3 * @brief Public interface for libyaml.
5 * Include the header file with the code:
7 * #include <yaml/yaml.h>
23 * @defgroup export Export Definitions
27 /** The public API declaration. */
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
35 # define YAML_DECLARE(type) __declspec(dllimport) type
38 # define YAML_DECLARE(type) type
44 * @defgroup version Version Information
49 * Get the library version as a string.
51 * @returns The function returns the pointer to a static string of the form
52 * @c "X.Y.Z", where @c X is the major version number, @c Y is a minor version
53 * number, and @c Z is the patch version number.
56 YAML_DECLARE(const char *)
57 yaml_get_version_string(void);
60 * Get the library version numbers.
62 * @param[out] major Major version number.
63 * @param[out] minor Minor version number.
64 * @param[out] patch Patch version number.
68 yaml_get_version(int *major, int *minor, int *patch);
73 * @defgroup basic Basic Types
77 /** The character type (UTF-8 octet). */
78 typedef unsigned char yaml_char_t;
80 /** The version directive data. */
82 /** The major version number. */
84 /** The minor version number. */
86 } yaml_version_directive_t;
88 /** The tag directive data. */
90 /** The tag handle. */
92 /** The tag prefix. */
94 } yaml_tag_directive_t;
96 /** The stream encoding. */
100 YAML_UTF16LE_ENCODING,
101 YAML_UTF16BE_ENCODING
104 /** Line break types. */
113 /** Many bad things could happen with the parser and emitter. */
127 /** The pointer position. */
129 /** The position index. */
132 /** The position line. */
135 /** The position column. */
142 * @defgroup styles Node Styles
146 /** Scalar styles. */
148 YAML_ANY_SCALAR_STYLE,
150 YAML_PLAIN_SCALAR_STYLE,
152 YAML_SINGLE_QUOTED_SCALAR_STYLE,
153 YAML_DOUBLE_QUOTED_SCALAR_STYLE,
155 YAML_LITERAL_SCALAR_STYLE,
156 YAML_FOLDED_SCALAR_STYLE
157 } yaml_scalar_style_t;
159 /** Sequence styles. */
161 YAML_ANY_SEQUENCE_STYLE,
163 YAML_BLOCK_SEQUENCE_STYLE,
164 YAML_FLOW_SEQUENCE_STYLE
165 } yaml_sequence_style_t;
167 /** Mapping styles. */
169 YAML_ANY_MAPPING_STYLE,
171 YAML_BLOCK_MAPPING_STYLE,
172 YAML_FLOW_MAPPING_STYLE,
173 YAML_FLOW_SET_MAPPING_STYLE
174 } yaml_mapping_style_t;
179 * @defgroup tokens Tokens
187 YAML_STREAM_START_TOKEN,
188 YAML_STREAM_END_TOKEN,
190 YAML_VERSION_DIRECTIVE_TOKEN,
191 YAML_TAG_DIRECTIVE_TOKEN,
192 YAML_DOCUMENT_START_TOKEN,
193 YAML_DOCUMENT_END_TOKEN,
195 YAML_BLOCK_SEQUENCE_START_TOKEN,
196 YAML_BLOCK_MAPPING_START_TOKEN,
197 YAML_BLOCK_END_TOKEN,
199 YAML_FLOW_SEQUENCE_START_TOKEN,
200 YAML_FLOW_SEQUENCE_END_TOKEN,
201 YAML_FLOW_MAPPING_START_TOKEN,
202 YAML_FLOW_MAPPING_END_TOKEN,
204 YAML_BLOCK_ENTRY_TOKEN,
205 YAML_FLOW_ENTRY_TOKEN,
215 /** The token structure. */
218 /** The token type. */
219 yaml_token_type_t type;
221 /** The token data. */
224 /** The stream start (for @c YAML_STREAM_START_TOKEN). */
226 /** The stream encoding. */
227 yaml_encoding_t encoding;
230 /** The alias (for @c YAML_ALIAS_TOKEN). */
232 /** The alias value. */
236 /** The anchor (for @c YAML_ANCHOR_TOKEN). */
238 /** The anchor value. */
242 /** The tag (for @c YAML_TAG_TOKEN). */
244 /** The tag handle. */
246 /** The tag suffix. */
250 /** The scalar value (for @c YAML_SCALAR_TOKEN). */
252 /** The scalar value. */
254 /** The length of the scalar value. */
256 /** The scalar style. */
257 yaml_scalar_style_t style;
260 /** The version directive (for @c YAML_VERSION_DIRECTIVE_TOKEN). */
262 /** The major version number. */
264 /** The minor version number. */
268 /** The tag directive (for @c YAML_TAG_DIRECTIVE_TOKEN). */
270 /** The tag handle. */
272 /** The tag prefix. */
278 /** The beginning of the token. */
279 yaml_mark_t start_mark;
280 /** The end of the token. */
281 yaml_mark_t end_mark;
286 * Free any memory allocated for a token object.
288 * @param[in] token A token object.
292 yaml_token_delete(yaml_token_t *token);
297 * @defgroup events Events
305 YAML_STREAM_START_EVENT,
306 YAML_STREAM_END_EVENT,
308 YAML_DOCUMENT_START_EVENT,
309 YAML_DOCUMENT_END_EVENT,
314 YAML_SEQUENCE_START_EVENT,
315 YAML_SEQUENCE_END_EVENT,
317 YAML_MAPPING_START_EVENT,
318 YAML_MAPPING_END_EVENT
321 /** The event structure. */
324 /** The event type. */
325 yaml_event_type_t type;
327 /** The event data. */
330 /** The stream parameters (for @c YAML_STREAM_START_EVENT). */
332 /** The document encoding. */
333 yaml_encoding_t encoding;
336 /** The document parameters (for @c YAML_DOCUMENT_START_EVENT). */
338 /** The version directive. */
339 yaml_version_directive_t *version_directive;
341 /** The list of tag directives. */
343 /** The beginning of the tag directives list. */
344 yaml_tag_directive_t *start;
345 /** The end of the tag directives list. */
346 yaml_tag_directive_t *end;
349 /** Is the document indicator implicit? */
353 /** The document end parameters (for @c YAML_DOCUMENT_END_EVENT). */
355 /** Is the document end indicator implicit? */
359 /** The alias parameters (for @c YAML_ALIAS_EVENT). */
365 /** The scalar parameters (for @c YAML_SCALAR_EVENT). */
371 /** The scalar value. */
373 /** The length of the scalar value. */
375 /** Is the tag optional for the plain style? */
377 /** Is the tag optional for any non-plain style? */
379 /** The scalar style. */
380 yaml_scalar_style_t style;
383 /** The sequence parameters (for @c YAML_SEQUENCE_START_EVENT). */
389 /** Is the tag optional? */
391 /** The sequence style. */
392 yaml_sequence_style_t style;
395 /** The mapping parameters (for @c YAML_MAPPING_START_EVENT). */
401 /** Is the tag optional? */
403 /** The mapping style. */
404 yaml_mapping_style_t style;
409 /** The beginning of the token. */
410 yaml_mark_t start_mark;
411 /** The end of the token. */
412 yaml_mark_t end_mark;
417 * Free any memory allocated for an event object.
419 * @param[in] event An event object.
423 yaml_event_delete(yaml_event_t *event);
428 * @defgroup parser Parser Definitions
433 * The prototype of a read handler.
435 * The read handler is called when the parser needs to read more bytes from the
436 * source. The handler should write not more than @a size bytes to the @a
437 * buffer. The number of written bytes should be set to the @a length variable.
439 * @param[in] data A pointer to an application data specified by
440 * @c yaml_parser_set_read_handler.
441 * @param[out] buffer The buffer to write the data from the source.
442 * @param[in] size The size of the buffer.
443 * @param[out] size_read The actual number of bytes read from the source.
445 * @returns On success, the handler should return @c 1. If the handler failed,
446 * the returned value should be @c 0. On EOF, the handler should set the
447 * @a size_read to @c 0 and return @c 1.
450 typedef int yaml_read_handler_t(void *data, unsigned char *buffer, size_t size,
454 * This structure holds information about a potential simple key.
458 /** Is a simple key possible? */
461 /** Is a simple key required? */
464 /** The number of the token. */
467 /** The position mark. */
472 * The states of the parser.
475 YAML_PARSE_STREAM_START_STATE,
476 YAML_PARSE_IMPLICIT_DOCUMENT_START_STATE,
477 YAML_PARSE_DOCUMENT_START_STATE,
478 YAML_PARSE_DOCUMENT_CONTENT_STATE,
479 YAML_PARSE_DOCUMENT_END_STATE,
480 YAML_PARSE_BLOCK_NODE_STATE,
481 YAML_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE,
482 YAML_PARSE_FLOW_NODE_STATE,
483 YAML_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE,
484 YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE,
485 YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE,
486 YAML_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE,
487 YAML_PARSE_BLOCK_MAPPING_KEY_STATE,
488 YAML_PARSE_BLOCK_MAPPING_VALUE_STATE,
489 YAML_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE,
490 YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE,
491 YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE,
492 YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE,
493 YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE,
494 YAML_PARSE_FLOW_MAPPING_FIRST_KEY_STATE,
495 YAML_PARSE_FLOW_MAPPING_KEY_STATE,
496 YAML_PARSE_FLOW_MAPPING_VALUE_STATE,
497 YAML_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE,
499 } yaml_parser_state_t;
502 * The parser structure.
504 * All members are internal. Manage the structure using the @c yaml_parser_
505 * family of functions.
511 * @name Error handling
516 yaml_error_type_t error;
517 /** Error description. */
519 /** The byte about which the problem occured. */
520 size_t problem_offset;
521 /** The problematic value (@c -1 is none). */
523 /** The problem position. */
524 yaml_mark_t problem_mark;
525 /** The error context. */
527 /** The context position. */
528 yaml_mark_t context_mark;
540 yaml_read_handler_t *read_handler;
542 /** A pointer for passing to the read handler. */
543 void *read_handler_data;
545 /** Standard (string or file) input data. */
547 /** String input data. */
549 /** The string start pointer. */
550 unsigned char *start;
551 /** The string end pointer. */
553 /** The string current position. */
554 unsigned char *current;
557 /** File input data. */
564 /** The working buffer. */
566 /** The beginning of the buffer. */
568 /** The end of the buffer. */
570 /** The current position of the buffer. */
571 yaml_char_t *pointer;
572 /** The last filled position of the buffer. */
576 /* The number of unread characters in the buffer. */
579 /** The raw buffer. */
581 /** The beginning of the buffer. */
582 unsigned char *start;
583 /** The end of the buffer. */
585 /** The current position of the buffer. */
586 unsigned char *pointer;
587 /** The last filled position of the buffer. */
591 /** The input encoding. */
592 yaml_encoding_t encoding;
594 /** The offset of the current position (in bytes). */
597 /** The mark of the current position. */
605 * @name Scanner stuff
609 /** Have we started to scan the input stream? */
610 int stream_start_produced;
612 /** Have we reached the end of the input stream? */
613 int stream_end_produced;
615 /** The number of unclosed '[' and '{' indicators. */
618 /** The tokens queue. */
620 /** The beginning of the tokens queue. */
622 /** The end of the tokens queue. */
624 /** The head of the tokens queue. */
626 /** The tail of the tokens queue. */
630 /** The number of tokens fetched from the queue. */
631 size_t tokens_parsed;
633 /* Does the tokens queue contain a token ready for dequeueing. */
636 /** The indentation levels stack. */
638 /** The beginning of the stack. */
640 /** The end of the stack. */
642 /** The top of the stack. */
646 /** The current indentation level. */
649 /** May a simple key occur at the current position? */
650 int simple_key_allowed;
652 /** The stack of simple keys. */
654 /** The beginning of the stack. */
655 yaml_simple_key_t *start;
656 /** The end of the stack. */
657 yaml_simple_key_t *end;
658 /** The top of the stack. */
659 yaml_simple_key_t *top;
671 /** The parser states stack. */
673 /** The beginning of the stack. */
674 yaml_parser_state_t *start;
675 /** The end of the stack. */
676 yaml_parser_state_t *end;
677 /** The top of the stack. */
678 yaml_parser_state_t *top;
681 /** The current parser state. */
682 yaml_parser_state_t state;
684 /** The stack of marks. */
686 /** The beginning of the stack. */
688 /** The end of the stack. */
690 /** The top of the stack. */
694 /** The list of TAG directives. */
696 /** The beginning of the list. */
697 yaml_tag_directive_t *start;
698 /** The end of the list. */
699 yaml_tag_directive_t *end;
700 /** The top of the list. */
701 yaml_tag_directive_t *top;
711 * Initialize a parser.
713 * This function creates a new parser object. An application is responsible
714 * for destroying the object using the @c yaml_parser_delete function.
716 * @param[in] parser An empty parser object.
718 * @returns @c 1 if the function succeeded, @c 0 on error.
722 yaml_parser_initialize(yaml_parser_t *parser);
727 * @param[in] parser A parser object.
731 yaml_parser_delete(yaml_parser_t *parser);
734 * Set a string input.
736 * Note that the @a input pointer must be valid while the @a parser object
737 * exists. The application is responsible for destroing @a input after
738 * destroying the @a parser.
740 * @param[in] parser A parser object.
741 * @param[in] input A source data.
742 * @param[in] size The length of the source data in bytes.
746 yaml_parser_set_input_string(yaml_parser_t *parser,
747 unsigned char *input, size_t size);
752 * @a file should be a file object open for reading. The application is
753 * responsible for closing the @a file.
755 * @param[in] parser A parser object.
756 * @param[in] file An open file.
760 yaml_parser_set_input_file(yaml_parser_t *parser, FILE *file);
763 * Set a generic input handler.
765 * @param[in] parser A parser object.
766 * @param[in] handler A read handler.
767 * @param[in] data Any application data for passing to the read handler.
771 yaml_parser_set_input(yaml_parser_t *parser,
772 yaml_read_handler_t *handler, void *data);
775 * Set the source encoding.
777 * @param[in] parser A parser object.
778 * @param[in] encoding The source encoding.
782 yaml_parser_set_encoding(yaml_parser_t *parser, yaml_encoding_t encoding);
785 * Scan the input stream and produce the next token.
787 * Call the function subsequently to produce a sequence of tokens corresponding
788 * to the input stream. The initial token has the type
789 * @c YAML_STREAM_START_TOKEN while the ending token has the type
790 * @c YAML_STREAM_END_TOKEN.
792 * An application is responsible for freeing any buffers associated with the
793 * produced token object using the @c yaml_token_delete function.
795 * An application must not alternate the calls of @c yaml_parser_scan with the
796 * calls of @c yaml_parser_parse. Doing this will break the parser.
798 * @param[in] parser A parser object.
799 * @param[in] token An empty token object.
801 * @returns @c 1 if the function succeeded, @c 0 on error.
805 yaml_parser_scan(yaml_parser_t *parser, yaml_token_t *token);
808 * Parse the input stream and produce the next parsing event.
810 * Call the function subsequently to produce a sequence of events corresponding
811 * to the input stream. The initial event has the type
812 * @c YAML_STREAM_START_EVENT while the ending event has the type
813 * @c YAML_STREAM_END_EVENT.
815 * An application is responsible for freeing any buffers associated with the
816 * produced event object using the @c yaml_event_delete function.
818 * An application must not alternate the calls of @c yaml_parser_scan with the
819 * calls of @c yaml_parser_parse. Doing this will break the parser.
821 * @param[in] parser A parser object.
822 * @param[in] event An empty event object.
824 * @returns @c 1 if the function succeeded, @c 0 on error.
828 yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event);
833 * @defgroup emitter Emitter Definitions
838 * The prototype of a write handler.
840 * The write handler is called when the emitter needs to flush the accumulated
841 * characters to the output. The handler should write @a size bytes of the
842 * @a buffer to the output.
844 * @param[in] data A pointer to an application data specified by
845 * @c yaml_emitter_set_write_handler.
846 * @param[out] buffer The buffer with bytes to be written.
847 * @param[in] size The size of the buffer.
849 * @returns On success, the handler should return @c 1. If the handler failed,
850 * the returned value should be @c 0.
853 typedef int yaml_write_handler_t(void *data, unsigned char *buffer, size_t size);
855 /** The emitter states. */
857 YAML_EMIT_STREAM_START_STATE,
858 YAML_EMIT_FIRST_DOCUMENT_START_STATE,
859 YAML_EMIT_DOCUMENT_START_STATE,
860 YAML_EMIT_DOCUMENT_CONTENT_STATE,
861 YAML_EMIT_DOCUMENT_END_STATE,
862 YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE,
863 YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE,
864 YAML_EMIT_FLOW_MAPPING_FIRST_KEY_STATE,
865 YAML_EMIT_FLOW_MAPPING_KEY_STATE,
866 YAML_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE,
867 YAML_EMIT_FLOW_MAPPING_VALUE_STATE,
868 YAML_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE,
869 YAML_EMIT_BLOCK_SEQUENCE_ITEM_STATE,
870 YAML_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE,
871 YAML_EMIT_BLOCK_MAPPING_KEY_STATE,
872 YAML_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE,
873 YAML_EMIT_BLOCK_MAPPING_VALUE_STATE
874 } yaml_emitter_state_t;
877 * The emitter structure.
879 * All members are internal. Manage the structure using the @c yaml_emitter_
880 * family of functions.
886 * @name Error handling
891 yaml_error_type_t error;
892 /** Error description. */
904 /** Write handler. */
905 yaml_write_handler_t *write_handler;
907 /** A pointer for passing to the white handler. */
908 void *write_handler_data;
910 /** Standard (string or file) output data. */
912 /** String output data. */
914 /** The buffer pointer. */
915 unsigned char *buffer;
916 /** The buffer size. */
918 /** The number of written bytes. */
919 size_t *size_written;
922 /** File output data. */
926 /** The working buffer. */
928 /** The beginning of the buffer. */
930 /** The end of the buffer. */
932 /** The current position of the buffer. */
933 yaml_char_t *pointer;
934 /** The last filled position of the buffer. */
938 /** The raw buffer. */
940 /** The beginning of the buffer. */
941 unsigned char *start;
942 /** The end of the buffer. */
944 /** The current position of the buffer. */
945 unsigned char *pointer;
946 /** The last filled position of the buffer. */
950 /** The stream encoding. */
951 yaml_encoding_t encoding;
958 * @name Emitter stuff
962 /** If the output is in the canonical style? */
964 /** The number of indentation spaces. */
966 /** The preferred width of the output lines. */
968 /** Allow unescaped non-ASCII characters? */
970 /** The preferred line break. */
971 yaml_break_t line_break;
973 /** The stack of states. */
975 /** The beginning of the stack. */
976 yaml_emitter_state_t *start;
977 /** The end of the stack. */
978 yaml_emitter_state_t *end;
979 /** The top of the stack. */
980 yaml_emitter_state_t *top;
983 /** The current emitter state. */
984 yaml_emitter_state_t state;
986 /** The event queue. */
988 /** The beginning of the event queue. */
990 /** The end of the event queue. */
992 /** The head of the event queue. */
994 /** The tail of the event queue. */
998 /** The current event. */
1001 /** The stack of indentation levels. */
1003 /** The beginning of the stack. */
1005 /** The end of the stack. */
1007 /** The top of the stack. */
1011 /** The list of tag directives. */
1013 /** The beginning of the list. */
1014 yaml_tag_directive_t *start;
1015 /** The end of the list. */
1016 yaml_tag_directive_t *end;
1017 /** The top of the list. */
1018 yaml_tag_directive_t *top;
1021 /** The current indentation level. */
1024 /** The current flow level. */
1027 /** Is it the document root context? */
1029 /** Is it a sequence context? */
1030 int sequence_context;
1031 /** Is it a mapping context? */
1032 int mapping_context;
1033 /** Is it a simple mapping key context? */
1034 int simple_key_context;
1036 /** The current line. */
1038 /** The current column. */
1040 /** If the last character was a whitespace? */
1042 /** If the last character was an indentation character (' ', '-', '?', ':')? */
1052 * Initialize an emitter.
1054 * This function creates a new emitter object. An application is responsible
1055 * for destroying the object using the @c yaml_emitter_delete function.
1057 * @param[in] emitter An empty parser object.
1059 * @returns @c 1 if the function succeeded, @c 0 on error.
1063 yaml_emitter_initialize(yaml_emitter_t *emitter);
1066 * Destroy an emitter.
1068 * @param[in] emitter An emitter object.
1072 yaml_emitter_delete(yaml_emitter_t *emitter);
1075 * Set a string output.
1077 * The emitter will write the output characters to the @a output buffer of the
1078 * size @a size. The emitter will set @a size_written to the number of written
1079 * bytes. If the buffer is smaller than required, the emitter produces the
1080 * YAML_WRITE_ERROR error.
1082 * @param[in] emitter An emitter object.
1083 * @param[in] output An output buffer.
1084 * @param[in] size The buffer size.
1085 * @param[in] size_written The pointer to save the number of written bytes.
1089 yaml_emitter_set_output_string(yaml_emitter_t *emitter,
1090 unsigned char *output, size_t size, size_t *size_written);
1093 * Set a file output.
1095 * @a file should be a file object open for writing. The application is
1096 * responsible for closing the @a file.
1098 * @param[in] emitter An emitter object.
1099 * @param[in] file An open file.
1103 yaml_emitter_set_output_file(yaml_emitter_t *emitter, FILE *file);
1106 * Set a generic output handler.
1108 * @param[in] emitter An emitter object.
1109 * @param[in] handler A write handler.
1110 * @param[in] data Any application data for passing to the write handler.
1114 yaml_emitter_set_output(yaml_emitter_t *emitter,
1115 yaml_write_handler_t *handler, void *data);
1118 * Set the output encoding.
1120 * @param[in] emitter An emitter object.
1121 * @param[in] encoding The output encoding.
1125 yaml_emitter_set_encoding(yaml_emitter_t *emitter, yaml_encoding_t encoding);
1128 * Set if the output should be in the "canonical" format as in the YAML
1131 * @param[in] emitter An emitter object.
1132 * @param[in] canonical If the output is canonical.
1136 yaml_emitter_set_canonical(yaml_emitter_t *emitter, int canonical);
1139 * Set the intendation increment.
1141 * @param[in] emitter An emitter object.
1142 * @param[in] indent The indentation increment (1 < . < 10).
1146 yaml_emitter_set_indent(yaml_emitter_t *emitter, int indent);
1149 * Set the preferred line width. @c -1 means unlimited.
1151 * @param[in] emitter An emitter object.
1152 * @param[in] width The preferred line width.
1156 yaml_emitter_set_width(yaml_emitter_t *emitter, int width);
1159 * Set if unescaped non-ASCII characters are allowed.
1161 * @param[in] emitter An emitter object.
1162 * @param[in] unicode If unescaped Unicode characters are allowed.
1166 yaml_emitter_set_unicode(yaml_emitter_t *emitter, int unicode);
1169 * Set the preferred line break.
1171 * @param[in] emitter An emitter object.
1172 * @param[in] line_break The preferred line break.
1176 yaml_emitter_set_break(yaml_emitter_t *emitter, yaml_break_t line_break);
1181 * The event object may be generated using the @c yaml_parser_parse function.
1182 * The emitter will destroy the event object if the function succeeds. If the
1183 * function fails, the application is responsible for destroing the event
1186 * @param[in] emitter An emitter object.
1187 * @param[in] event An event object.
1189 * @returns @c 1 if the function succeeded, @c 0 on error.
1193 yaml_emitter_emit(yaml_emitter_t *emitter, yaml_event_t *event);
1196 * Emit the STREAM-START event.
1198 * @param[in] emitter An emitter object.
1199 * @param[in] encoding The stream encoding.
1201 * @returns @c 1 if the function succeeded, @c 0 on error.
1205 yaml_emitter_emit_stream_start(yaml_emitter_t *emitter,
1206 yaml_encoding_t encoding);
1209 * Emit the STREAM-END event.
1211 * @param[in] emitter An emitter object.
1213 * @returns @c 1 if the function succeeded, @c 0 on error.
1217 yaml_emitter_emit_stream_end(yaml_emitter_t *emitter);
1220 * Emit the DOCUMENT-START event.
1222 * The @a implicit argument is considered as a stylistic parameter and may be
1223 * ignored by the emitter.
1225 * @param[in] emitter An emitter object.
1226 * @param[in] version_directive The %YAML directive value or @c NULL.
1227 * @param[in] tag_directives_start The beginning of the %TAG directives list.
1228 * @param[in] tag_directives_end The end of the %TAG directives list.
1229 * @param[in] implicit If the document start indicator is implicit.
1231 * @returns @c 1 if the function succeeded, @c 0 on error.
1235 yaml_emitter_emit_document_start(yaml_emitter_t *emitter,
1236 yaml_version_directive_t *version_directive,
1237 yaml_tag_directive_t *tag_directives_start,
1238 yaml_tag_directive_t *tag_directives_end,
1242 * Emit the DOCUMENT-END event.
1244 * The @a implicit argument is considered as a stylistic parameter and may be
1245 * ignored by the emitter.
1247 * @param[in] emitter An emitter object.
1248 * @param[in] implicit If the document end indicator is implicit.
1250 * @returns @c 1 if the function succeeded, @c 0 on error.
1254 yaml_emitter_emit_document_end(yaml_emitter_t *emitter, int implicit);
1257 * Emit an ALIAS event.
1259 * @param[in] emitter An emitter object.
1260 * @param[in] anchor The anchor value.
1262 * @returns @c 1 if the function succeeded, @c 0 on error.
1266 yaml_emitter_emit_alias(yaml_emitter_t *emitter, yaml_char_t *anchor);
1269 * Emit a SCALAR event.
1271 * The @a style argument may be ignored by the emitter.
1273 * Either the @a tag attribute or one of the @a plain_implicit and
1274 * @a quoted_implicit flags must be set.
1276 * @param[in] emitter An emitter object.
1277 * @param[in] anchor The scalar anchor or @c NULL.
1278 * @param[in] tag The scalar tag or @c NULL.
1279 * @param[in] value The scalar value.
1280 * @param[in] length The length of the scalar value.
1281 * @param[in] plain_implicit If the tag may be omitted for the plain style.
1282 * @param[in] quoted_implicit If the tag may be omitted for any non-plain style.
1283 * @param[in] style The scalar style.
1285 * @returns @c 1 if the function succeeded, @c 0 on error.
1289 yaml_emitter_emit_scalar(yaml_emitter_t *emitter,
1290 yaml_char_t *anchor, yaml_char_t *tag,
1291 yaml_char_t *value, size_t length,
1292 int plain_implicit, int quoted_implicit,
1293 yaml_scalar_style_t style);
1296 * Emit a SEQUENCE-START event.
1298 * The @a style argument may be ignored by the emitter.
1300 * Either the @a tag attribute or the @a implicit flag must be set.
1302 * @param[in] emitter An emitter object.
1303 * @param[in] anchor The sequence anchor or @c NULL.
1304 * @param[in] tag The sequence tag or @c NULL.
1305 * @param[in] implicit If the tag may be omitted.
1306 * @param[in] style The sequence style.
1308 * @returns @c 1 if the function succeeded, @c 0 on error.
1312 yaml_emitter_emit_sequence_start(yaml_emitter_t *emitter,
1313 yaml_char_t *anchor, yaml_char_t *tag, int implicit,
1314 yaml_sequence_style_t style);
1317 * Emit a SEQUENCE-END event.
1319 * @param[in] emitter An emitter object.
1321 * @returns @c 1 if the function succeeded, @c 0 on error.
1325 yaml_emitter_emit_sequence_end(yaml_emitter_t *emitter);
1328 * Emit a MAPPING-START event.
1330 * The @a style argument may be ignored by the emitter.
1332 * Either the @a tag attribute or the @a implicit flag must be set.
1334 * @param[in] emitter An emitter object.
1335 * @param[in] anchor The mapping anchor or @c NULL.
1336 * @param[in] tag The mapping tag or @c NULL.
1337 * @param[in] implicit If the tag may be omitted.
1338 * @param[in] style The mapping style.
1340 * @returns @c 1 if the function succeeded, @c 0 on error.
1344 yaml_emitter_emit_mapping_start(yaml_emitter_t *emitter,
1345 yaml_char_t *anchor, yaml_char_t *tag, int implicit,
1346 yaml_mapping_style_t style);
1349 * Emit a MAPPING-END event.
1351 * @param[in] emitter An emitter object.
1353 * @returns @c 1 if the function succeeded, @c 0 on error.
1357 yaml_emitter_emit_mapping_end(yaml_emitter_t *emitter);
1360 * Flush the accumulated characters to the output.
1362 * @param[in] emitter An emitter object.
1364 * @returns @c 1 if the function succeeded, @c 0 on error.
1368 yaml_emitter_flush(yaml_emitter_t *emitter);
1376 #endif /* #ifndef YAML_H */