Changeset 238 for libyaml/trunk/include/yaml.h
- Timestamp:
- 01/07/07 15:11:16 (6 years ago)
- File:
-
- 1 edited
-
libyaml/trunk/include/yaml.h (modified) (46 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libyaml/trunk/include/yaml.h
r237 r238 60 60 * Get the library version numbers. 61 61 * 62 * @param[out] major Major version number.63 * @param[out] minor Minor version number.64 * @param[out] patch Patch version number.62 * @param[out] major Major version number. 63 * @param[out] minor Minor version number. 64 * @param[out] patch Patch version number. 65 65 */ 66 66 … … 79 79 80 80 /** The version directive data. */ 81 typedef struct {81 typedef struct yaml_version_directive_s { 82 82 /** The major version number. */ 83 83 int major; … … 87 87 88 88 /** The tag directive data. */ 89 typedef struct {89 typedef struct yaml_tag_directive_s { 90 90 /** The tag handle. */ 91 91 yaml_char_t *handle; … … 95 95 96 96 /** The stream encoding. */ 97 typedef enum {97 typedef enum yaml_encoding_e { 98 98 YAML_ANY_ENCODING, 99 99 YAML_UTF8_ENCODING, … … 104 104 /** Line break types. */ 105 105 106 typedef enum {106 typedef enum yaml_break_e { 107 107 YAML_ANY_BREAK, 108 108 YAML_CR_BREAK, … … 112 112 113 113 /** Many bad things could happen with the parser and emitter. */ 114 typedef enum {114 typedef enum yaml_error_type_e { 115 115 YAML_NO_ERROR, 116 116 … … 120 120 YAML_SCANNER_ERROR, 121 121 YAML_PARSER_ERROR, 122 YAML_COMPOSER_ERROR, 122 123 123 124 YAML_WRITER_ERROR, … … 126 127 127 128 /** The pointer position. */ 128 typedef struct {129 typedef struct yaml_mark_s { 129 130 /** The position index. */ 130 131 size_t index; … … 145 146 146 147 /** Scalar styles. */ 147 typedef enum {148 typedef enum yaml_scalar_style_e { 148 149 YAML_ANY_SCALAR_STYLE, 149 150 … … 158 159 159 160 /** Sequence styles. */ 160 typedef enum {161 typedef enum yaml_sequence_style_e { 161 162 YAML_ANY_SEQUENCE_STYLE, 162 163 … … 166 167 167 168 /** Mapping styles. */ 168 typedef enum {169 typedef enum yaml_mapping_style_e { 169 170 YAML_ANY_MAPPING_STYLE, 170 171 … … 182 183 183 184 /** Token types. */ 184 typedef enum {185 typedef enum yaml_token_type_e { 185 186 YAML_NO_TOKEN, 186 187 … … 214 215 215 216 /** The token structure. */ 216 typedef struct {217 typedef struct yaml_token_s { 217 218 218 219 /** The token type. */ … … 300 301 301 302 /** Event types. */ 302 typedef enum {303 typedef enum yaml_event_type_e { 303 304 YAML_NO_EVENT, 304 305 … … 320 321 321 322 /** The event structure. */ 322 typedef struct {323 typedef struct yaml_event_s { 323 324 324 325 /** The event type. */ … … 417 418 * Create the STREAM-START event. 418 419 * 419 * @param[out] event An empty event object.420 * @param[in] encoding The stream encoding.420 * @param[out] event An empty event object. 421 * @param[in] encoding The stream encoding. 421 422 * 422 423 * @returns @c 1 if the function succeeded, @c 0 on error. … … 430 431 * Create the STREAM-END event. 431 432 * 432 * @param[out] event An empty event object.433 * @param[out] event An empty event object. 433 434 * 434 435 * @returns @c 1 if the function succeeded, @c 0 on error. … … 444 445 * ignored by the emitter. 445 446 * 446 * @param[out] event An empty event object. 447 * @param[in] version_directive The %YAML directive value or @c NULL. 448 * @param[in] tag_directives_start The beginning of the %TAG directives list. 449 * @param[in] tag_directives_end The end of the %TAG directives list. 450 * @param[in] implicit If the document start indicator is implicit. 447 * @param[out] event An empty event object. 448 * @param[in] version_directive The %YAML directive value or 449 * @c NULL. 450 * @param[in] tag_directives_start The beginning of the %TAG 451 * directives list. 452 * @param[in] tag_directives_end The end of the %TAG directives 453 * list. 454 * @param[in] implicit If the document start indicator is 455 * implicit. 451 456 * 452 457 * @returns @c 1 if the function succeeded, @c 0 on error. … … 466 471 * ignored by the emitter. 467 472 * 468 * @param[out] event An empty event object.469 * @param[in] implicit If the document end indicator is implicit.473 * @param[out] event An empty event object. 474 * @param[in] implicit If the document end indicator is implicit. 470 475 * 471 476 * @returns @c 1 if the function succeeded, @c 0 on error. … … 478 483 * Create an ALIAS event. 479 484 * 480 * @param[out] event An empty event object.481 * @param[in] anchor The anchor value.485 * @param[out] event An empty event object. 486 * @param[in] anchor The anchor value. 482 487 * 483 488 * @returns @c 1 if the function succeeded, @c 0 on error. … … 495 500 * @a quoted_implicit flags must be set. 496 501 * 497 * @param[out] event An empty event object. 498 * @param[in] anchor The scalar anchor or @c NULL. 499 * @param[in] tag The scalar tag or @c NULL. 500 * @param[in] value The scalar value. 501 * @param[in] length The length of the scalar value. 502 * @param[in] plain_implicit If the tag may be omitted for the plain style. 503 * @param[in] quoted_implicit If the tag may be omitted for any non-plain style. 504 * @param[in] style The scalar style. 502 * @param[out] event An empty event object. 503 * @param[in] anchor The scalar anchor or @c NULL. 504 * @param[in] tag The scalar tag or @c NULL. 505 * @param[in] value The scalar value. 506 * @param[in] length The length of the scalar value. 507 * @param[in] plain_implicit If the tag may be omitted for the plain 508 * style. 509 * @param[in] quoted_implicit If the tag may be omitted for any 510 * non-plain style. 511 * @param[in] style The scalar style. 505 512 * 506 513 * @returns @c 1 if the function succeeded, @c 0 on error. … … 521 528 * Either the @a tag attribute or the @a implicit flag must be set. 522 529 * 523 * @param[out] event An empty event object.524 * @param[in] anchor The sequence anchor or @c NULL.525 * @param[in] tag The sequence tag or @c NULL.526 * @param[in] implicit If the tag may be omitted.527 * @param[in] style The sequence style.530 * @param[out] event An empty event object. 531 * @param[in] anchor The sequence anchor or @c NULL. 532 * @param[in] tag The sequence tag or @c NULL. 533 * @param[in] implicit If the tag may be omitted. 534 * @param[in] style The sequence style. 528 535 * 529 536 * @returns @c 1 if the function succeeded, @c 0 on error. … … 538 545 * Create a SEQUENCE-END event. 539 546 * 540 * @param[out] event An empty event object.547 * @param[out] event An empty event object. 541 548 * 542 549 * @returns @c 1 if the function succeeded, @c 0 on error. … … 553 560 * Either the @a tag attribute or the @a implicit flag must be set. 554 561 * 555 * @param[out] event An empty event object.556 * @param[in] anchor The mapping anchor or @c NULL.557 * @param[in] tag The mapping tag or @c NULL.558 * @param[in] implicit If the tag may be omitted.559 * @param[in] style The mapping style.562 * @param[out] event An empty event object. 563 * @param[in] anchor The mapping anchor or @c NULL. 564 * @param[in] tag The mapping tag or @c NULL. 565 * @param[in] implicit If the tag may be omitted. 566 * @param[in] style The mapping style. 560 567 * 561 568 * @returns @c 1 if the function succeeded, @c 0 on error. … … 570 577 * Create a MAPPING-END event. 571 578 * 572 * @param[out] event An empty event object.579 * @param[out] event An empty event object. 573 580 * 574 581 * @returns @c 1 if the function succeeded, @c 0 on error. … … 581 588 * Free any memory allocated for an event object. 582 589 * 583 * @param[ out]event An event object.590 * @param[in,out] event An event object. 584 591 */ 585 592 … … 604 611 #define YAML_DEFAULT_SCALAR_TAG YAML_STR_TAG 605 612 #define YAML_DEFAULT_SEQUENCE_TAG YAML_SEQ_TAG 606 #define YAML_DEFAULT_MAPPING_ STYLEYAML_MAP_TAG613 #define YAML_DEFAULT_MAPPING_TAG YAML_MAP_TAG 607 614 608 615 /** Node types. */ 609 typedef enum {616 typedef enum yaml_node_type_e { 610 617 YAML_NO_NODE, 611 618 … … 615 622 } yaml_node_type_t; 616 623 617 #if 0 618 619 typedef struct _yaml_node_t yaml_node_item_t; 620 621 typedef struct { 622 yaml_node_item_t key; 623 yaml_node_item_t value; 624 /** The forward definition of a document node structure. */ 625 typedef struct yaml_node_s yaml_node_t; 626 627 /** An element of a sequence node. */ 628 typedef int yaml_node_item_t; 629 630 /** An element of a mapping node. */ 631 typedef struct yaml_node_pair_s { 632 /** The key of the element. */ 633 int key; 634 /** The value of the element. */ 635 int value; 624 636 } yaml_node_pair_t; 625 637 626 638 /** The node structure. */ 627 typedef struct _yaml_node_t{639 struct yaml_node_s { 628 640 629 641 /** The node type. */ 630 642 yaml_node_type_t type; 631 643 632 /* The reference counter. */633 int references;644 /** The node tag. */ 645 yaml_char_t *tag; 634 646 635 647 /** The node data. */ … … 638 650 /** The scalar parameters (for @c YAML_SCALAR_NODE). */ 639 651 struct { 640 /** The tag. */641 yaml_char_t *tag;642 652 /** The scalar value. */ 643 653 yaml_char_t *value; … … 650 660 /** The sequence parameters (for @c YAML_SEQUENCE_NODE). */ 651 661 struct { 652 /** The tag. */653 yaml_char_t *tag;654 662 /** The stack of sequence items. */ 655 663 struct { 656 664 /** The beginning of the stack. */ 657 structyaml_node_item_t *start;665 yaml_node_item_t *start; 658 666 /** The end of the stack. */ 659 structyaml_node_item_t *end;667 yaml_node_item_t *end; 660 668 /** The top of the stack. */ 661 structyaml_node_item_t *top;669 yaml_node_item_t *top; 662 670 } items; 663 671 /** The sequence style. */ … … 667 675 /** The mapping parameters (for @c YAML_MAPPING_NODE). */ 668 676 struct { 669 /** The tag. */ 670 yaml_char_t *tag; 671 /** The stack of mapping pairs. */ 677 /** The stack of mapping pairs (key, value). */ 672 678 struct { 673 679 /** The beginning of the stack. */ 674 structyaml_node_pair_t *start;680 yaml_node_pair_t *start; 675 681 /** The end of the stack. */ 676 structyaml_node_pair_t *end;682 yaml_node_pair_t *end; 677 683 /** The top of the stack. */ 678 structyaml_node_pair_t *top;684 yaml_node_pair_t *top; 679 685 } pairs; 680 686 /** The mapping style. */ … … 689 695 yaml_mark_t end_mark; 690 696 691 } yaml_node_t; 692 693 /** 694 * Create a SCALAR node. 697 }; 698 699 /** The document structure. */ 700 typedef struct yaml_document_s { 701 702 /** The document nodes. */ 703 struct { 704 /** The beginning of the stack. */ 705 yaml_node_t *start; 706 /** The end of the stack. */ 707 yaml_node_t *end; 708 /** The top of the stack. */ 709 yaml_node_t *top; 710 } nodes; 711 712 /** The version directive. */ 713 yaml_version_directive_t *version_directive; 714 715 /** The list of tag directives. */ 716 struct { 717 /** The beginning of the tag directives list. */ 718 yaml_tag_directive_t *start; 719 /** The end of the tag directives list. */ 720 yaml_tag_directive_t *end; 721 } tag_directives; 722 723 /** Is the document start indicator implicit? */ 724 int start_implicit; 725 /** Is the document end indicator implicit? */ 726 int end_implicit; 727 728 /** The beginning of the document. */ 729 yaml_mark_t start_mark; 730 /** The end of the document. */ 731 yaml_mark_t end_mark; 732 733 } yaml_document_t; 734 735 /** 736 * Create a YAML document. 737 * 738 * @param[out] document An empty document object. 739 * @param[in] version_directive The %YAML directive value or 740 * @c NULL. 741 * @param[in] tag_directives_start The beginning of the %TAG 742 * directives list. 743 * @param[in] tag_directives_end The end of the %TAG directives 744 * list. 745 * @param[in] start_implicit If the document start indicator is 746 * implicit. 747 * @param[in] end_implicit If the document end indicator is 748 * implicit. 749 * 750 * @returns @c 1 if the function succeeded, @c 0 on error. 751 */ 752 753 YAML_DECLARE(int) 754 yaml_document_initialize(yaml_document_t *document, 755 yaml_version_directive_t *version_directive, 756 yaml_tag_directive_t *tag_directives_start, 757 yaml_tag_directive_t *tag_directives_end, 758 int start_implicit, int end_implicit); 759 760 /** 761 * Delete a YAML document and all its nodes. 762 * 763 * @param[in,out] document A document object. 764 */ 765 766 YAML_DECLARE(void) 767 yaml_document_delete(yaml_document_t *document); 768 769 /** 770 * Get a node of a YAML document. 771 * 772 * The pointer returned by this function is valid until any of the functions 773 * modifying the documents are called. 774 * 775 * @param[in] document A document object. 776 * @param[in] node The node id. 777 * 778 * @returns the node objct or @c NULL if @c node_id is out of range. 779 */ 780 781 YAML_DECLARE(yaml_node_t *) 782 yaml_document_get_node(yaml_document_t *document, int node_id); 783 784 /** 785 * Get the root of a YAML document node. 786 * 787 * The root object is the first object added to the document. 788 * 789 * The pointer returned by this function is valid until any of the functions 790 * modifying the documents are called. 791 * 792 * An empty document produced by the parser signifies the end of a YAML 793 * stream. 794 * 795 * @param[in] document A document object. 796 * 797 * @returns the node object or @c NULL if the document is empty. 798 */ 799 800 YAML_DECLARE(yaml_node_t *) 801 yaml_document_get_root_node(yaml_document_t *document); 802 803 /** 804 * Create a SCALAR node and attach it to the document. 695 805 * 696 806 * The @a style argument may be ignored by the emitter. 697 807 * 698 * @param[ out] node An empty nodeobject.699 * @param[in] tag The scalar tag.700 * @param[in] value The scalar value.701 * @param[in] length The length of the scalar value.702 * @param[in] style The scalar style.703 * 704 * @returns @c 1 if the function succeeded,@c 0 on error.705 */ 706 707 YAML_DECLARE(int) 708 yaml_ scalar_node_initialize(yaml_node_t *node,808 * @param[in,out] document A document object. 809 * @param[in] tag The scalar tag. 810 * @param[in] value The scalar value. 811 * @param[in] length The length of the scalar value. 812 * @param[in] style The scalar style. 813 * 814 * @returns the node id or @c 0 on error. 815 */ 816 817 YAML_DECLARE(int) 818 yaml_document_add_scalar(yaml_document_t *document, 709 819 yaml_char_t *tag, yaml_char_t *value, int length, 710 820 yaml_scalar_style_t style); 711 821 712 822 /** 713 * Create a SEQUENCE node .823 * Create a SEQUENCE node and attach it to the document. 714 824 * 715 825 * The @a style argument may be ignored by the emitter. 716 826 * 717 * @param[ out] node An empty nodeobject.718 * @param[in] tag The sequence tag.719 * @param[in] style The sequence style.720 * 721 * @returns @c 1 if the function succeeded,@c 0 on error.722 */ 723 724 YAML_DECLARE(int) 725 yaml_ sequence_node_initialize(yaml_node_t *node,827 * @param[in,out] document A document object. 828 * @param[in] tag The sequence tag. 829 * @param[in] style The sequence style. 830 * 831 * @returns the node id or @c 0 on error. 832 */ 833 834 YAML_DECLARE(int) 835 yaml_document_add_sequence(yaml_document_t *document, 726 836 yaml_char_t *tag, yaml_sequence_style_t style); 727 837 728 838 /** 729 * Add an item to a SEQUENCE node 730 * 731 * @param[out] node A sequence node. 732 * @param[in] item An item node. 839 * Create a MAPPING node and attach it to the document. 840 * 841 * The @a style argument may be ignored by the emitter. 842 * 843 * @param[in,out] document A document object. 844 * @param[in] tag The sequence tag. 845 * @param[in] style The sequence style. 846 * 847 * @returns the node id or @c 0 on error. 848 */ 849 850 YAML_DECLARE(int) 851 yaml_document_add_mapping(yaml_document_t *document, 852 yaml_char_t *tag, yaml_mapping_style_t style); 853 854 /** 855 * Add an item to a SEQUENCE node. 856 * 857 * @param[in,out] document A document object. 858 * @param[in] sequence The sequence node id. 859 * @param[in] item The item node id. 733 860 * 734 861 * @returns @c 1 if the function succeeded, @c 0 on error. … … 736 863 737 864 YAML_DECLARE(int) 738 yaml_sequence_node_add_item(yaml_node_t *node, yaml_node_t *item) 739 740 /** 741 * Create a SCALAR node and add it to a SEQUENCE node. 742 * 743 * @param[out] node A sequence node. 744 * @param[in] tag The scalar tag. 745 * @param[in] value The scalar value. 746 * @param[in] length The length of the scalar value. 747 * @param[in] style The scalar style. 748 * 749 * @returns @c 1 if the function succeeded, @c 0 on error. 750 */ 751 752 YAML_DECLARE(int) 753 yaml_sequence_node_add_scalar_item(yaml_node_t *node, 754 yaml_char_t *tag, yaml_char_t *value, int length, 755 yaml_scalar_style_t style); 756 757 /** 758 * Get the number of subnodes of a SEQUENCE node. 759 * 760 * @param[in] node A sequence node. 761 * 762 * @returns the number of subnodes. 763 */ 764 765 YAML_DECLARE(size_t) 766 yaml_sequence_node_get_length(yaml_node_t *node); 767 768 /** 769 * Get a subnode of a SEQUENCE node. 770 * 771 * @param[in] node A sequence node. 772 * @param[in] index The index of a subnode. 773 * @param[out] item A subnode. 774 */ 775 776 YAML_DECLARE(void) 777 yaml_sequence_node_get_item(yaml_node_t *node, size_t index, 778 yaml_node_t *item); 779 780 /** 781 * Create a MAPPING node. 782 * 783 * The @a style argument may be ignored by the emitter. 784 * 785 * @param[out] node An empty node object. 786 * @param[in] tag The mapping tag. 787 * @param[in] style The mapping style. 788 * 789 * @returns @c 1 if the function succeeded, @c 0 on error. 790 */ 791 792 YAML_DECLARE(int) 793 yaml_mapping_node_initialize(yaml_node_t *node, 794 yaml_char_t *tag, yaml_mapping_style_t style); 795 796 /** 797 * Add a key/value pair of nodes to a MAPPING node. 798 * 799 * @param[out] node A mapping node. 800 * @param[in] key A key node. 801 * @param[in] value A value node. 802 * 803 * @returns @c 1 if the function succeeded, @c 0 on error. 804 */ 805 806 YAML_DECLARE(int) 807 yaml_mapping_node_add_pair(yaml_node_t *node, 808 yaml_node_t *key, yaml_node_t *value) 809 810 /** 811 * Create a scalar key and add the key/value pair to a MAPPING node. 812 * 813 * @param[out] node A mapping node. 814 * @param[in] key_tag The key node tag. 815 * @param[in] key_value The key node value. 816 * @param[in] key_length The length of the key node value. 817 * @param[in] key_style The key node style. 818 * @param[in] value A value node. 819 * 820 * @returns @c 1 if the function succeeded, @c 0 on error. 821 */ 822 823 YAML_DECLARE(int) 824 yaml_sequence_node_add_scalar_key_pair(yaml_node_t *node, 825 yaml_char_t *key_tag, yaml_char_t *key_value, int key_length, 826 yaml_scalar_style_t key_style, 827 yaml_node_t *value); 828 829 /** 830 * Create a scalar key/value nodes and add the pair to a MAPPING node. 831 * 832 * @param[out] node A mapping node. 833 * @param[in] key_tag The key node tag. 834 * @param[in] key_value The key node value. 835 * @param[in] key_length The length of the key node value. 836 * @param[in] key_style The key node style. 837 * @param[in] value_tag The value node tag. 838 * @param[in] value_value The value node value. 839 * @param[in] value_length The length of the value node value. 840 * @param[in] value_style The value node style. 841 * 842 * @returns @c 1 if the function succeeded, @c 0 on error. 843 */ 844 845 YAML_DECLARE(int) 846 yaml_sequence_node_add_scalar_pair(yaml_node_t *node, 847 yaml_char_t *key_tag, yaml_char_t *key_value, int key_length, 848 yaml_scalar_style_t key_style, 849 yaml_char_t *value_tag, yaml_char_t *value_value, int value_length, 850 yaml_scalar_style_t value_style); 851 852 /** 853 * Get the number of subnode pairs of a MAPPING node. 854 * 855 * @param[in] node A mapping node. 856 * 857 * @returns the number of pairs. 858 */ 859 860 YAML_DECLARE(size_t) 861 yaml_mapping_node_get_length(yaml_node_t *node); 862 863 /** 864 * Get a subnode of a SEQUENCE node. 865 * 866 * @param[in] node A sequence node. 867 * @param[in] index The index of a subnode. 868 * @param[out] key The key subnode. 869 * @param[out] value The value subnode. 870 */ 871 872 YAML_DECLARE(void) 873 yaml_mapping_node_get_pair(yaml_node_t *node, size_t index, 874 yaml_node_t *key, yaml_node_t *value); 875 876 /** 877 * Delete a node and its subnodes. 878 * 879 * @param[out] node A node object. 880 */ 881 882 YAML_DECLARE(void) 883 yaml_node_delete(yaml_node_t *node); 884 885 #endif 865 yaml_document_append_sequence_item(yaml_document_t *document, 866 int sequence, int item); 867 868 /** 869 * Add a pair of a key and a value to a MAPPING node. 870 * 871 * @param[in,out] document A document object. 872 * @param[in] mapping The mapping node id. 873 * @param[in] key The key node id. 874 * @param[in] value The value node id. 875 * 876 * @returns @c 1 if the function succeeded, @c 0 on error. 877 */ 878 879 YAML_DECLARE(int) 880 yaml_document_append_mapping_pair(yaml_document_t *document, 881 int mapping, int key, int value); 886 882 887 883 /** @} */ … … 917 913 */ 918 914 919 typedef struct {915 typedef struct yaml_simple_key_s { 920 916 /** Is a simple key possible? */ 921 917 int possible; … … 934 930 * The states of the parser. 935 931 */ 936 typedef enum {932 typedef enum yaml_parser_state_e { 937 933 YAML_PARSE_STREAM_START_STATE, 938 934 YAML_PARSE_IMPLICIT_DOCUMENT_START_STATE, … … 962 958 963 959 /** 960 * This structure holds aliases data. 961 */ 962 963 typedef struct yaml_alias_data_s { 964 /** The anchor. */ 965 yaml_char_t *anchor; 966 /** The node id. */ 967 int index; 968 /** The anchor mark. */ 969 yaml_mark_t mark; 970 } yaml_alias_data_t; 971 972 /** 964 973 * The parser structure. 965 974 * … … 968 977 */ 969 978 970 typedef struct {979 typedef struct yaml_parser_s { 971 980 972 981 /** … … 1168 1177 */ 1169 1178 1179 /** 1180 * @name Dumper stuff 1181 * @{ 1182 */ 1183 1184 /** The alias data. */ 1185 struct { 1186 /** The beginning of the list. */ 1187 yaml_alias_data_t *start; 1188 /** The end of the list. */ 1189 yaml_alias_data_t *end; 1190 /** The top of the list. */ 1191 yaml_alias_data_t *top; 1192 } aliases; 1193 1194 /** The currently parsed document. */ 1195 yaml_document_t *document; 1196 1197 /** 1198 * @} 1199 */ 1200 1170 1201 } yaml_parser_t; 1171 1202 … … 1176 1207 * for destroying the object using the yaml_parser_delete() function. 1177 1208 * 1178 * @param[out] parser An empty parser object.1209 * @param[out] parser An empty parser object. 1179 1210 * 1180 1211 * @returns @c 1 if the function succeeded, @c 0 on error. … … 1257 1288 * 1258 1289 * An application must not alternate the calls of yaml_parser_scan() with the 1259 * calls of yaml_parser_parse(). Doing this will break the parser. 1290 * calls of yaml_parser_parse() or yaml_parser_load(). Doing this will break 1291 * the parser. 1260 1292 * 1261 1293 * @param[in,out] parser A parser object. … … 1279 1311 * produced event object using the yaml_event_delete() function. 1280 1312 * 1281 * An application must not alternate the calls of yaml_parser_scan() with the 1282 * calls of yaml_parser_parse(). Doing this will break the parser. 1313 * An application must not alternate the calls of yaml_parser_parse() with the 1314 * calls of yaml_parser_scan() or yaml_parser_load(). Doing this will break the 1315 * parser. 1283 1316 * 1284 1317 * @param[in,out] parser A parser object. … … 1290 1323 YAML_DECLARE(int) 1291 1324 yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event); 1325 1326 /** 1327 * Parse the input stream and produce the next YAML document. 1328 * 1329 * Call this function subsequently to produce a sequence of documents 1330 * constituting the input stream. 1331 * 1332 * If the produced document has no root node, it means that the document 1333 * end has been reached. 1334 * 1335 * An application is responsible for freeing any data associated with the 1336 * produced document object using the yaml_document_delete() function. 1337 * 1338 * An application must not alternate the calls of yaml_parser_load() with the 1339 * calls of yaml_parser_scan() or yaml_parser_parse(). Doing this will break 1340 * the parser. 1341 * 1342 * @param[in,out] parser A parser object. 1343 * @param[out] document An empty document object. 1344 * 1345 * @return @c 1 if the function succeeded, @c 0 on error. 1346 */ 1347 1348 YAML_DECLARE(int) 1349 yaml_parser_load(yaml_parser_t *parser, yaml_document_t *document); 1292 1350 1293 1351 /** @} */ … … 1317 1375 1318 1376 /** The emitter states. */ 1319 typedef enum {1377 typedef enum yaml_emitter_state_e { 1320 1378 YAML_EMIT_STREAM_START_STATE, 1321 1379 YAML_EMIT_FIRST_DOCUMENT_START_STATE, … … 1345 1403 */ 1346 1404 1347 typedef struct {1405 typedef struct yaml_emitter_s { 1348 1406 1349 1407 /** … … 1550 1608 */ 1551 1609 1610 /** 1611 * @name Dumper stuff 1612 * @{ 1613 */ 1614 1615 /** If the stream was already opened? */ 1616 int opened; 1617 /** If the stream was already closed? */ 1618 int closed; 1619 1620 /** The information associated with the document nodes. */ 1621 struct { 1622 /** The number of references. */ 1623 int references; 1624 /** The anchor id. */ 1625 int anchor; 1626 /** If the node has been emitted? */ 1627 int serialized; 1628 } *anchors; 1629 1630 /** The last assigned anchor id. */ 1631 int last_anchor_id; 1632 1633 /** The currently emitted document. */ 1634 yaml_document_t *document; 1635 1636 /** 1637 * @} 1638 */ 1639 1552 1640 } yaml_emitter_t; 1553 1641 … … 1698 1786 yaml_emitter_emit(yaml_emitter_t *emitter, yaml_event_t *event); 1699 1787 1788 /* 1789 * Start a YAML stream. 1790 * 1791 * This function should be used before yaml_emitter_dump() is called. 1792 * 1793 * @param[in,out] emitter An emitter object. 1794 * 1795 * @returns @c 1 if the function succeeded, @c 0 on error. 1796 */ 1797 1798 YAML_DECLARE(int) 1799 yaml_emitter_open(yaml_emitter_t *emitter); 1800 1801 /* 1802 * Finish a YAML stream. 1803 * 1804 * This function should be used after yaml_emitter_dump() is called. 1805 * 1806 * @param[in,out] emitter An emitter object. 1807 * 1808 * @returns @c 1 if the function succeeded, @c 0 on error. 1809 */ 1810 1811 YAML_DECLARE(int) 1812 yaml_emitter_close(yaml_emitter_t *emitter); 1813 1814 /* 1815 * Emit a YAML document. 1816 * 1817 * The documen object may be generated using the yaml_parser_load() function 1818 * or the yaml_document_initialize() function. The emitter takes the 1819 * responsibility for the document object and destoys its content after 1820 * it is emitted. The document object is destroyedeven if the function fails. 1821 * 1822 * @param[in,out] emitter An emitter object. 1823 * @param[in,out] document A document object. 1824 * 1825 * @returns @c 1 if the function succeeded, @c 0 on error. 1826 */ 1827 1828 YAML_DECLARE(int) 1829 yaml_emitter_dump(yaml_emitter_t *emitter, yaml_document_t *document); 1830 1700 1831 /** 1701 1832 * Flush the accumulated characters to the output.
Note: See TracChangeset
for help on using the changeset viewer.
