Changeset 208 for libyaml/trunk/include/yaml.h
- Timestamp:
- 07/21/06 09:50:32 (7 years ago)
- File:
-
- 1 edited
-
libyaml/trunk/include/yaml.h (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libyaml/trunk/include/yaml.h
r202 r208 148 148 } yaml_scalar_style_t; 149 149 150 151 150 /** Sequence styles. */ 152 151 typedef enum { … … 162 161 163 162 YAML_BLOCK_MAPPING_STYLE, 164 YAML_FLOW_MAPPING_STYLE 163 YAML_FLOW_MAPPING_STYLE, 164 YAML_FLOW_SET_MAPPING_STYLE 165 165 } yaml_mapping_style_t; 166 166 … … 174 174 /** Token types. */ 175 175 typedef enum { 176 YAML_NO_TOKEN, 177 176 178 YAML_STREAM_START_TOKEN, 177 179 YAML_STREAM_END_TOKEN, … … 233 235 /** The tag handle. */ 234 236 yaml_char_t *handle; 235 236 237 /** The tag suffix. */ 237 238 yaml_char_t *suffix; … … 240 241 /** The scalar value (for @c YAML_SCALAR_TOKEN). */ 241 242 struct { 242 243 243 /** The scalar value. */ 244 244 yaml_char_t *value; 245 246 245 /** The length of the scalar value. */ 247 246 size_t length; 248 249 247 /** The scalar style. */ 250 248 yaml_scalar_style_t style; … … 255 253 /** The major version number. */ 256 254 int major; 257 258 255 /** The minor version number. */ 259 256 int minor; … … 264 261 /** The tag handle. */ 265 262 yaml_char_t *handle; 266 267 263 /** The tag prefix. */ 268 264 yaml_char_t *prefix; 269 265 } tag_directive; 266 270 267 } data; 271 268 272 269 /** The beginning of the token. */ 273 270 yaml_mark_t start_mark; 274 275 271 /** The end of the token. */ 276 272 yaml_mark_t end_mark; … … 279 275 280 276 /** 281 * Create a new token without assigning any data. 282 * 283 * This function can be used for constructing indicator tokens: 284 * @c YAML_DOCUMENT_START, @c YAML_DOCUMENT_END, 285 * @c YAML_BLOCK_SEQUENCE_START_TOKEN, @c YAML_BLOCK_MAPPING_START_TOKEN, 286 * @c YAML_BLOCK_END_TOKEN, 287 * @c YAML_FLOW_SEQUENCE_START_TOKEN, @c YAML_FLOW_SEQUENCE_END_TOKEN, 288 * @c YAML_FLOW_MAPPING_START_TOKEN, @c YAML_FLOW_MAPPING_END_TOKEN, 289 * @c YAML_BLOCK_ENTRY_TOKEN, @c YAML_FLOW_ENTRY_TOKEN, 290 * @c YAML_KEY_TOKEN, @c YAML_VALUE_TOKEN. 291 * 292 * @param[in] type The token type. 293 * @param[in] start_mark The beginning of the token. 294 * @param[in] end_mark The end of the token. 295 * 296 * @returns A new token object, or @c NULL on error. 297 */ 298 299 YAML_DECLARE(yaml_token_t *) 300 yaml_token_new(yaml_token_type_t type, 301 yaml_mark_t start_mark, yaml_mark_t end_mark); 302 303 /** 304 * Create a new @c YAML_STREAM_START_TOKEN token with the specified encoding. 305 * 306 * @param[in] encoding The stream encoding. 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_stream_start_token_new(yaml_encoding_t encoding, 315 yaml_mark_t start_mark, yaml_mark_t end_mark); 316 317 /** 318 * Create a new @c YAML_STREAM_END_TOKEN token. 319 * 320 * @param[in] start_mark The beginning of the token. 321 * @param[in] end_mark The end of the token. 322 * 323 * @returns A new token object, or @c NULL on error. 324 */ 325 326 YAML_DECLARE(yaml_token_t *) 327 yaml_stream_end_token_new(yaml_mark_t start_mark, yaml_mark_t end_mark); 328 329 /** 330 * Create a new @c YAML_VERSION_DIRECTIVE_TOKEN token with the specified 331 * version numbers. 332 * 333 * @param[in] major The major version number. 334 * @param[in] minor The minor version number. 335 * @param[in] start_mark The beginning of the token. 336 * @param[in] end_mark The end of the token. 337 * 338 * @returns A new token object, or @c NULL on error. 339 */ 340 341 YAML_DECLARE(yaml_token_t *) 342 yaml_version_directive_token_new(int major, int minor, 343 yaml_mark_t start_mark, yaml_mark_t end_mark); 344 345 /** 346 * Create a new @c YAML_TAG_DIRECTIVE_TOKEN token with the specified tag 347 * handle and prefix. 348 * 349 * Note that the @a handle and the @a prefix pointers will be freed by 350 * the token descructor. 351 * 352 * @param[in] handle The tag handle. 353 * @param[in] prefix The tag prefix. 354 * @param[in] start_mark The beginning of the token. 355 * @param[in] end_mark The end of the token. 356 * 357 * @returns A new token object, or @c NULL on error. 358 */ 359 360 YAML_DECLARE(yaml_token_t *) 361 yaml_tag_directive_token_new(yaml_char_t *handle, yaml_char_t *prefix, 362 yaml_mark_t start_mark, yaml_mark_t end_mark); 363 364 /** 365 * Create a new @c YAML_ALIAS_TOKEN token with the specified anchor. 366 * 367 * Note that the @a anchor pointer will be freed by the token descructor. 368 * 369 * @param[in] anchor The anchor. 370 * @param[in] start_mark The beginning of the token. 371 * @param[in] end_mark The end of the token. 372 * 373 * @returns A new token object, or @c NULL on error. 374 */ 375 376 YAML_DECLARE(yaml_token_t *) 377 yaml_alias_token_new(yaml_char_t *anchor, 378 yaml_mark_t start_mark, yaml_mark_t end_mark); 379 380 /** 381 * Create a new @c YAML_ANCHOR_TOKEN token with the specified anchor. 382 * 383 * Note that the @a anchor pointer will be freed by the token descructor. 384 * 385 * @param[in] anchor The anchor. 386 * @param[in] start_mark The beginning of the token. 387 * @param[in] end_mark The end of the token. 388 * 389 * @returns A new token object, or @c NULL on error. 390 */ 391 392 YAML_DECLARE(yaml_token_t *) 393 yaml_anchor_token_new(yaml_char_t *anchor, 394 yaml_mark_t start_mark, yaml_mark_t end_mark); 395 396 /** 397 * Create a new @c YAML_TAG_TOKEN token with the specified tag handle and 398 * suffix. 399 * 400 * Note that the @a handle and the @a suffix pointers will be freed by 401 * the token descructor. 402 * 403 * @param[in] handle The tag handle. 404 * @param[in] suffix The tag suffix. 405 * @param[in] start_mark The beginning of the token. 406 * @param[in] end_mark The end of the token. 407 * 408 * @returns A new token object, or @c NULL on error. 409 */ 410 411 YAML_DECLARE(yaml_token_t *) 412 yaml_tag_token_new(yaml_char_t *handle, yaml_char_t *suffix, 413 yaml_mark_t start_mark, yaml_mark_t end_mark); 414 415 /** 416 * Create a new @c YAML_SCALAR_TOKEN token with the specified scalar value, 417 * length, and style. 418 * 419 * Note that the scalar value may contain the @c NUL character, therefore 420 * the value length is also required. The scalar value always ends with 421 * @c NUL. 422 * 423 * Note that the @a value pointer will be freed by the token descructor. 424 * 425 * @param[in] value The scalar value. 426 * @param[in] length The value length. 427 * @param[in] style The scalar style. 428 * @param[in] start_mark The beginning of the token. 429 * @param[in] end_mark The end of the token. 430 * 431 * @returns A new token object, or @c NULL on error. 432 */ 433 434 YAML_DECLARE(yaml_token_t *) 435 yaml_scalar_token_new(yaml_char_t *value, size_t length, 436 yaml_scalar_style_t style, 437 yaml_mark_t start_mark, yaml_mark_t end_mark); 438 439 /** 440 * Destroy a token object. 277 * Free any memory allocated for a token object. 441 278 * 442 279 * @param[in] token A token object. … … 455 292 /** Event types. */ 456 293 typedef enum { 294 YAML_NO_EVENT, 295 457 296 YAML_STREAM_START_EVENT, 458 297 YAML_STREAM_END_EVENT, … … 490 329 /** The version directive. */ 491 330 yaml_version_directive_t *version_directive; 331 492 332 /** The list of tag directives. */ 493 yaml_tag_directive_t **tag_directives; 333 struct { 334 /** The beginning of the tag directives list. */ 335 yaml_tag_directive_t *start; 336 /** The end of the tag directives list. */ 337 yaml_tag_directive_t *end; 338 } tag_directives; 339 494 340 /** Is the document indicator implicit? */ 495 341 int implicit; … … 554 400 /** The beginning of the token. */ 555 401 yaml_mark_t start_mark; 556 557 402 /** The end of the token. */ 558 403 yaml_mark_t end_mark; 404 559 405 } yaml_event_t; 560 406 561 407 /** 562 * Create a new @c YAML_STREAM_START_EVENT event. 563 * 564 * @param[in] encoding The stream encoding. 565 * @param[in] start_mark The beginning of the event. 566 * @param[in] end_mark The end of the event. 567 * 568 * @returns A new event object, or @c NULL on error. 569 */ 570 571 YAML_DECLARE(yaml_event_t *) 572 yaml_stream_start_event_new(yaml_encoding_t encoding, 573 yaml_mark_t start_mark, yaml_mark_t end_mark); 574 575 /** 576 * Create a new @c YAML_STREAM_END_TOKEN event. 577 * 578 * @param[in] start_mark The beginning of the event. 579 * @param[in] end_mark The end of the event. 580 * 581 * @returns A new event object, or @c NULL on error. 582 */ 583 584 YAML_DECLARE(yaml_event_t *) 585 yaml_stream_end_event_new(yaml_mark_t start_mark, yaml_mark_t end_mark); 586 587 /** 588 * Create a new @c YAML_DOCUMENT_START_EVENT event. 589 * 590 * @param[in] version_directive The version directive or @c NULL. 591 * @param[in] tag_directives A list of tag directives or @c NULL. 592 * @param[in] implicit Is the document indicator present? 593 * @param[in] start_mark The beginning of the event. 594 * @param[in] end_mark The end of the event. 595 * 596 * @returns A new event object, or @c NULL on error. 597 */ 598 599 YAML_DECLARE(yaml_event_t *) 600 yaml_document_start_event_new(yaml_version_directive_t *version_directive, 601 yaml_tag_directive_t **tag_directives, int implicit, 602 yaml_mark_t start_mark, yaml_mark_t end_mark); 603 604 /** 605 * Create a new @c YAML_DOCUMENT_END_EVENT event. 606 * 607 * @param[in] implicit Is the document end indicator present? 608 * @param[in] start_mark The beginning of the event. 609 * @param[in] end_mark The end of the event. 610 * 611 * @returns A new event object, or @c NULL on error. 612 */ 613 614 YAML_DECLARE(yaml_event_t *) 615 yaml_document_end_event_new(int implicit, 616 yaml_mark_t start_mark, yaml_mark_t end_mark); 617 618 /** 619 * Create a new @c YAML_ALIAS_EVENT event. 620 * 621 * @param[in] anchor The anchor value. 622 * @param[in] start_mark The beginning of the event. 623 * @param[in] end_mark The end of the event. 624 * 625 * @returns A new event object, or @c NULL on error. 626 */ 627 628 YAML_DECLARE(yaml_event_t *) 629 yaml_alias_event_new(yaml_char_t *anchor, 630 yaml_mark_t start_mark, yaml_mark_t end_mark); 631 632 /** 633 * Create a new @c YAML_SCALAR_EVENT event. 634 * 635 * @param[in] anchor The anchor value or @c NULL. 636 * @param[in] tag The tag value or @c NULL. 637 * @param[in] value The scalar value. 638 * @param[in] length The length of the scalar value. 639 * @param[in] plain_implicit Is the tag optional for the plain style? 640 * @param[in] quoted_implicit Is the tag optional for any non-plain style? 641 * @param[in] style The scalar style. 642 * @param[in] start_mark The beginning of the event. 643 * @param[in] end_mark The end of the event. 644 * 645 * @returns A new event object, or @c NULL on error. 646 */ 647 648 YAML_DECLARE(yaml_event_t *) 649 yaml_scalar_event_new(yaml_char_t *anchor, yaml_char_t *tag, 650 yaml_char_t *value, size_t length, 651 int plain_implicit, int quoted_implicit, 652 yaml_scalar_style_t style, 653 yaml_mark_t start_mark, yaml_mark_t end_mark); 654 655 /** 656 * Create a new @c YAML_SEQUENCE_START_EVENT event. 657 * 658 * @param[in] anchor The anchor value or @c NULL. 659 * @param[in] tag The tag value or @c NULL. 660 * @param[in] implicit Is the tag optional? 661 * @param[in] style The sequence style. 662 * @param[in] start_mark The beginning of the event. 663 * @param[in] end_mark The end of the event. 664 * 665 * @returns A new event object, or @c NULL on error. 666 */ 667 668 YAML_DECLARE(yaml_event_t *) 669 yaml_sequence_start_event_new(yaml_char_t *anchor, yaml_char_t *tag, 670 int implicit, yaml_sequence_style_t style, 671 yaml_mark_t start_mark, yaml_mark_t end_mark); 672 673 /** 674 * Create a new @c YAML_SEQUENCE_END_EVENT event. 675 * 676 * @param[in] start_mark The beginning of the event. 677 * @param[in] end_mark The end of the event. 678 * 679 * @returns A new event object, or @c NULL on error. 680 */ 681 682 YAML_DECLARE(yaml_event_t *) 683 yaml_sequence_end_event_new(yaml_mark_t start_mark, yaml_mark_t end_mark); 684 685 /** 686 * Create a new @c YAML_MAPPING_START_EVENT event. 687 * 688 * @param[in] anchor The anchor value or @c NULL. 689 * @param[in] tag The tag value or @c NULL. 690 * @param[in] implicit Is the tag optional? 691 * @param[in] style The mapping style. 692 * @param[in] start_mark The beginning of the event. 693 * @param[in] end_mark The end of the event. 694 * 695 * @returns A new event object, or @c NULL on error. 696 */ 697 698 YAML_DECLARE(yaml_event_t *) 699 yaml_mapping_start_event_new(yaml_char_t *anchor, yaml_char_t *tag, 700 int implicit, yaml_mapping_style_t style, 701 yaml_mark_t start_mark, yaml_mark_t end_mark); 702 703 /** 704 * Create a new @c YAML_MAPPING_END_EVENT event. 705 * 706 * @param[in] start_mark The beginning of the event. 707 * @param[in] end_mark The end of the event. 708 * 709 * @returns A new event object, or @c NULL on error. 710 */ 711 712 YAML_DECLARE(yaml_event_t *) 713 yaml_mapping_end_event_new(yaml_mark_t start_mark, yaml_mark_t end_mark); 714 715 /** 716 * Destroy an event object. 408 * Free any memory allocated for an event object. 717 409 * 718 410 * @param[in] event An event object. … … 751 443 752 444 /** 753 * This structure holds a string input specified by 754 * @c yaml_parser_set_input_string. 445 * This structure holds information about a potential simple key. 755 446 */ 756 447 757 448 typedef struct { 758 /** The string start pointer. */ 759 unsigned char *start; 760 761 /** The string end pointer. */ 762 unsigned char *end; 763 764 /** The string current position. */ 765 unsigned char *current; 766 } yaml_string_input_t; 767 768 /** 769 * This structure holds information about a potential simple key. 770 */ 771 772 typedef struct { 449 /** Is a simple key possible? */ 450 int possible; 451 773 452 /** Is a simple key required? */ 774 453 int required; … … 776 455 /** The number of the token. */ 777 456 size_t token_number; 778 779 /** The position index. */780 size_t index;781 782 /** The position line. */783 size_t line;784 785 /** The position column. */786 size_t column;787 457 788 458 /** The position mark. */ … … 794 464 */ 795 465 typedef enum { 796 YAML_PARSE_END_STATE,797 466 YAML_PARSE_STREAM_START_STATE, 798 467 YAML_PARSE_IMPLICIT_DOCUMENT_START_STATE, … … 817 486 YAML_PARSE_FLOW_MAPPING_KEY_STATE, 818 487 YAML_PARSE_FLOW_MAPPING_VALUE_STATE, 819 YAML_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE 488 YAML_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE, 489 YAML_PARSE_END_STATE 820 490 } yaml_parser_state_t; 821 491 … … 836 506 /** Error type. */ 837 507 yaml_error_type_t error; 838 839 508 /** Error description. */ 840 509 const char *problem; 841 842 510 /** The byte about which the problem occured. */ 843 511 size_t problem_offset; 844 845 512 /** The problematic value (@c -1 is none). */ 846 513 int problem_value; 847 848 514 /** The problem position. */ 849 515 yaml_mark_t problem_mark; 850 851 516 /** The error context. */ 852 517 const char *context; 853 854 518 /** The context position. */ 855 519 yaml_mark_t context_mark; … … 870 534 void *read_handler_data; 871 535 536 /** Standard (string or file) input data. */ 537 union { 538 /** String input data. */ 539 struct { 540 /** The string start pointer. */ 541 unsigned char *start; 542 /** The string end pointer. */ 543 unsigned char *end; 544 /** The string current position. */ 545 unsigned char *current; 546 } string; 547 548 /** File input data. */ 549 FILE *file; 550 } input; 551 872 552 /** EOF flag */ 873 553 int eof; 874 554 875 /** The pointer to the beginning of the working buffer. */ 876 yaml_char_t *buffer; 877 878 /** The pointer to the end of the working buffer. */ 879 yaml_char_t *buffer_end; 880 881 /** The pointer to the current character in the working buffer. */ 882 yaml_char_t *pointer; 883 884 /** The number of unread characters in the working buffer. */ 555 /** The working buffer. */ 556 struct { 557 /* The beginning of the buffer. */ 558 yaml_char_t *start; 559 /* The end of the buffer. */ 560 yaml_char_t *end; 561 /* The current position of the buffer. */ 562 yaml_char_t *pointer; 563 /* The last filled position of the buffer. */ 564 yaml_char_t *last; 565 } buffer; 566 567 /* The number of unread characters in the buffer. */ 885 568 size_t unread; 886 569 887 /** The pointer to the beginning of the raw buffer. */ 888 unsigned char *raw_buffer; 889 890 /** The pointer to the current character in the raw buffer. */ 891 unsigned char *raw_pointer; 892 893 /** The number of unread bytes in the raw buffer. */ 894 size_t raw_unread; 570 /** The raw buffer. */ 571 struct { 572 /** The beginning of the buffer. */ 573 unsigned char *start; 574 /** The end of the buffer. */ 575 unsigned char *end; 576 /** The current position of the buffer. */ 577 unsigned char *pointer; 578 /** The last filled position of the buffer. */ 579 unsigned char *last; 580 } raw_buffer; 895 581 896 582 /** The input encoding. */ … … 900 586 size_t offset; 901 587 902 /** The index of the current position (in characters). */ 903 size_t index; 904 905 /** The line of the current position (starting from @c 0). */ 906 size_t line; 907 908 /** The column of the current position (starting from @c 0). */ 909 size_t column; 910 911 /* String input structure. */ 912 yaml_string_input_t string_input; 588 /** The mark of the current position. */ 589 yaml_mark_t mark; 913 590 914 591 /** … … 930 607 int flow_level; 931 608 932 /** The tokens queue , which contains the current produced tokens. */933 yaml_token_t **tokens;934 935 /** The size of the tokens queue. */936 size_t tokens_size;937 938 /** The head of the tokens queue. */939 size_t tokens_head;940 941 /** The tail of the tokens queue. */942 size_t tokens_tail;943 944 /** The number of tokens fetched from the tokensqueue. */609 /** The tokens queue. */ 610 struct { 611 /** The beginning of the tokens queue. */ 612 yaml_token_t *start; 613 /** The end of the tokens queue. */ 614 yaml_token_t *end; 615 /** The head of the tokens queue. */ 616 yaml_token_t *head; 617 /** The tail of the tokens queue. */ 618 yaml_token_t *tail; 619 } tokens; 620 621 /** The number of tokens fetched from the queue. */ 945 622 size_t tokens_parsed; 946 623 947 /** The stack of indentation levels. */ 948 int *indents; 949 950 /** The size of the indents stack. */ 951 size_t indents_size; 952 953 /** The number of items in the indents stack. */ 954 size_t indents_length; 624 /* Does the tokens queue contain a token ready for dequeueing. */ 625 int token_available; 626 627 /** The indentation levels stack. */ 628 struct { 629 /** The beginning of the stack. */ 630 int *start; 631 /** The end of the stack. */ 632 int *end; 633 /** The top of the stack. */ 634 int *top; 635 } indents; 955 636 956 637 /** The current indentation level. */ … … 960 641 int simple_key_allowed; 961 642 962 /** The stack of potential simple keys. */ 963 yaml_simple_key_t **simple_keys; 964 965 /** The size of the simple keys stack. */ 966 size_t simple_keys_size; 643 /** The stack of simple keys. */ 644 struct { 645 /** The beginning of the stack. */ 646 yaml_simple_key_t *start; 647 /** The end of the stack. */ 648 yaml_simple_key_t *end; 649 /** The top of the stack. */ 650 yaml_simple_key_t *top; 651 } simple_keys; 967 652 968 653 /** … … 976 661 977 662 /** The parser states stack. */ 978 yaml_parser_state_t *states; 979 980 /** The size of the parser states stack. */ 981 size_t states_size; 982 983 /** The number of items in the parser states stack. */ 984 size_t states_length; 663 struct { 664 /** The beginning of the stack. */ 665 yaml_parser_state_t *start; 666 /** The end of the stack. */ 667 yaml_parser_state_t *end; 668 /** The top of the stack. */ 669 yaml_parser_state_t *top; 670 } states; 985 671 986 672 /** The current parser state. */ … … 988 674 989 675 /** The stack of marks. */ 990 yaml_mark_t *marks; 991 992 /** The size of the marks stack. */ 993 size_t marks_size; 994 995 /** The number of items in the marks stack. */ 996 size_t marks_length; 997 998 /** The current event. */ 999 yaml_event_t *current_event; 1000 1001 /** The YAML version directive. */ 1002 yaml_version_directive_t *version_directive; 676 struct { 677 /** The beginning of the stack. */ 678 yaml_mark_t *start; 679 /** The end of the stack. */ 680 yaml_mark_t *end; 681 /** The top of the stack. */ 682 yaml_mark_t *top; 683 } marks; 1003 684 1004 685 /** The list of TAG directives. */ 1005 yaml_tag_directive_t **tag_directives; 1006 1007 /** The size of the TAG directives list. */ 1008 size_t tag_directives_size; 1009 1010 /** The number of items in the TAG directives list. */ 1011 size_t tag_directives_length; 686 struct { 687 /** The beginning of the list. */ 688 yaml_tag_directive_t *start; 689 /** The end of the list. */ 690 yaml_tag_directive_t *end; 691 /** The top of the list. */ 692 yaml_tag_directive_t *top; 693 } tag_directives; 1012 694 1013 695 /** … … 1018 700 1019 701 /** 1020 * Create a newparser.702 * Initialize a parser. 1021 703 * 1022 704 * This function creates a new parser object. An application is responsible 1023 705 * for destroying the object using the @c yaml_parser_delete function. 1024 706 * 1025 * @returns A new parser object; @c NULL on error. 1026 */ 1027 1028 YAML_DECLARE(yaml_parser_t *) 1029 yaml_parser_new(void); 707 * @param[in] parser An empty parser object. 708 * 709 * @returns #c 1 if the function succeeded, @c 0 on error. 710 */ 711 712 YAML_DECLARE(int) 713 yaml_parser_initialize(yaml_parser_t *parser); 1030 714 1031 715 /** … … 1091 775 1092 776 /** 1093 * Get the next token. 1094 * 1095 * The token is removed from the internal token queue and the application is 1096 * responsible for destroing the token object. 777 * Scan the input stream and produce the next token. 778 * 779 * Call the function subsequently to produce a sequence of tokens corresponding 780 * to the input stream. The initial token has the type 781 * @c YAML_STREAM_START_TOKEN while the ending token has the type 782 * @c YAML_STREAM_END_TOKEN. 783 * 784 * An application is responsible for freeing any buffers associated with the 785 * produced token object using the @c yaml_token_delete function. 786 * 787 * An application must not alternate the calls of @c yaml_parser_scan with the 788 * calls of @c yaml_parser_parse. Doing this will break the parser. 1097 789 * 1098 790 * @param[in] parser A parser object. 1099 * 1100 * @returns A token object, or @c NULL on error. 1101 */ 1102 1103 YAML_DECLARE(yaml_token_t *) 1104 yaml_parser_get_token(yaml_parser_t *parser); 1105 1106 /** 1107 * Peek the next token. 1108 * 1109 * The token is not removed from the internal token queue and will be returned 1110 * again on a subsequent call of @c yaml_parser_get_token or 1111 * @c yaml_parser_peek_token. The application should not destroy the token 1112 * object. 791 * @param[in] token An empty token object. 792 * 793 * @returns @c 1 if the function succeeded, @c 0 on error. 794 */ 795 796 YAML_DECLARE(int) 797 yaml_parser_scan(yaml_parser_t *parser, yaml_token_t *token); 798 799 /** 800 * Parse the input stream and produce the next parsing event. 801 * 802 * Call the function subsequently to produce a sequence of events corresponding 803 * to the input stream. The initial event has the type 804 * @c YAML_STREAM_START_EVENT while the ending event has the type 805 * @c YAML_STREAM_END_EVENT. 806 * 807 * An application is responsible for freeing any buffers associated with the 808 * produced event object using the @c yaml_event_delete function. 809 * 810 * An application must not alternate the calls of @c yaml_parser_scan with the 811 * calls of @c yaml_parser_parse. Doing this will break the parser. 1113 812 * 1114 813 * @param[in] parser A parser object. 1115 * 1116 * @returns A token object, or @c NULL on error. 1117 */ 1118 1119 YAML_DECLARE(yaml_token_t *) 1120 yaml_parser_peek_token(yaml_parser_t *parser); 1121 1122 /** 1123 * Get the next event. 1124 * 1125 * The application is responsible for destroing the event object. 1126 * 1127 * @param[in] parser A parser object. 1128 * 1129 * @returns An event object, or @c NULL on error. 1130 */ 1131 1132 YAML_DECLARE(yaml_event_t *) 1133 yaml_parser_get_event(yaml_parser_t *parser); 1134 1135 /** 1136 * Peek the next event. 1137 * 1138 * The event will be returned again on a subsequent call of 1139 * @c yaml_parser_get_event or @c yaml_parser_peek_event. The application 1140 * should not destroy the event object. 1141 * 1142 * @param[in] parser A parser object. 1143 * 1144 * @returns An event object, or @c NULL on error. 1145 */ 1146 1147 YAML_DECLARE(yaml_event_t *) 1148 yaml_parser_peek_event(yaml_parser_t *parser); 814 * @param[in] event An empty event object. 815 * 816 * @returns @c 1 if the function succeeded, @c 0 on error. 817 */ 818 819 YAML_DECLARE(int) 820 yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event); 1149 821 1150 822 /** @} */ … … 1153 825 typedef struct { 1154 826 } yaml_emitter_t; 827 828 YAML_DECLARE(int) 829 yaml_emitter_emit(yaml_emitter_t *emitter, yaml_event_t *event); 830 831 YAML_DECLARE(int) 832 yaml_emitter_emit_stream_start(yaml_emitter_t *emitter, 833 yaml_encoding_t encoding); 834 1155 835 */ 1156 1157 /**1158 * @defgroup internal Internal Definitions1159 * @{1160 */1161 1162 /**1163 * Allocate a dynamic memory block.1164 *1165 * @param[in] size Size of a memory block, \c 0 is valid.1166 *1167 * @returns @c yaml_malloc returns a pointer to a newly allocated memory block,1168 * or @c NULL if it failed.1169 */1170 1171 YAML_DECLARE(void *)1172 yaml_malloc(size_t size);1173 1174 /**1175 * Reallocate a dynamic memory block.1176 *1177 * @param[in] ptr A pointer to an existing memory block, \c NULL is1178 * valid.1179 * @param[in] size A size of a new block, \c 0 is valid.1180 *1181 * @returns @c yaml_realloc returns a pointer to a reallocated memory block,1182 * or @c NULL if it failed.1183 */1184 1185 YAML_DECLARE(void *)1186 yaml_realloc(void *ptr, size_t size);1187 1188 /**1189 * Free a dynamic memory block.1190 *1191 * @param[in] ptr A pointer to an existing memory block, \c NULL is1192 * valid.1193 */1194 1195 YAML_DECLARE(void)1196 yaml_free(void *ptr);1197 1198 /** The initial size for various buffers. */1199 1200 #define YAML_DEFAULT_SIZE 161201 1202 /** The size of the raw buffer. */1203 1204 #define YAML_RAW_BUFFER_SIZE 163841205 1206 /**1207 * The size of the buffer.1208 *1209 * We allocate enough space for decoding the whole raw buffer.1210 */1211 1212 #define YAML_BUFFER_SIZE (YAML_RAW_BUFFER_SIZE*3)1213 1214 /**1215 * Ensure that the buffer contains at least @a length characters.1216 *1217 * @param[in] parser A parser object.1218 * @param[in] length The number of characters in the buffer.1219 *1220 * @returns @c 1 on success, @c 0 on error.1221 */1222 1223 YAML_DECLARE(int)1224 yaml_parser_update_buffer(yaml_parser_t *parser, size_t length);1225 1226 /** @} */1227 1228 836 1229 837 #ifdef __cplusplus
Note: See TracChangeset
for help on using the changeset viewer.
