-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyaml_c_wrapper.h
More file actions
79 lines (63 loc) · 2.77 KB
/
yaml_c_wrapper.h
File metadata and controls
79 lines (63 loc) · 2.77 KB
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
76
77
78
79
#ifndef YAML_C_WRAPPER_H
#define YAML_C_WRAPPER_H
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef void* YAMLNodeHandle;
// === CREATION ===
YAMLNodeHandle yaml_create_node(void);
YAMLNodeHandle yaml_create_map(void);
YAMLNodeHandle yaml_create_sequence(void);
YAMLNodeHandle yaml_create_scalar();
void yaml_delete_node(YAMLNodeHandle handle);
// === PARSING ===
YAMLNodeHandle yaml_parse(const char* yaml_str);
YAMLNodeHandle yaml_parse_file(const char* filename);
// === TYPE CHECKING ===
bool yaml_is_scalar(YAMLNodeHandle handle);
bool yaml_is_sequence(YAMLNodeHandle handle);
bool yaml_is_map(YAMLNodeHandle handle);
bool yaml_is_null(YAMLNodeHandle handle);
// === ACCESS ===
YAMLNodeHandle yaml_get_key(YAMLNodeHandle handle, const char* key);
YAMLNodeHandle yaml_get_index(YAMLNodeHandle handle, int index);
bool yaml_has_key(YAMLNodeHandle handle, const char* key);
int yaml_size(YAMLNodeHandle handle);
// === CONVERSION ===
char* yaml_as_string(YAMLNodeHandle handle);
int yaml_as_int(YAMLNodeHandle handle);
double yaml_as_float(YAMLNodeHandle handle);
bool yaml_as_bool(YAMLNodeHandle handle);
void yaml_free_string(char* str);
// === MODIFICATION ===
void yaml_set_string(YAMLNodeHandle handle, const char* key, const char* value);
void yaml_set_int(YAMLNodeHandle handle, const char* key, int value);
void yaml_set_float(YAMLNodeHandle handle, const char* key, double value);
void yaml_set_bool(YAMLNodeHandle handle, const char* key, bool value);
void yaml_set_node(YAMLNodeHandle handle, const char* key, YAMLNodeHandle value);
void yaml_set_scalar_string(YAMLNodeHandle handle, const char* value);
void yaml_set_scalar_int(YAMLNodeHandle handle, int value);
void yaml_set_scalar_float(YAMLNodeHandle handle, double value);
void yaml_set_scalar_bool(YAMLNodeHandle handle, bool value);
void yaml_set_at_index(YAMLNodeHandle handle, int index, YAMLNodeHandle value) ;
void yaml_push_string(YAMLNodeHandle handle, const char* value);
void yaml_push_int(YAMLNodeHandle handle, int value);
void yaml_push_float(YAMLNodeHandle handle, double value);
void yaml_push_bool(YAMLNodeHandle handle, bool value);
void yaml_push_node(YAMLNodeHandle handle, YAMLNodeHandle value);
// === UTILITY ===
char* yaml_to_string(YAMLNodeHandle handle);
char* yaml_emit(YAMLNodeHandle handle, int indent);
YAMLNodeHandle yaml_clone(YAMLNodeHandle handle);
YAMLNodeHandle yaml_expand(YAMLNodeHandle handle);
bool yaml_write_file(YAMLNodeHandle handle, const char* filename);
bool yaml_write_file_formatted(YAMLNodeHandle handle, const char* filename,
int indent, bool flow_maps, bool flow_seqs);
// === KEY UTILITIES ===
char** yaml_get_keys(YAMLNodeHandle handle, int* out_count);
void yaml_free_keys(char** keys, int count);
#ifdef __cplusplus
}
#endif
#endif // YAML_C_WRAPPER_H