]>
Commit | Line | Data |
---|---|---|
721c1923 KS |
1 | /** |
2 | * @file yaml.h | |
3 | * @brief Public interface for libyaml. | |
4 | * | |
5 | * Include the header file with | |
6 | * @code | |
7 | * #include <yaml/yaml.h> | |
8 | * @endcode | |
9 | */ | |
9e05b78c | 10 | |
cec6fc98 KS |
11 | #ifndef YAML_H |
12 | #define YAML_H | |
9e05b78c KS |
13 | |
14 | #ifdef __cplusplus | |
15 | extern "C" { | |
16 | #endif | |
17 | ||
cec6fc98 KS |
18 | #include <stdlib.h> |
19 | ||
20 | #include "yaml_version.h" | |
21 | #include "yaml_error.h" | |
9e05b78c KS |
22 | |
23 | typedef enum { | |
cec6fc98 | 24 | YAML_DETECT_ENCODING, |
9e05b78c KS |
25 | YAML_UTF8_ENCODING, |
26 | YAML_UTF16LE_ENCODING, | |
27 | YAML_UTF16BE_ENCODING | |
28 | } yaml_encoding_t; | |
29 | ||
30 | typedef enum { | |
cec6fc98 | 31 | YAML_ANY_SCALAR_STYLE, |
9e05b78c KS |
32 | YAML_PLAIN_SCALAR_STYLE, |
33 | YAML_SINGLE_QUOTED_SCALAR_STYLE, | |
34 | YAML_DOUBLE_QUOTED_SCALAR_STYLE, | |
35 | YAML_LITERAL_SCALAR_STYLE, | |
36 | YAML_FOLDED_SCALAR_STYLE | |
37 | } yaml_scalar_style_t; | |
38 | ||
39 | typedef enum { | |
cec6fc98 | 40 | YAML_ANY_SEQUENCE_STYLE, |
9e05b78c KS |
41 | YAML_BLOCK_SEQUENCE_STYLE, |
42 | YAML_FLOW_SEQUENCE_STYLE | |
43 | } yaml_sequence_style_t; | |
44 | ||
45 | typedef enum { | |
cec6fc98 | 46 | YAML_ANY_MAPPING_STYLE, |
9e05b78c KS |
47 | YAML_BLOCK_MAPPING_STYLE, |
48 | YAML_FLOW_MAPPING_STYLE | |
49 | } yaml_mapping_style_t; | |
50 | ||
51 | typedef enum { | |
52 | YAML_STREAM_START_TOKEN, | |
53 | YAML_STREAM_END_TOKEN, | |
cec6fc98 | 54 | |
9e05b78c KS |
55 | YAML_VERSION_DIRECTIVE_TOKEN, |
56 | YAML_TAG_DIRECTIVE_TOKEN, | |
57 | YAML_DOCUMENT_START_TOKEN, | |
58 | YAML_DOCUMENT_END_TOKEN, | |
cec6fc98 | 59 | |
9e05b78c KS |
60 | YAML_BLOCK_SEQUENCE_START_TOKEN, |
61 | YAML_BLOCK_MAPPING_START_TOKEN, | |
62 | YAML_BLOCK_END_TOKEN, | |
cec6fc98 | 63 | |
9e05b78c KS |
64 | YAML_FLOW_SEQUENCE_START_TOKEN, |
65 | YAML_FLOW_SEQUENCE_END_TOKEN, | |
66 | YAML_FLOW_MAPPING_START_TOKEN, | |
67 | YAML_FLOW_MAPPING_END_TOKEN, | |
cec6fc98 | 68 | |
9e05b78c KS |
69 | YAML_BLOCK_ENTRY_TOKEN, |
70 | YAML_FLOW_ENTRY_TOKEN, | |
71 | YAML_KEY_TOKEN, | |
72 | YAML_VALUE_TOKEN, | |
cec6fc98 | 73 | |
9e05b78c KS |
74 | YAML_ALIAS_TOKEN, |
75 | YAML_ANCHOR_TOKEN, | |
76 | YAML_TAG_TOKEN, | |
77 | YAML_SCALAR_TOKEN | |
78 | } yaml_token_type_t; | |
79 | ||
80 | typedef enum { | |
81 | YAML_STREAM_START_EVENT, | |
82 | YAML_STREAM_END_EVENT, | |
cec6fc98 | 83 | |
9e05b78c KS |
84 | YAML_DOCUMENT_START_EVENT, |
85 | YAML_DOCUMENT_END_EVENT, | |
cec6fc98 | 86 | |
9e05b78c | 87 | YAML_ALIAS_EVENT, |
cec6fc98 KS |
88 | YAML_SCALAR_EVENT, |
89 | ||
9e05b78c KS |
90 | YAML_SEQUENCE_START_EVENT, |
91 | YAML_SEQUENCE_END_EVENT, | |
cec6fc98 | 92 | |
9e05b78c | 93 | YAML_MAPPING_START_EVENT, |
cec6fc98 | 94 | YAML_MAPPING_END_EVENT |
9e05b78c KS |
95 | } yaml_event_type_t; |
96 | ||
97 | typedef struct { | |
cec6fc98 | 98 | size_t offset; |
9e05b78c KS |
99 | size_t index; |
100 | size_t line; | |
101 | size_t column; | |
102 | } yaml_mark_t; | |
103 | ||
104 | typedef struct { | |
105 | yaml_error_type_t type; | |
106 | char *context; | |
107 | yaml_mark_t context_mark; | |
108 | char *problem; | |
109 | yaml_mark_t problem_mark; | |
110 | } yaml_error_t; | |
111 | ||
112 | typedef struct { | |
113 | yaml_token_type_t type; | |
114 | union { | |
115 | yaml_encoding_t encoding; | |
cec6fc98 KS |
116 | char *anchor; |
117 | char *tag; | |
9e05b78c | 118 | struct { |
cec6fc98 KS |
119 | char *value; |
120 | size_t length; | |
9e05b78c KS |
121 | yaml_scalar_style_t style; |
122 | } scalar; | |
123 | struct { | |
124 | int major; | |
125 | int minor; | |
126 | } version; | |
127 | struct { | |
cec6fc98 KS |
128 | char *handle; |
129 | char *prefix; | |
9e05b78c KS |
130 | } tag_pair; |
131 | } data; | |
132 | yaml_mark_t start_mark; | |
133 | yaml_mark_t end_mark; | |
134 | } yaml_token_t; | |
135 | ||
136 | typedef struct { | |
137 | yaml_event_type_t type; | |
138 | union { | |
139 | struct { | |
140 | yaml_encoding_t encoding; | |
141 | } stream_start; | |
142 | struct { | |
143 | struct { | |
144 | int major; | |
145 | int minor; | |
146 | } version; | |
147 | struct { | |
cec6fc98 KS |
148 | char *handle; |
149 | char *prefix; | |
9e05b78c KS |
150 | } **tag_pairs; |
151 | int implicit; | |
152 | } document_start; | |
153 | struct { | |
154 | int implicit; | |
155 | } document_end; | |
156 | struct { | |
cec6fc98 | 157 | char *anchor; |
9e05b78c KS |
158 | } alias; |
159 | struct { | |
cec6fc98 KS |
160 | char *anchor; |
161 | char *tag; | |
162 | char *value; | |
163 | size_t length; | |
9e05b78c KS |
164 | int plain_implicit; |
165 | int quoted_implicit; | |
166 | yaml_scalar_style_t style; | |
167 | } scalar; | |
168 | struct { | |
cec6fc98 KS |
169 | char *anchor; |
170 | char *tag; | |
9e05b78c KS |
171 | int implicit; |
172 | yaml_sequence_style_t style; | |
173 | } sequence_start; | |
174 | struct { | |
cec6fc98 KS |
175 | char *anchor; |
176 | char *tag; | |
9e05b78c KS |
177 | int implicit; |
178 | yaml_mapping_style_t style; | |
179 | } mapping_start; | |
180 | } data; | |
181 | yaml_mark_t start_mark; | |
182 | yaml_mark_t end_mark; | |
183 | } yaml_event_t; | |
184 | ||
cec6fc98 | 185 | /* |
9e05b78c KS |
186 | typedef struct { |
187 | } yaml_parser_t; | |
188 | ||
9e05b78c KS |
189 | typedef struct { |
190 | } yaml_emitter_t; | |
cec6fc98 | 191 | */ |
9e05b78c KS |
192 | |
193 | #ifdef __cplusplus | |
194 | } | |
195 | #endif | |
196 | ||
cec6fc98 | 197 | #endif /* #ifndef YAML_H */ |
9e05b78c | 198 |