aboutsummaryrefslogtreecommitdiff
path: root/src/vdf/vdf.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/vdf/vdf.h')
-rw-r--r--src/vdf/vdf.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/vdf/vdf.h b/src/vdf/vdf.h
new file mode 100644
index 0000000..d9755da
--- /dev/null
+++ b/src/vdf/vdf.h
@@ -0,0 +1,75 @@
+#ifndef VDF_H
+#define VDF_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stddef.h>
+#include <stdint.h>
+
+enum vdf_data_type
+{
+ VDF_TYPE_NONE,
+ VDF_TYPE_ARRAY,
+ VDF_TYPE_STRING,
+ VDF_TYPE_INT,
+ VDF_TYPE_FLOAT,
+ VDF_TYPE_PTR,
+ VDF_TYPE_WSTRING,
+ VDF_TYPE_COLOR
+};
+
+struct vdf_object;
+
+union vdf_data {
+ struct {
+ struct vdf_object** data_value;
+ size_t len;
+ } data_array;
+
+ struct {
+ char* str;
+ size_t len;
+ } data_string;
+
+ int data_int;
+ float data_float;
+
+ void* data_ptr; // TYPE?
+
+ struct {
+ wchar_t* str;
+ size_t len;
+ } data_wstring;
+
+ uint32_t color; // RGBA
+};
+
+struct vdf_object
+{
+ char* key;
+ struct vdf_object* parent;
+
+ enum vdf_data_type type;
+ union vdf_data data;
+};
+
+struct vdf_object* vdf_parse_file(const char* path);
+
+size_t vdf_object_get_array_length(struct vdf_object* o);
+struct vdf_object* vdf_object_index_array(struct vdf_object* o, size_t index);
+struct vdf_object* vdf_object_index_array_str(struct vdf_object* o, char* str);
+
+const char* vdf_object_get_string(struct vdf_object* o);
+
+int vdf_object_get_int(struct vdf_object* o);
+
+void vdf_print_object(struct vdf_object* o);
+void vdf_free_object(struct vdf_object* o);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif \ No newline at end of file