3 * @brief Public interface for libyaml.
5 * Include the header file with the code:
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,out] 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 * Create the STREAM-START event.
419 * @param[out] event An empty event object.
420 * @param[in] encoding The stream encoding.
422 * @returns @c 1 if the function succeeded, @c 0 on error.
426 yaml_stream_start_event_initialize(yaml_event_t *event,
427 yaml_encoding_t encoding);
430 * Create the STREAM-END event.
432 * @param[out] event An empty event object.
434 * @returns @c 1 if the function succeeded, @c 0 on error.
438 yaml_stream_end_event_initialize(yaml_event_t *event);
441 * Create the DOCUMENT-START event.
443 * The @a implicit argument is considered as a stylistic parameter and may be
444 * ignored by the emitter.
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.
452 * @returns @c 1 if the function succeeded, @c 0 on error.
456 yaml_document_start_event_initialize(yaml_event_t *event,
457 yaml_version_directive_t *version_directive,
458 yaml_tag_directive_t *tag_directives_start,
459 yaml_tag_directive_t *tag_directives_end,
463 * Create the DOCUMENT-END event.
465 * The @a implicit argument is considered as a stylistic parameter and may be
466 * ignored by the emitter.
468 * @param[out] event An empty event object.
469 * @param[in] implicit If the document end indicator is implicit.
471 * @returns @c 1 if the function succeeded, @c 0 on error.
475 yaml_document_end_event_initialize(yaml_event_t *event, int implicit);
478 * Create an ALIAS event.
480 * @param[out] event An empty event object.
481 * @param[in] anchor The anchor value.
483 * @returns @c 1 if the function succeeded, @c 0 on error.
487 yaml_alias_event_initialize(yaml_event_t *event, yaml_char_t *anchor);
490 * Create a SCALAR event.
492 * The @a style argument may be ignored by the emitter.
494 * Either the @a tag attribute or one of the @a plain_implicit and
495 * @a quoted_implicit flags must be set.
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.
506 * @returns @c 1 if the function succeeded, @c 0 on error.
510 yaml_scalar_event_initialize(yaml_event_t *event,
511 yaml_char_t *anchor, yaml_char_t *tag,
512 yaml_char_t *value, int length,
513 int plain_implicit, int quoted_implicit,
514 yaml_scalar_style_t style);
517 * Create a SEQUENCE-START event.
519 * The @a style argument may be ignored by the emitter.
521 * Either the @a tag attribute or the @a implicit flag must be set.
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.
529 * @returns @c 1 if the function succeeded, @c 0 on error.
533 yaml_sequence_start_event_initialize(yaml_event_t *event,
534 yaml_char_t *anchor, yaml_char_t *tag, int implicit,
535 yaml_sequence_style_t style);
538 * Create a SEQUENCE-END event.
540 * @param[out] event An empty event object.
542 * @returns @c 1 if the function succeeded, @c 0 on error.
546 yaml_sequence_end_event_initialize(yaml_event_t *event);
549 * Create a MAPPING-START event.
551 * The @a style argument may be ignored by the emitter.
553 * Either the @a tag attribute or the @a implicit flag must be set.
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.
561 * @returns @c 1 if the function succeeded, @c 0 on error.
565 yaml_mapping_start_event_initialize(yaml_event_t *event,
566 yaml_char_t *anchor, yaml_char_t *tag, int implicit,
567 yaml_mapping_style_t style);
570 * Create a MAPPING-END event.
572 * @param[out] event An empty event object.
574 * @returns @c 1 if the function succeeded, @c 0 on error.
578 yaml_mapping_end_event_initialize(yaml_event_t *event);
581 * Free any memory allocated for an event object.
583 * @param[out] event An event object.
587 yaml_event_delete(yaml_event_t *event);
592 * @defgroup parser Parser Definitions
597 * The prototype of a read handler.
599 * The read handler is called when the parser needs to read more bytes from the
600 * source. The handler should write not more than @a size bytes to the @a
601 * buffer. The number of written bytes should be set to the @a length variable.
603 * @param[in,out] data A pointer to an application data specified by
604 * yaml_parser_set_input().
605 * @param[out] buffer The buffer to write the data from the source.
606 * @param[in] size The size of the buffer.
607 * @param[out] size_read The actual number of bytes read from the source.
609 * @returns On success, the handler should return @c 1. If the handler failed,
610 * the returned value should be @c 0. On EOF, the handler should set the
611 * @a size_read to @c 0 and return @c 1.
614 typedef int yaml_read_handler_t(void *data, unsigned char *buffer, size_t size,
618 * This structure holds information about a potential simple key.
622 /** Is a simple key possible? */
625 /** Is a simple key required? */
628 /** The number of the token. */
631 /** The position mark. */
636 * The states of the parser.
639 YAML_PARSE_STREAM_START_STATE,
640 YAML_PARSE_IMPLICIT_DOCUMENT_START_STATE,
641 YAML_PARSE_DOCUMENT_START_STATE,
642 YAML_PARSE_DOCUMENT_CONTENT_STATE,
643 YAML_PARSE_DOCUMENT_END_STATE,
644 YAML_PARSE_BLOCK_NODE_STATE,
645 YAML_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE,
646 YAML_PARSE_FLOW_NODE_STATE,
647 YAML_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE,
648 YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE,
649 YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE,
650 YAML_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE,
651 YAML_PARSE_BLOCK_MAPPING_KEY_STATE,
652 YAML_PARSE_BLOCK_MAPPING_VALUE_STATE,
653 YAML_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE,
654 YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE,
655 YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE,
656 YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE,
657 YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE,
658 YAML_PARSE_FLOW_MAPPING_FIRST_KEY_STATE,
659 YAML_PARSE_FLOW_MAPPING_KEY_STATE,
660 YAML_PARSE_FLOW_MAPPING_VALUE_STATE,
661 YAML_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE,
663 } yaml_parser_state_t;
666 * The parser structure.
668 * All members are internal. Manage the structure using the @c yaml_parser_
669 * family of functions.
675 * @name Error handling
680 yaml_error_type_t error;
681 /** Error description. */
683 /** The byte about which the problem occured. */
684 size_t problem_offset;
685 /** The problematic value (@c -1 is none). */
687 /** The problem position. */
688 yaml_mark_t problem_mark;
689 /** The error context. */
691 /** The context position. */
692 yaml_mark_t context_mark;
704 yaml_read_handler_t *read_handler;
706 /** A pointer for passing to the read handler. */
707 void *read_handler_data;
709 /** Standard (string or file) input data. */
711 /** String input data. */
713 /** The string start pointer. */
714 unsigned char *start;
715 /** The string end pointer. */
717 /** The string current position. */
718 unsigned char *current;
721 /** File input data. */
728 /** The working buffer. */
730 /** The beginning of the buffer. */
732 /** The end of the buffer. */
734 /** The current position of the buffer. */
735 yaml_char_t *pointer;
736 /** The last filled position of the buffer. */
740 /* The number of unread characters in the buffer. */
743 /** The raw buffer. */
745 /** The beginning of the buffer. */
746 unsigned char *start;
747 /** The end of the buffer. */
749 /** The current position of the buffer. */
750 unsigned char *pointer;
751 /** The last filled position of the buffer. */
755 /** The input encoding. */
756 yaml_encoding_t encoding;
758 /** The offset of the current position (in bytes). */
761 /** The mark of the current position. */
769 * @name Scanner stuff
773 /** Have we started to scan the input stream? */
774 int stream_start_produced;
776 /** Have we reached the end of the input stream? */
777 int stream_end_produced;
779 /** The number of unclosed '[' and '{' indicators. */
782 /** The tokens queue. */
784 /** The beginning of the tokens queue. */
786 /** The end of the tokens queue. */
788 /** The head of the tokens queue. */
790 /** The tail of the tokens queue. */
794 /** The number of tokens fetched from the queue. */
795 size_t tokens_parsed;
797 /* Does the tokens queue contain a token ready for dequeueing. */
800 /** The indentation levels stack. */
802 /** The beginning of the stack. */
804 /** The end of the stack. */
806 /** The top of the stack. */
810 /** The current indentation level. */
813 /** May a simple key occur at the current position? */
814 int simple_key_allowed;
816 /** The stack of simple keys. */
818 /** The beginning of the stack. */
819 yaml_simple_key_t *start;
820 /** The end of the stack. */
821 yaml_simple_key_t *end;
822 /** The top of the stack. */
823 yaml_simple_key_t *top;
835 /** The parser states stack. */
837 /** The beginning of the stack. */
838 yaml_parser_state_t *start;
839 /** The end of the stack. */
840 yaml_parser_state_t *end;
841 /** The top of the stack. */
842 yaml_parser_state_t *top;
845 /** The current parser state. */
846 yaml_parser_state_t state;
848 /** The stack of marks. */
850 /** The beginning of the stack. */
852 /** The end of the stack. */
854 /** The top of the stack. */
858 /** The list of TAG directives. */
860 /** The beginning of the list. */
861 yaml_tag_directive_t *start;
862 /** The end of the list. */
863 yaml_tag_directive_t *end;
864 /** The top of the list. */
865 yaml_tag_directive_t *top;
875 * Initialize a parser.
877 * This function creates a new parser object. An application is responsible
878 * for destroying the object using the yaml_parser_delete() function.
880 * @param[out] parser An empty parser object.
882 * @returns @c 1 if the function succeeded, @c 0 on error.
886 yaml_parser_initialize(yaml_parser_t *parser);
891 * @param[in,out] parser A parser object.
895 yaml_parser_delete(yaml_parser_t *parser);
898 * Set a string input.
900 * Note that the @a input pointer must be valid while the @a parser object
901 * exists. The application is responsible for destroing @a input after
902 * destroying the @a parser.
904 * @param[in,out] parser A parser object.
905 * @param[in] input A source data.
906 * @param[in] size The length of the source data in bytes.
910 yaml_parser_set_input_string(yaml_parser_t *parser,
911 unsigned char *input, size_t size);
916 * @a file should be a file object open for reading. The application is
917 * responsible for closing the @a file.
919 * @param[in,out] parser A parser object.
920 * @param[in] file An open file.
924 yaml_parser_set_input_file(yaml_parser_t *parser, FILE *file);
927 * Set a generic input handler.
929 * @param[in,out] parser A parser object.
930 * @param[in] handler A read handler.
931 * @param[in] data Any application data for passing to the read
936 yaml_parser_set_input(yaml_parser_t *parser,
937 yaml_read_handler_t *handler, void *data);
940 * Set the source encoding.
942 * @param[in,out] parser A parser object.
943 * @param[in] encoding The source encoding.
947 yaml_parser_set_encoding(yaml_parser_t *parser, yaml_encoding_t encoding);
950 * Scan the input stream and produce the next token.
952 * Call the function subsequently to produce a sequence of tokens corresponding
953 * to the input stream. The initial token has the type
954 * @c YAML_STREAM_START_TOKEN while the ending token has the type
955 * @c YAML_STREAM_END_TOKEN.
957 * An application is responsible for freeing any buffers associated with the
958 * produced token object using the @c yaml_token_delete function.
960 * An application must not alternate the calls of yaml_parser_scan() with the
961 * calls of yaml_parser_parse(). Doing this will break the parser.
963 * @param[in,out] parser A parser object.
964 * @param[out] token An empty token object.
966 * @returns @c 1 if the function succeeded, @c 0 on error.
970 yaml_parser_scan(yaml_parser_t *parser, yaml_token_t *token);
973 * Parse the input stream and produce the next parsing event.
975 * Call the function subsequently to produce a sequence of events corresponding
976 * to the input stream. The initial event has the type
977 * @c YAML_STREAM_START_EVENT while the ending event has the type
978 * @c YAML_STREAM_END_EVENT.
980 * An application is responsible for freeing any buffers associated with the
981 * produced event object using the yaml_event_delete() function.
983 * An application must not alternate the calls of yaml_parser_scan() with the
984 * calls of yaml_parser_parse(). Doing this will break the parser.
986 * @param[in,out] parser A parser object.
987 * @param[out] event An empty event object.
989 * @returns @c 1 if the function succeeded, @c 0 on error.
993 yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event);
998 * @defgroup emitter Emitter Definitions
1003 * The prototype of a write handler.
1005 * The write handler is called when the emitter needs to flush the accumulated
1006 * characters to the output. The handler should write @a size bytes of the
1007 * @a buffer to the output.
1009 * @param[in,out] data A pointer to an application data specified by
1010 * yaml_emitter_set_output().
1011 * @param[in] buffer The buffer with bytes to be written.
1012 * @param[in] size The size of the buffer.
1014 * @returns On success, the handler should return @c 1. If the handler failed,
1015 * the returned value should be @c 0.
1018 typedef int yaml_write_handler_t(void *data, unsigned char *buffer, size_t size);
1020 /** The emitter states. */
1022 YAML_EMIT_STREAM_START_STATE,
1023 YAML_EMIT_FIRST_DOCUMENT_START_STATE,
1024 YAML_EMIT_DOCUMENT_START_STATE,
1025 YAML_EMIT_DOCUMENT_CONTENT_STATE,
1026 YAML_EMIT_DOCUMENT_END_STATE,
1027 YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE,
1028 YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE,
1029 YAML_EMIT_FLOW_MAPPING_FIRST_KEY_STATE,
1030 YAML_EMIT_FLOW_MAPPING_KEY_STATE,
1031 YAML_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE,
1032 YAML_EMIT_FLOW_MAPPING_VALUE_STATE,
1033 YAML_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE,
1034 YAML_EMIT_BLOCK_SEQUENCE_ITEM_STATE,
1035 YAML_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE,
1036 YAML_EMIT_BLOCK_MAPPING_KEY_STATE,
1037 YAML_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE,
1038 YAML_EMIT_BLOCK_MAPPING_VALUE_STATE,
1040 } yaml_emitter_state_t;
1043 * The emitter structure.
1045 * All members are internal. Manage the structure using the @c yaml_emitter_
1046 * family of functions.
1052 * @name Error handling
1057 yaml_error_type_t error;
1058 /** Error description. */
1059 const char *problem;
1066 * @name Writer stuff
1070 /** Write handler. */
1071 yaml_write_handler_t *write_handler;
1073 /** A pointer for passing to the white handler. */
1074 void *write_handler_data;
1076 /** Standard (string or file) output data. */
1078 /** String output data. */
1080 /** The buffer pointer. */
1081 unsigned char *buffer;
1082 /** The buffer size. */
1084 /** The number of written bytes. */
1085 size_t *size_written;
1088 /** File output data. */
1092 /** The working buffer. */
1094 /** The beginning of the buffer. */
1096 /** The end of the buffer. */
1098 /** The current position of the buffer. */
1099 yaml_char_t *pointer;
1100 /** The last filled position of the buffer. */
1104 /** The raw buffer. */
1106 /** The beginning of the buffer. */
1107 unsigned char *start;
1108 /** The end of the buffer. */
1110 /** The current position of the buffer. */
1111 unsigned char *pointer;
1112 /** The last filled position of the buffer. */
1113 unsigned char *last;
1116 /** The stream encoding. */
1117 yaml_encoding_t encoding;
1124 * @name Emitter stuff
1128 /** If the output is in the canonical style? */
1130 /** The number of indentation spaces. */
1132 /** The preferred width of the output lines. */
1134 /** Allow unescaped non-ASCII characters? */
1136 /** The preferred line break. */
1137 yaml_break_t line_break;
1139 /** The stack of states. */
1141 /** The beginning of the stack. */
1142 yaml_emitter_state_t *start;
1143 /** The end of the stack. */
1144 yaml_emitter_state_t *end;
1145 /** The top of the stack. */
1146 yaml_emitter_state_t *top;
1149 /** The current emitter state. */
1150 yaml_emitter_state_t state;
1152 /** The event queue. */
1154 /** The beginning of the event queue. */
1155 yaml_event_t *start;
1156 /** The end of the event queue. */
1158 /** The head of the event queue. */
1160 /** The tail of the event queue. */
1164 /** The stack of indentation levels. */
1166 /** The beginning of the stack. */
1168 /** The end of the stack. */
1170 /** The top of the stack. */
1174 /** The list of tag directives. */
1176 /** The beginning of the list. */
1177 yaml_tag_directive_t *start;
1178 /** The end of the list. */
1179 yaml_tag_directive_t *end;
1180 /** The top of the list. */
1181 yaml_tag_directive_t *top;
1184 /** The current indentation level. */
1187 /** The current flow level. */
1190 /** Is it the document root context? */
1192 /** Is it a sequence context? */
1193 int sequence_context;
1194 /** Is it a mapping context? */
1195 int mapping_context;
1196 /** Is it a simple mapping key context? */
1197 int simple_key_context;
1199 /** The current line. */
1201 /** The current column. */
1203 /** If the last character was a whitespace? */
1205 /** If the last character was an indentation character (' ', '-', '?', ':')? */
1208 /** Anchor analysis. */
1210 /** The anchor value. */
1211 yaml_char_t *anchor;
1212 /** The anchor length. */
1213 size_t anchor_length;
1214 /** Is it an alias? */
1218 /** Tag analysis. */
1220 /** The tag handle. */
1221 yaml_char_t *handle;
1222 /** The tag handle length. */
1223 size_t handle_length;
1224 /** The tag suffix. */
1225 yaml_char_t *suffix;
1226 /** The tag suffix length. */
1227 size_t suffix_length;
1230 /** Scalar analysis. */
1232 /** The scalar value. */
1234 /** The scalar length. */
1236 /** Does the scalar contain line breaks? */
1238 /** Can the scalar be expessed in the flow plain style? */
1239 int flow_plain_allowed;
1240 /** Can the scalar be expressed in the block plain style? */
1241 int block_plain_allowed;
1242 /** Can the scalar be expressed in the single quoted style? */
1243 int single_quoted_allowed;
1244 /** Can the scalar be expressed in the literal or folded styles? */
1246 /** The output style. */
1247 yaml_scalar_style_t style;
1257 * Initialize an emitter.
1259 * This function creates a new emitter object. An application is responsible
1260 * for destroying the object using the yaml_emitter_delete() function.
1262 * @param[out] emitter An empty parser object.
1264 * @returns @c 1 if the function succeeded, @c 0 on error.
1268 yaml_emitter_initialize(yaml_emitter_t *emitter);
1271 * Destroy an emitter.
1273 * @param[in,out] emitter An emitter object.
1277 yaml_emitter_delete(yaml_emitter_t *emitter);
1280 * Set a string output.
1282 * The emitter will write the output characters to the @a output buffer of the
1283 * size @a size. The emitter will set @a size_written to the number of written
1284 * bytes. If the buffer is smaller than required, the emitter produces the
1285 * YAML_WRITE_ERROR error.
1287 * @param[in,out] emitter An emitter object.
1288 * @param[in] output An output buffer.
1289 * @param[in] size The buffer size.
1290 * @param[in] size_written The pointer to save the number of written
1295 yaml_emitter_set_output_string(yaml_emitter_t *emitter,
1296 unsigned char *output, size_t size, size_t *size_written);
1299 * Set a file output.
1301 * @a file should be a file object open for writing. The application is
1302 * responsible for closing the @a file.
1304 * @param[in,out] emitter An emitter object.
1305 * @param[in] file An open file.
1309 yaml_emitter_set_output_file(yaml_emitter_t *emitter, FILE *file);
1312 * Set a generic output handler.
1314 * @param[in,out] emitter An emitter object.
1315 * @param[in] handler A write handler.
1316 * @param[in] data Any application data for passing to the write
1321 yaml_emitter_set_output(yaml_emitter_t *emitter,
1322 yaml_write_handler_t *handler, void *data);
1325 * Set the output encoding.
1327 * @param[in,out] emitter An emitter object.
1328 * @param[in] encoding The output encoding.
1332 yaml_emitter_set_encoding(yaml_emitter_t *emitter, yaml_encoding_t encoding);
1335 * Set if the output should be in the "canonical" format as in the YAML
1338 * @param[in,out] emitter An emitter object.
1339 * @param[in] canonical If the output is canonical.
1343 yaml_emitter_set_canonical(yaml_emitter_t *emitter, int canonical);
1346 * Set the intendation increment.
1348 * @param[in,out] emitter An emitter object.
1349 * @param[in] indent The indentation increment (1 < . < 10).
1353 yaml_emitter_set_indent(yaml_emitter_t *emitter, int indent);
1356 * Set the preferred line width. @c -1 means unlimited.
1358 * @param[in,out] emitter An emitter object.
1359 * @param[in] width The preferred line width.
1363 yaml_emitter_set_width(yaml_emitter_t *emitter, int width);
1366 * Set if unescaped non-ASCII characters are allowed.
1368 * @param[in,out] emitter An emitter object.
1369 * @param[in] unicode If unescaped Unicode characters are allowed.
1373 yaml_emitter_set_unicode(yaml_emitter_t *emitter, int unicode);
1376 * Set the preferred line break.
1378 * @param[in,out] emitter An emitter object.
1379 * @param[in] line_break The preferred line break.
1383 yaml_emitter_set_break(yaml_emitter_t *emitter, yaml_break_t line_break);
1388 * The event object may be generated using the yaml_parser_parse() function.
1389 * The emitter takes the responsibility for the event object and destroys its
1390 * content after it is emitted. The event object is destroyed even if the
1393 * @param[in,out] emitter An emitter object.
1394 * @param[in,out] event An event object.
1396 * @returns @c 1 if the function succeeded, @c 0 on error.
1400 yaml_emitter_emit(yaml_emitter_t *emitter, yaml_event_t *event);
1403 * Flush the accumulated characters to the output.
1405 * @param[in,out] emitter An emitter object.
1407 * @returns @c 1 if the function succeeded, @c 0 on error.
1411 yaml_emitter_flush(yaml_emitter_t *emitter);
1419 #endif /* #ifndef YAML_H */