Changeset 183 for libyaml/trunk/include/yaml/yaml.h
- Timestamp:
- 06/02/06 09:03:14 (7 years ago)
- File:
-
- 1 edited
-
libyaml/trunk/include/yaml/yaml.h (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libyaml/trunk/include/yaml/yaml.h
r182 r183 21 21 22 22 /** 23 * @defgroup Export Definitions 24 * @{ 25 */ 26 27 /** The public API declaration. */ 28 29 #ifdef WIN32 30 # if defined(YAML_DECLARE_STATIC) 31 # define YAML_DECLARE(type) type 32 # elif defined(YAML_DECLARE_EXPORT) 33 # define YAML_DECLARE(type) __declspec(dllexport) type 34 # else 35 # define YAML_DECLARE(type) __declspec(dllimport) type 36 # endif 37 #else 38 # define YAML_DECLARE(type) type 39 #endif 40 41 /** @} */ 42 43 /** 23 44 * @defgroup version Version Information 24 45 * @{ … … 33 54 */ 34 55 35 const char * 56 YAML_DECLARE(const char *) 36 57 yaml_get_version_string(void); 37 58 … … 44 65 */ 45 66 46 void 67 YAML_DECLARE(void) 47 68 yaml_get_version(int *major, int *minor, int *patch); 48 69 … … 54 75 */ 55 76 56 /** The character type . */77 /** The character type (UTF-8 octet). */ 57 78 typedef unsigned char yaml_char_t; 58 79 … … 79 100 } yaml_error_type_t; 80 101 102 /** The pointer position. */ 103 typedef struct { 104 /** The position index. */ 105 size_t index; 106 107 /** The position line. */ 108 size_t line; 109 110 /** The position column. */ 111 size_t column; 112 } yaml_mark_t; 113 81 114 /** @} */ 82 115 83 /* 84 116 /** 117 * @defgroup Node Styles 118 * @{ 119 */ 120 121 /** Scalar styles. */ 85 122 typedef enum { 86 123 YAML_ANY_SCALAR_STYLE, 124 87 125 YAML_PLAIN_SCALAR_STYLE, 126 88 127 YAML_SINGLE_QUOTED_SCALAR_STYLE, 89 128 YAML_DOUBLE_QUOTED_SCALAR_STYLE, 129 90 130 YAML_LITERAL_SCALAR_STYLE, 91 131 YAML_FOLDED_SCALAR_STYLE 92 132 } yaml_scalar_style_t; 93 133 134 135 /** Sequence styles. */ 94 136 typedef enum { 95 137 YAML_ANY_SEQUENCE_STYLE, 138 96 139 YAML_BLOCK_SEQUENCE_STYLE, 97 140 YAML_FLOW_SEQUENCE_STYLE 98 141 } yaml_sequence_style_t; 99 142 143 /** Mapping styles. */ 100 144 typedef enum { 101 145 YAML_ANY_MAPPING_STYLE, 146 102 147 YAML_BLOCK_MAPPING_STYLE, 103 148 YAML_FLOW_MAPPING_STYLE 104 149 } yaml_mapping_style_t; 105 150 151 /** @} */ 152 153 /** 154 * @defgroup Tokens 155 * @{ 156 */ 157 158 /** Token types. */ 106 159 typedef enum { 107 160 YAML_STREAM_START_TOKEN, … … 133 186 } yaml_token_type_t; 134 187 188 /** The token structure. */ 189 typedef struct { 190 191 /** The token type. */ 192 yaml_token_type_t type; 193 194 /** The token data. */ 195 union { 196 197 /** The stream encoding (for @c YAML_STREAM_START_TOKEN). */ 198 yaml_encoding_t encoding; 199 200 /** The anchor (for @c YAML_ALIAS_TOKEN and @c YAML_ANCHOR_TOKEN). */ 201 yaml_char_t *anchor; 202 203 /** The tag (for @c YAML_TAG_TOKEN). */ 204 struct { 205 /** The tag handle. */ 206 yaml_char_t *handle; 207 208 /** The tag suffix. */ 209 yaml_char_t *suffix; 210 } tag; 211 212 /** The scalar value (for @c YAML_SCALAR_TOKEN). */ 213 struct { 214 215 /** The scalar value. */ 216 yaml_char_t *value; 217 218 /** The length of the scalar value. */ 219 size_t length; 220 221 /** The scalar style. */ 222 yaml_scalar_style_t style; 223 } scalar; 224 225 /** The version directive (for @c YAML_VERSION_DIRECTIVE_TOKEN). */ 226 struct { 227 /** The major version number. */ 228 int major; 229 230 /** The minor version number. */ 231 int minor; 232 } version_directive; 233 234 /** The tag directive (for @c YAML_TAG_DIRECTIVE_TOKEN). */ 235 struct { 236 /** The tag handle. */ 237 yaml_char_t *handle; 238 239 /** The tag prefix. */ 240 yaml_char_t *prefix; 241 } tag_directive; 242 } data; 243 244 /** The beginning of the token. */ 245 yaml_mark_t start_mark; 246 247 /** The end of the token. */ 248 yaml_mark_t end_mark; 249 250 } yaml_token_t; 251 252 /** 253 * Create a new token without assigning any data. 254 * 255 * This function can be used for constructing indicator tokens: 256 * @c YAML_DOCUMENT_START, @c YAML_DOCUMENT_END, 257 * @c YAML_BLOCK_SEQUENCE_START_TOKEN, @c YAML_BLOCK_MAPPING_START_TOKEN, 258 * @c YAML_BLOCK_END_TOKEN, 259 * @c YAML_FLOW_SEQUENCE_START_TOKEN, @c YAML_FLOW_SEQUENCE_END_TOKEN, 260 * @c YAML_FLOW_MAPPING_START_TOKEN, @c YAML_FLOW_MAPPING_END_TOKEN, 261 * @c YAML_BLOCK_ENTRY_TOKEN, @c YAML_FLOW_ENTRY_TOKEN, 262 * @c YAML_KEY_TOKEN, @c YAML_VALUE_TOKEN. 263 * 264 * @param[in] type The token type. 265 * @param[in] start_mark The beginning of the token. 266 * @param[in] end_mark The end of the token. 267 * 268 * @returns A new token object, or @c NULL on error. 269 */ 270 271 YAML_DECLARE(yaml_token_t *) 272 yaml_token_new(yaml_token_type_t type, 273 yaml_mark_t start_mark, yaml_mark_t end_mark); 274 275 /** 276 * Create a new @c YAML_STREAM_START_TOKEN token with the specified encoding. 277 * 278 * @param[in] encoding The stream encoding. 279 * @param[in] start_mark The beginning of the token. 280 * @param[in] end_mark The end of the token. 281 * 282 * @returns A new token object, or @c NULL on error. 283 */ 284 285 YAML_DECLARE(yaml_token_t *) 286 yaml_stream_start_token_new(yaml_encoding_t encoding, 287 yaml_mark_t start_mark, yaml_mark_t end_mark); 288 289 /** 290 * Create a new @c YAML_STREAM_END_TOKEN token. 291 * 292 * @param[in] start_mark The beginning of the token. 293 * @param[in] end_mark The end of the token. 294 * 295 * @returns A new token object, or @c NULL on error. 296 */ 297 298 YAML_DECLARE(yaml_token_t *) 299 yaml_stream_end_token_new(yaml_mark_t start_mark, yaml_mark_t end_mark); 300 301 /** 302 * Create a new @c YAML_VERSION_DIRECTIVE_TOKEN token with the specified 303 * version numbers. 304 * 305 * @param[in] major The major version number. 306 * @param[in] minor The minor version number. 307 * @param[in] start_mark The beginning of the token. 308 * @param[in] end_mark The end of the token. 309 * 310 * @returns A new token object, or @c NULL on error. 311 */ 312 313 YAML_DECLARE(yaml_token_t *) 314 yaml_version_directive_token_new(int major, int minor, 315 yaml_mark_t start_mark, yaml_mark_t end_mark); 316 317 /** 318 * Create a new @c YAML_TAG_DIRECTIVE_TOKEN token with the specified tag 319 * handle and prefix. 320 * 321 * Note that the @a handle and the @a prefix pointers will be freed by 322 * the token descructor. 323 * 324 * @param[in] handle The tag handle. 325 * @param[in] prefix The tag prefix. 326 * @param[in] start_mark The beginning of the token. 327 * @param[in] end_mark The end of the token. 328 * 329 * @returns A new token object, or @c NULL on error. 330 */ 331 332 YAML_DECLARE(yaml_token_t *) 333 yaml_tag_directive_token_new(yaml_char_t *handle, yaml_char_t *prefix, 334 yaml_mark_t start_mark, yaml_mark_t end_mark); 335 336 /** 337 * Create a new @c YAML_ALIAS_TOKEN token with the specified anchor. 338 * 339 * Note that the @a anchor pointer will be freed by the token descructor. 340 * 341 * @param[in] anchor The anchor. 342 * @param[in] start_mark The beginning of the token. 343 * @param[in] end_mark The end of the token. 344 * 345 * @returns A new token object, or @c NULL on error. 346 */ 347 348 YAML_DECLARE(yaml_token_t *) 349 yaml_alias_token_new(yaml_char_t *anchor, 350 yaml_mark_t start_mark, yaml_mark_t end_mark); 351 352 /** 353 * Create a new @c YAML_ANCHOR_TOKEN token with the specified anchor. 354 * 355 * Note that the @a anchor pointer will be freed by the token descructor. 356 * 357 * @param[in] anchor The anchor. 358 * @param[in] start_mark The beginning of the token. 359 * @param[in] end_mark The end of the token. 360 * 361 * @returns A new token object, or @c NULL on error. 362 */ 363 364 YAML_DECLARE(yaml_token_t *) 365 yaml_anchor_token_new(yaml_char_t *anchor, 366 yaml_mark_t start_mark, yaml_mark_t end_mark); 367 368 /** 369 * Create a new @c YAML_TAG_TOKEN token with the specified tag handle and 370 * suffix. 371 * 372 * Note that the @a handle and the @a suffix pointers will be freed by 373 * the token descructor. 374 * 375 * @param[in] handle The tag handle. 376 * @param[in] suffix The tag suffix. 377 * @param[in] start_mark The beginning of the token. 378 * @param[in] end_mark The end of the token. 379 * 380 * @returns A new token object, or @c NULL on error. 381 */ 382 383 YAML_DECLARE(yaml_token_t *) 384 yaml_tag_token_new(yaml_char_t *handle, yaml_char_t *suffix, 385 yaml_mark_t start_mark, yaml_mark_t end_mark); 386 387 /** 388 * Create a new @c YAML_SCALAR_TOKEN token with the specified scalar value, 389 * length, and style. 390 * 391 * Note that the scalar value may contain the @c NUL character, therefore 392 * the value length is also required. The scalar value always ends with 393 * @c NUL. 394 * 395 * Note that the @a value pointer will be freed by the token descructor. 396 * 397 * @param[in] value The scalar value. 398 * @param[in] length The value length. 399 * @param[in] style The scalar style. 400 * @param[in] start_mark The beginning of the token. 401 * @param[in] end_mark The end of the token. 402 * 403 * @returns A new token object, or @c NULL on error. 404 */ 405 406 YAML_DECLARE(yaml_token_t *) 407 yaml_scalar_token_new(yaml_char_t *value, size_t length, 408 yaml_scalar_style_t style, 409 yaml_mark_t start_mark, yaml_mark_t end_mark); 410 411 /** 412 * Destroy a token object. 413 * 414 * @param[in] token A token object. 415 */ 416 417 YAML_DECLARE(void) 418 yaml_token_delete(yaml_token_t *token); 419 420 /** @} */ 421 422 /* 423 135 424 typedef enum { 136 425 YAML_STREAM_START_EVENT, … … 149 438 YAML_MAPPING_END_EVENT 150 439 } yaml_event_type_t; 151 152 typedef struct {153 size_t offset;154 size_t index;155 size_t line;156 size_t column;157 } yaml_mark_t;158 159 typedef struct {160 yaml_error_type_t type;161 char *context;162 yaml_mark_t context_mark;163 char *problem;164 yaml_mark_t problem_mark;165 } yaml_error_t;166 167 typedef struct {168 yaml_token_type_t type;169 union {170 yaml_encoding_t encoding;171 char *anchor;172 char *tag;173 struct {174 char *value;175 size_t length;176 yaml_scalar_style_t style;177 } scalar;178 struct {179 int major;180 int minor;181 } version;182 struct {183 char *handle;184 char *prefix;185 } tag_pair;186 } data;187 yaml_mark_t start_mark;188 yaml_mark_t end_mark;189 } yaml_token_t;190 440 191 441 typedef struct { … … 273 523 274 524 typedef struct { 525 /** The string start pointer. */ 275 526 unsigned char *start; 527 528 /** The string end pointer. */ 276 529 unsigned char *end; 530 531 /** The string current position. */ 277 532 unsigned char *current; 278 533 } yaml_string_input_t; … … 376 631 */ 377 632 378 yaml_parser_t * 633 YAML_DECLARE(yaml_parser_t *) 379 634 yaml_parser_new(void); 380 635 … … 385 640 */ 386 641 387 void 642 YAML_DECLARE(void) 388 643 yaml_parser_delete(yaml_parser_t *parser); 389 644 … … 397 652 * @param[in] parser A parser object. 398 653 * @param[in] input A source data. 399 * @param[in] lengthThe length of the source data in bytes.400 */ 401 402 void 654 * @param[in] size The length of the source data in bytes. 655 */ 656 657 YAML_DECLARE(void) 403 658 yaml_parser_set_input_string(yaml_parser_t *parser, 404 659 unsigned char *input, size_t size); … … 415 670 */ 416 671 417 void 672 YAML_DECLARE(void) 418 673 yaml_parser_set_input_file(yaml_parser_t *parser, FILE *file); 419 674 … … 426 681 */ 427 682 428 void 683 YAML_DECLARE(void) 429 684 yaml_parser_set_input(yaml_parser_t *parser, 430 685 yaml_read_handler_t *handler, void *data); … … 433 688 * Set the source encoding. 434 689 * 690 * @param[in] parser A parser object. 435 691 * @param[in] encoding The source encoding. 436 692 */ 437 693 438 void 694 YAML_DECLARE(void) 439 695 yaml_parser_set_encoding(yaml_parser_t *parser, yaml_encoding_t encoding); 440 696 … … 460 716 */ 461 717 462 void * 718 YAML_DECLARE(void *) 463 719 yaml_malloc(size_t size); 464 720 … … 474 730 */ 475 731 476 void * 732 YAML_DECLARE(void *) 477 733 yaml_realloc(void *ptr, size_t size); 478 734 … … 484 740 */ 485 741 486 void 742 YAML_DECLARE(void) 487 743 yaml_free(void *ptr); 488 744 … … 508 764 */ 509 765 510 int 766 YAML_DECLARE(int) 511 767 yaml_parser_update_buffer(yaml_parser_t *parser, size_t length); 512 768
Note: See TracChangeset
for help on using the changeset viewer.
