blob: d9755da79ff96a24713970656fcec57a792cedfb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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
|