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