]> gitweb.factorcode.org Git - factor.git/blob - extra/yaml/ffi/ffi.factor
Switch to https urls
[factor.git] / extra / yaml / ffi / ffi.factor
1 ! Copyright (C) 2013 Jon Harper.
2 ! See https://factorcode.org/license.txt for BSD license.
3 ! adapted from "yaml.h" libYAML 0.1.4
4 ! https://pyyaml.org/wiki/LibYAML
5 USING: alien alien.c-types alien.destructors alien.libraries
6 alien.syntax classes.struct combinators literals system
7 alien.libraries.finder ;
8 IN: yaml.ffi
9
10 <<
11 "libyaml" { "yaml" "yaml-0" "libyaml-0-2" } find-library-from-list cdecl add-library
12 >>
13
14 C-TYPE: FILE
15
16 LIBRARY: libyaml
17
18 ! /**
19 !  * @defgroup version Version Information
20 !  * @{
21 !  */
22
23 ! /**
24 !  * Get the library version as a string.
25 !  *
26 !  * @returns The function returns the pointer to a static string of the form
27 !  * @c "X.Y.Z", where @c X is the major version number, @c Y is a minor version
28 !  * number, and @c Z is the patch version number.
29 !  */
30 FUNCTION: c-string
31 yaml_get_version_string ( )
32
33 ! /**
34 !  * Get the library version numbers.
35 !  *
36 !  * @param[out]      major   Major version number.
37 !  * @param[out]      minor   Minor version number.
38 !  * @param[out]      patch   Patch version number.
39 !  */
40 FUNCTION: void
41 yaml_get_version ( int *major, int *minor, int *patch )
42
43 ! /** @} */
44
45 ! /**
46 !  * @defgroup basic Basic Types
47 !  * @{
48 !  */
49
50 ! /** The character type (UTF-8 octet). */
51 ! libYAML returns it's data as null-terminated UTF-8 string.
52 ! It copies it's input and we can use null-terminated string
53 ! if we give a negative length. So we can use factor's c-string
54 ! for input and output.
55 TYPEDEF: uchar yaml_char_t
56
57 ! /** The version directive data. */
58 STRUCT: yaml_version_directive_t
59     { major int }
60     { minor int }
61 ;
62
63 ! /** The tag directive data. */
64 STRUCT: yaml_tag_directive_t
65     { handle c-string }
66     { prefix c-string }
67 ;
68
69 ! /** The stream encoding. */
70 ENUM: yaml_encoding_t
71     YAML_ANY_ENCODING
72     YAML_UTF8_ENCODING
73     YAML_UTF16LE_ENCODING
74     YAML_UTF16BE_ENCODING
75 ;
76
77 ! /** Line break types. */
78 ENUM: yaml_break_t
79     YAML_ANY_BREAK
80     YAML_CR_BREAK
81     YAML_LN_BREAK
82     YAML_CRLN_BREAK
83 ;
84
85 ! /** Many bad things could happen with the parser and emitter. */
86 ENUM: yaml_error_type_t
87     YAML_NO_ERROR
88
89     YAML_MEMORY_ERROR
90
91     YAML_READER_ERROR
92     YAML_SCANNER_ERROR
93     YAML_PARSER_ERROR
94     YAML_COMPOSER_ERROR
95
96     YAML_WRITER_ERROR
97     YAML_EMITTER_ERROR
98 ;
99
100 ! /** The pointer position. */
101 STRUCT: yaml_mark_t
102     { index size_t }
103     { line size_t }
104     { column size_t }
105 ;
106
107 ! /** @} */
108
109 ! /**
110 !  * @defgroup styles Node Styles
111 !  * @{
112 !  */
113
114 ! /** Scalar styles. */
115 ENUM: yaml_scalar_style_t
116     YAML_ANY_SCALAR_STYLE
117
118     YAML_PLAIN_SCALAR_STYLE
119
120     YAML_SINGLE_QUOTED_SCALAR_STYLE
121     YAML_DOUBLE_QUOTED_SCALAR_STYLE
122
123     YAML_LITERAL_SCALAR_STYLE
124     YAML_FOLDED_SCALAR_STYLE
125 ;
126
127 ! /** Sequence styles. */
128 ENUM: yaml_sequence_style_t
129     YAML_ANY_SEQUENCE_STYLE
130
131     YAML_BLOCK_SEQUENCE_STYLE
132     YAML_FLOW_SEQUENCE_STYLE
133 ;
134
135 ! /** Mapping styles. */
136 ENUM: yaml_mapping_style_t
137     YAML_ANY_MAPPING_STYLE
138
139     YAML_BLOCK_MAPPING_STYLE
140     YAML_FLOW_MAPPING_STYLE
141 ;
142
143 ! /** @} */
144
145 ! /**
146 !  * @defgroup tokens Tokens
147 !  * @{
148 !  */
149
150 ! /** Token types. */
151 ENUM: yaml_token_type_t
152     YAML_NO_TOKEN
153
154     YAML_STREAM_START_TOKEN
155     YAML_STREAM_END_TOKEN
156
157     YAML_VERSION_DIRECTIVE_TOKEN
158     YAML_TAG_DIRECTIVE_TOKEN
159     YAML_DOCUMENT_START_TOKEN
160     YAML_DOCUMENT_END_TOKEN
161
162     YAML_BLOCK_SEQUENCE_START_TOKEN
163     YAML_BLOCK_MAPPING_START_TOKEN
164     YAML_BLOCK_END_TOKEN
165
166     YAML_FLOW_SEQUENCE_START_TOKEN
167     YAML_FLOW_SEQUENCE_END_TOKEN
168     YAML_FLOW_MAPPING_START_TOKEN
169     YAML_FLOW_MAPPING_END_TOKEN
170
171     YAML_BLOCK_ENTRY_TOKEN
172     YAML_FLOW_ENTRY_TOKEN
173     YAML_KEY_TOKEN
174     YAML_VALUE_TOKEN
175
176     YAML_ALIAS_TOKEN
177     YAML_ANCHOR_TOKEN
178     YAML_TAG_TOKEN
179     YAML_SCALAR_TOKEN
180 ;
181
182 ! /** The token structure. */
183 ! /** The stream start (for @c YAML_STREAM_START_TOKEN). */
184 STRUCT: stream_start_token_data
185     { encoding yaml_encoding_t }
186 ;
187 ! /** The alias (for @c YAML_ALIAS_TOKEN). */
188 STRUCT: alias_token_data
189     { value c-string }
190 ;
191 ! /** The anchor (for @c YAML_ANCHOR_TOKEN). */
192 STRUCT: anchor_token_data
193     { value c-string }
194 ;
195
196 ! /** The tag (for @c YAML_TAG_TOKEN). */
197 STRUCT: tag_token_data
198     { handle c-string }
199     { suffix c-string }
200 ;
201
202 ! /** The scalar value (for @c YAML_SCALAR_TOKEN). */
203 STRUCT: scalar_token_data
204     { value c-string }
205     { length size_t }
206     { style yaml_scalar_style_t }
207 ;
208
209 ! /** The version directive (for @c YAML_VERSION_DIRECTIVE_TOKEN). */
210 STRUCT: version_directive_token_data
211     { major int }
212     { minor int }
213 ;
214
215 UNION-STRUCT: token_data
216   { stream_start stream_start_token_data }
217   { alias alias_token_data }
218   { anchor anchor_token_data }
219   { tag tag_token_data }
220   { scalar scalar_token_data }
221   { version_directive version_directive_token_data }
222 ;
223 STRUCT: yaml_token_t
224
225     { type yaml_token_type_t }
226
227     { data token_data }
228
229     { start_mark yaml_mark_t }
230     { end_mark yaml_mark_t }
231 ;
232
233 ! /**
234 !  * Free any memory allocated for a token object.
235 !  *
236 !  * @param[in,out]   token   A token object.
237 !  */
238
239 FUNCTION: void
240 yaml_token_delete ( yaml_token_t *token )
241 DESTRUCTOR: yaml_token_delete
242
243 ! /** @} */
244
245 ! /**
246 !  * @defgroup events Events
247 !  * @{
248 !  */
249
250 ! /** Event types. */
251 ENUM: yaml_event_type_t
252     YAML_NO_EVENT
253
254     YAML_STREAM_START_EVENT
255     YAML_STREAM_END_EVENT
256
257     YAML_DOCUMENT_START_EVENT
258     YAML_DOCUMENT_END_EVENT
259
260     YAML_ALIAS_EVENT
261     YAML_SCALAR_EVENT
262
263     YAML_SEQUENCE_START_EVENT
264     YAML_SEQUENCE_END_EVENT
265
266     YAML_MAPPING_START_EVENT
267     YAML_MAPPING_END_EVENT
268 ;
269
270 ! /** The event structure. */
271
272 ! /** The event data. */
273 ! /** The stream parameters (for @c YAML_STREAM_START_EVENT). */
274 STRUCT: stream_start_event_data
275     { encoding yaml_encoding_t }
276 ;
277
278 ! /** The document parameters (for @c YAML_DOCUMENT_START_EVENT). */
279 !   /** The list of tag directives. */
280     STRUCT: tag_directives_document_start_event_data
281         { start yaml_tag_directive_t* }
282         { end yaml_tag_directive_t* }
283     ;
284 STRUCT: document_start_event_data
285     { version_directive yaml_version_directive_t* }
286     { tag_directives tag_directives_document_start_event_data }
287     { implicit int }
288 ;
289
290 ! /** The document end parameters (for @c YAML_DOCUMENT_END_EVENT). */
291 STRUCT: document_end_event_data
292     { implicit int }
293 ;
294
295 ! /** The alias parameters (for @c YAML_ALIAS_EVENT). */
296 STRUCT: alias_event_data
297     { anchor c-string }
298 ;
299
300 ! /** The scalar parameters (for @c YAML_SCALAR_EVENT). */
301 STRUCT: scalar_event_data
302     { anchor c-string }
303     { tag c-string }
304     { value c-string }
305     { length size_t }
306     { plain_implicit int }
307     { quoted_implicit int }
308     { style yaml_scalar_style_t }
309 ;
310
311 ! /** The sequence parameters (for @c YAML_SEQUENCE_START_EVENT). */
312 STRUCT: sequence_start_event_data
313     { anchor c-string }
314     { tag c-string }
315     { implicit int }
316     { style yaml_sequence_style_t }
317 ;
318
319 ! /** The mapping parameters (for @c YAML_MAPPING_START_EVENT). */
320 STRUCT: mapping_start_event_data
321     { anchor c-string }
322     { tag c-string }
323     { implicit int }
324     { style yaml_mapping_style_t }
325 ;
326
327 UNION-STRUCT: event_data
328   { stream_start stream_start_event_data }
329   { document_start document_start_event_data }
330   { document_end document_end_event_data }
331   { alias alias_event_data }
332   { scalar scalar_event_data }
333   { sequence_start sequence_start_event_data }
334   { mapping_start mapping_start_event_data }
335 ;
336
337 STRUCT: yaml_event_t
338
339     { type yaml_event_type_t }
340
341     { data event_data }
342
343     { start_mark yaml_mark_t }
344     { end_mark yaml_mark_t }
345 ;
346
347 ! /**
348 !  * Create the STREAM-START event.
349 !  *
350 !  * @param[out]      event       An empty event object.
351 !  * @param[in]       encoding    The stream encoding.
352 !  *
353 !  * @returns @c 1 if the function succeeded, @c 0 on error.
354 !  */
355
356 FUNCTION: bool
357 yaml_stream_start_event_initialize ( yaml_event_t *event,
358         yaml_encoding_t encoding )
359
360 ! /**
361 !  * Create the STREAM-END event.
362 !  *
363 !  * @param[out]      event       An empty event object.
364 !  *
365 !  * @returns @c 1 if the function succeeded, @c 0 on error.
366 !  */
367
368 FUNCTION: bool
369 yaml_stream_end_event_initialize ( yaml_event_t *event )
370
371 ! /**
372 !  * Create the DOCUMENT-START event.
373 !  *
374 !  * The @a implicit argument is considered as a stylistic parameter and may be
375 !  * ignored by the emitter.
376 !  *
377 !  * @param[out]      event                   An empty event object.
378 !  * @param[in]       version_directive       The %YAML directive value or
379 !  *                                          @c NULL.
380 !  * @param[in]       tag_directives_start    The beginning of the %TAG
381 !  *                                          directives list.
382 !  * @param[in]       tag_directives_end      The end of the %TAG directives
383 !  *                                          list.
384 !  * @param[in]       implicit                If the document start indicator is
385 !  *                                          implicit.
386 !  *
387 !  * @returns @c 1 if the function succeeded, @c 0 on error.
388 !  */
389
390 FUNCTION: bool
391 yaml_document_start_event_initialize ( yaml_event_t *event,
392         yaml_version_directive_t *version_directive,
393         yaml_tag_directive_t *tag_directives_start,
394         yaml_tag_directive_t *tag_directives_end,
395         bool implicit )
396
397 ! /**
398 !  * Create the DOCUMENT-END event.
399 !  *
400 !  * The @a implicit argument is considered as a stylistic parameter and may be
401 !  * ignored by the emitter.
402 !  *
403 !  * @param[out]      event       An empty event object.
404 !  * @param[in]       implicit    If the document end indicator is implicit.
405 !  *
406 !  * @returns @c 1 if the function succeeded, @c 0 on error.
407 !  */
408
409 FUNCTION: bool
410 yaml_document_end_event_initialize ( yaml_event_t *event, bool implicit )
411
412 ! /**
413 !  * Create an ALIAS event.
414 !  *
415 !  * @param[out]      event       An empty event object.
416 !  * @param[in]       anchor      The anchor value.
417 !  *
418 !  * @returns @c 1 if the function succeeded, @c 0 on error.
419 !  */
420
421 FUNCTION: bool
422 yaml_alias_event_initialize ( yaml_event_t *event, c-string anchor )
423
424 ! /**
425 !  * Create a SCALAR event.
426 !  *
427 !  * The @a style argument may be ignored by the emitter.
428 !  *
429 !  * Either the @a tag attribute or one of the @a plain_implicit and
430 !  * @a quoted_implicit flags must be set.
431 !  *
432 !  * @param[out]      event           An empty event object.
433 !  * @param[in]       anchor          The scalar anchor or @c NULL.
434 !  * @param[in]       tag             The scalar tag or @c NULL.
435 !  * @param[in]       value           The scalar value.
436 !  * @param[in]       length          The length of the scalar value.
437 !  * @param[in]       plain_implicit  If the tag may be omitted for the plain
438 !  *                                  style.
439 !  * @param[in]       quoted_implicit If the tag may be omitted for any
440 !  *                                  non-plain style.
441 !  * @param[in]       style           The scalar style.
442 !  *
443 !  * @returns @c 1 if the function succeeded, @c 0 on error.
444 !  */
445
446 FUNCTION: bool
447 yaml_scalar_event_initialize ( yaml_event_t *event,
448         c-string anchor, c-string tag,
449         c-string value, int length,
450         bool plain_implicit, bool quoted_implicit,
451         yaml_scalar_style_t style )
452
453 ! /**
454 !  * Create a SEQUENCE-START event.
455 !  *
456 !  * The @a style argument may be ignored by the emitter.
457 !  *
458 !  * Either the @a tag attribute or the @a implicit flag must be set.
459 !  *
460 !  * @param[out]      event       An empty event object.
461 !  * @param[in]       anchor      The sequence anchor or @c NULL.
462 !  * @param[in]       tag         The sequence tag or @c NULL.
463 !  * @param[in]       implicit    If the tag may be omitted.
464 !  * @param[in]       style       The sequence style.
465 !  *
466 !  * @returns @c 1 if the function succeeded, @c 0 on error.
467 !  */
468
469 FUNCTION: bool
470 yaml_sequence_start_event_initialize ( yaml_event_t *event,
471         c-string anchor, c-string tag, bool implicit,
472         yaml_sequence_style_t style )
473
474 ! /**
475 !  * Create a SEQUENCE-END event.
476 !  *
477 !  * @param[out]      event       An empty event object.
478 !  *
479 !  * @returns @c 1 if the function succeeded, @c 0 on error.
480 !  */
481
482 FUNCTION: bool
483 yaml_sequence_end_event_initialize ( yaml_event_t *event )
484
485 ! /**
486 !  * Create a MAPPING-START event.
487 !  *
488 !  * The @a style argument may be ignored by the emitter.
489 !  *
490 !  * Either the @a tag attribute or the @a implicit flag must be set.
491 !  *
492 !  * @param[out]      event       An empty event object.
493 !  * @param[in]       anchor      The mapping anchor or @c NULL.
494 !  * @param[in]       tag         The mapping tag or @c NULL.
495 !  * @param[in]       implicit    If the tag may be omitted.
496 !  * @param[in]       style       The mapping style.
497 !  *
498 !  * @returns @c 1 if the function succeeded, @c 0 on error.
499 !  */
500
501 FUNCTION: bool
502 yaml_mapping_start_event_initialize ( yaml_event_t *event,
503         c-string anchor, c-string tag, bool implicit,
504         yaml_mapping_style_t style )
505
506 ! /**
507 !  * Create a MAPPING-END event.
508 !  *
509 !  * @param[out]      event       An empty event object.
510 !  *
511 !  * @returns @c 1 if the function succeeded, @c 0 on error.
512 !  */
513
514 FUNCTION: bool
515 yaml_mapping_end_event_initialize ( yaml_event_t *event )
516
517 ! /**
518 !  * Free any memory allocated for an event object.
519 !  *
520 !  * @param[in,out]   event   An event object.
521 !  */
522
523 FUNCTION: void
524 yaml_event_delete ( yaml_event_t *event )
525 DESTRUCTOR: yaml_event_delete
526
527 ! /** @} */
528
529 ! /**
530 !  * @defgroup nodes Nodes
531 !  * @{
532 !  */
533
534 ! /** The tag @c !!null with the only possible value: @c null. */
535 CONSTANT:  YAML_NULL_TAG       "tag:yaml.org,2002:null"
536 ! /** The tag @c !!bool with the values: @c true and @c falce. */
537 CONSTANT:  YAML_BOOL_TAG       "tag:yaml.org,2002:bool"
538 ! /** The tag @c !!str for string values. */
539 CONSTANT:  YAML_STR_TAG        "tag:yaml.org,2002:str"
540 ! /** The tag @c !!int for integer values. */
541 CONSTANT:  YAML_INT_TAG        "tag:yaml.org,2002:int"
542 ! /** The tag @c !!float for float values. */
543 CONSTANT:  YAML_FLOAT_TAG      "tag:yaml.org,2002:float"
544 ! /** The tag @c !!timestamp for date and time values. */
545 CONSTANT:  YAML_TIMESTAMP_TAG  "tag:yaml.org,2002:timestamp"
546
547 ! /** The tag @c !!seq is used to denote sequences. */
548 CONSTANT:  YAML_SEQ_TAG        "tag:yaml.org,2002:seq"
549 ! /** The tag @c !!map is used to denote mapping. */
550 CONSTANT:  YAML_MAP_TAG        "tag:yaml.org,2002:map"
551
552 ! /** The default scalar tag is @c !!str. */
553 CONSTANT:  YAML_DEFAULT_SCALAR_TAG     $ YAML_STR_TAG
554 ! /** The default sequence tag is @c !!seq. */
555 CONSTANT:  YAML_DEFAULT_SEQUENCE_TAG   $ YAML_SEQ_TAG
556 ! /** The default mapping tag is @c !!map. */
557 CONSTANT:  YAML_DEFAULT_MAPPING_TAG    $ YAML_MAP_TAG
558
559 ! /** Node types. */
560 ENUM: yaml_node_type_t
561     YAML_NO_NODE
562
563     YAML_SCALAR_NODE
564     YAML_SEQUENCE_NODE
565     YAML_MAPPING_NODE
566 ;
567
568 ! /** The forward definition of a document node structure. */
569 ! typedef struct yaml_node_s yaml_node_t;
570
571 ! /** An element of a sequence node. */
572 TYPEDEF: int yaml_node_item_t
573
574 ! /** An element of a mapping node. */
575 STRUCT: yaml_node_pair_t
576     { key int }
577     { value int }
578 ;
579
580 ! /** The node structure. */
581         ! /** The scalar parameters (for @c YAML_SCALAR_NODE). */
582         STRUCT: scalar_node_data
583             { value c-string }
584             { length size_t }
585             { style yaml_scalar_style_t }
586         ;
587
588         ! /** The sequence parameters (for @c YAML_SEQUENCE_NODE). */
589             ! /** The stack of sequence items. */
590             STRUCT: sequence_node_data_items
591                 { start yaml_node_item_t* }
592                 { end yaml_node_item_t* }
593                 { top yaml_node_item_t* }
594             ;
595         STRUCT: sequence_node_data
596             { items sequence_node_data_items }
597             { style yaml_sequence_style_t }
598         ;
599
600         ! /** The mapping parameters (for @c YAML_MAPPING_NODE). */
601             ! /** The stack of mapping pairs (key, value). */
602             STRUCT: mapping_node_data_pairs
603                 { start yaml_node_pair_t* }
604                 { end yaml_node_pair_t* }
605                 { top yaml_node_pair_t* }
606             ;
607         STRUCT: mapping_node_data
608             { pairs mapping_node_data_pairs }
609             { style yaml_mapping_style_t }
610         ;
611   UNION-STRUCT: node_data
612     { scalar scalar_node_data }
613     { sequence sequence_node_data }
614     { mapping mapping_node_data }
615   ;
616
617 STRUCT: yaml_node_t
618
619     { type yaml_node_type_t }
620
621     { tag c-string }
622
623     { data node_data }
624
625     { start_mark yaml_mark_t }
626     { end_mark yaml_mark_t }
627
628 ;
629
630 ! /** The document structure. */
631     ! /** The document nodes. */
632     STRUCT: yaml_document_nodes
633         { start yaml_node_t* }
634         { end yaml_node_t* }
635         { top yaml_node_t* }
636     ;
637
638     ! /** The list of tag directives. */
639     STRUCT: yaml_document_tag_directives
640         { start yaml_tag_directive_t* }
641         { end yaml_tag_directive_t* }
642     ;
643
644 STRUCT: yaml_document_t
645
646     { nodes yaml_document_nodes }
647
648     { version_directive yaml_version_directive_t* }
649
650     { tag_directives yaml_document_tag_directives }
651
652     { start_implicit int }
653     { end_implicit int }
654
655     { start_mark yaml_mark_t }
656     { end_mark yaml_mark_t }
657
658 ;
659
660 ! /**
661 !  * Create a YAML document.
662 !  *
663 !  * @param[out]      document                An empty document object.
664 !  * @param[in]       version_directive       The %YAML directive value or
665 !  *                                          @c NULL.
666 !  * @param[in]       tag_directives_start    The beginning of the %TAG
667 !  *                                          directives list.
668 !  * @param[in]       tag_directives_end      The end of the %TAG directives
669 !  *                                          list.
670 !  * @param[in]       start_implicit          If the document start indicator is
671 !  *                                          implicit.
672 !  * @param[in]       end_implicit            If the document end indicator is
673 !  *                                          implicit.
674 !  *
675 !  * @returns @c 1 if the function succeeded, @c 0 on error.
676 !  */
677
678 FUNCTION: bool
679 yaml_document_initialize ( yaml_document_t *document,
680         yaml_version_directive_t *version_directive,
681         yaml_tag_directive_t *tag_directives_start,
682         yaml_tag_directive_t *tag_directives_end,
683         bool start_implicit, bool end_implicit )
684
685 ! /**
686 !  * Delete a YAML document and all its nodes.
687 !  *
688 !  * @param[in,out]   document        A document object.
689 !  */
690
691 FUNCTION: void
692 yaml_document_delete ( yaml_document_t *document )
693 DESTRUCTOR: yaml_document_delete
694
695 ! /**
696 !  * Get a node of a YAML document.
697 !  *
698 !  * The pointer returned by this function is valid until any of the functions
699 !  * modifying the documents are called.
700 !  *
701 !  * @param[in]       document        A document object.
702 !  * @param[in]       index           The node id.
703 !  *
704 !  * @returns the node objct or @c NULL if @c node_id is out of range.
705 !  */
706
707 FUNCTION: yaml_node_t*
708 yaml_document_get_node ( yaml_document_t *document, int index )
709
710 ! /**
711 !  * Get the root of a YAML document node.
712 !  *
713 !  * The root object is the first object added to the document.
714 !  *
715 !  * The pointer returned by this function is valid until any of the functions
716 !  * modifying the documents are called.
717 !  *
718 !  * An empty document produced by the parser signifies the end of a YAML
719 !  * stream.
720 !  *
721 !  * @param[in]       document        A document object.
722 !  *
723 !  * @returns the node object or @c NULL if the document is empty.
724 !  */
725
726 FUNCTION: yaml_node_t*
727 yaml_document_get_root_node ( yaml_document_t *document )
728
729 ! /**
730 !  * Create a SCALAR node and attach it to the document.
731 !  *
732 !  * The @a style argument may be ignored by the emitter.
733 !  *
734 !  * @param[in,out]   document        A document object.
735 !  * @param[in]       tag             The scalar tag.
736 !  * @param[in]       value           The scalar value.
737 !  * @param[in]       length          The length of the scalar value.
738 !  * @param[in]       style           The scalar style.
739 !  *
740 !  * @returns the node id or @c 0 on error.
741 !  */
742
743 FUNCTION: int
744 yaml_document_add_scalar ( yaml_document_t *document,
745         c-string tag, c-string value, int length,
746         yaml_scalar_style_t style )
747
748 ! /**
749 !  * Create a SEQUENCE node and attach it to the document.
750 !  *
751 !  * The @a style argument may be ignored by the emitter.
752 !  *
753 !  * @param[in,out]   document    A document object.
754 !  * @param[in]       tag         The sequence tag.
755 !  * @param[in]       style       The sequence style.
756 !  *
757 !  * @returns the node id or @c 0 on error.
758 !  */
759
760 FUNCTION: int
761 yaml_document_add_sequence ( yaml_document_t *document,
762         c-string tag, yaml_sequence_style_t style )
763
764 ! /**
765 !  * Create a MAPPING node and attach it to the document.
766 !  *
767 !  * The @a style argument may be ignored by the emitter.
768 !  *
769 !  * @param[in,out]   document    A document object.
770 !  * @param[in]       tag         The sequence tag.
771 !  * @param[in]       style       The sequence style.
772 !  *
773 !  * @returns the node id or @c 0 on error.
774 !  */
775
776 FUNCTION: int
777 yaml_document_add_mapping ( yaml_document_t *document,
778         c-string tag, yaml_mapping_style_t style )
779
780 ! /**
781 !  * Add an item to a SEQUENCE node.
782 !  *
783 !  * @param[in,out]   document    A document object.
784 !  * @param[in]       sequence    The sequence node id.
785 !  * @param[in]       item        The item node id.
786 ! *
787 !  * @returns @c 1 if the function succeeded, @c 0 on error.
788 !  */
789
790 FUNCTION: bool
791 yaml_document_append_sequence_item ( yaml_document_t *document,
792         int sequence, int item )
793
794 ! /**
795 !  * Add a pair of a key and a value to a MAPPING node.
796 !  *
797 !  * @param[in,out]   document    A document object.
798 !  * @param[in]       mapping     The mapping node id.
799 !  * @param[in]       key         The key node id.
800 !  * @param[in]       value       The value node id.
801 ! *
802 !  * @returns @c 1 if the function succeeded, @c 0 on error.
803 !  */
804
805 FUNCTION: bool
806 yaml_document_append_mapping_pair ( yaml_document_t *document,
807         int mapping, int key, int value )
808
809 ! /** @} */
810
811 ! /**
812 !  * @defgroup parser Parser Definitions
813 !  * @{
814 !  */
815
816 ! /**
817 !  * The prototype of a read handler.
818 !  *
819 !  * The read handler is called when the parser needs to read more bytes from the
820 !  * source.  The handler should write not more than @a size bytes to the @a
821 !  * buffer.  The number of written bytes should be set to the @a length variable.
822 !  *
823 !  * @param[in,out]   data        A pointer to an application data specified by
824 !  *                              yaml_parser_set_input().
825 !  * @param[out]      buffer      The buffer to write the data from the source.
826 !  * @param[in]       size        The size of the buffer.
827 !  * @param[out]      size_read   The actual number of bytes read from the source.
828 !  *
829 !  * @returns On success, the handler should return @c 1.  If the handler failed,
830 !  * the returned value should be @c 0.  On EOF, the handler should set the
831 !  * @a size_read to @c 0 and return @c 1.
832 !  */
833
834 CALLBACK: bool yaml_read_handler_t ( void *data,  uchar *buffer, size_t size,
835          size_t *size_read )
836
837 ! /**
838 !  * This structure holds information about a potential simple key.
839 !  */
840
841 STRUCT: yaml_simple_key_t
842     { possible int }
843
844     { required int }
845
846     { token_number size_t }
847
848     { mark yaml_mark_t }
849 ;
850
851 ! /**
852 !  * The states of the parser.
853 !  */
854 ENUM: yaml_parser_state_t
855     YAML_PARSE_STREAM_START_STATE
856     YAML_PARSE_IMPLICIT_DOCUMENT_START_STATE
857     YAML_PARSE_DOCUMENT_START_STATE
858     YAML_PARSE_DOCUMENT_CONTENT_STATE
859     YAML_PARSE_DOCUMENT_END_STATE
860     YAML_PARSE_BLOCK_NODE_STATE
861     YAML_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE
862     YAML_PARSE_FLOW_NODE_STATE
863     YAML_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE
864     YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE
865     YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE
866     YAML_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE
867     YAML_PARSE_BLOCK_MAPPING_KEY_STATE
868     YAML_PARSE_BLOCK_MAPPING_VALUE_STATE
869     YAML_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE
870     YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE
871     YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE
872     YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE
873     YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE
874     YAML_PARSE_FLOW_MAPPING_FIRST_KEY_STATE
875     YAML_PARSE_FLOW_MAPPING_KEY_STATE
876     YAML_PARSE_FLOW_MAPPING_VALUE_STATE
877     YAML_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE
878     YAML_PARSE_END_STATE
879 ;
880
881 ! /**
882 !  * This structure holds aliases data.
883 !  */
884
885 STRUCT: yaml_alias_data_t
886     { anchor c-string }
887     { index int }
888     { mark yaml_mark_t }
889 ;
890
891 ! /**
892 !  * The parser structure.
893 !  *
894 !  * All members are internal.  Manage the structure using the @c yaml_parser_
895 !  * family of functions.
896 !  */
897
898     ! /** Standard (string or file) input data. */
899         ! /** String input data. */
900         STRUCT: string_yaml_parser_input
901             { start uchar* }
902             { end uchar* }
903             { current uchar* }
904         ;
905     UNION-STRUCT: yaml_parser_input
906         { string string_yaml_parser_input }
907         { file FILE* }
908     ;
909
910     ! /** The working buffer. */
911     STRUCT: yaml_parser_buffer
912         { start yaml_char_t* }
913         { end yaml_char_t* }
914         { pointer yaml_char_t* }
915         { last yaml_char_t* }
916     ;
917
918     ! /** The raw buffer. */
919     STRUCT: yaml_parser_raw_buffer
920         { start uchar* }
921         { end uchar* }
922         { pointer uchar* }
923         { last uchar* }
924     ;
925
926     ! /** The tokens queue. */
927     STRUCT: yaml_parser_tokens
928         { start yaml_token_t* }
929         { end yaml_token_t* }
930         { head yaml_token_t* }
931         { tail yaml_token_t* }
932     ;
933
934     ! /** The indentation levels stack. */
935     STRUCT: yaml_parser_indents
936         { start int* }
937         { end int* }
938         { top int* }
939     ;
940
941     ! /** The stack of simple keys. */
942     STRUCT: yaml_parser_simple_keys
943         { start yaml_simple_key_t* }
944         { end yaml_simple_key_t* }
945         { top yaml_simple_key_t* }
946     ;
947
948     ! /** The parser states stack. */
949     STRUCT: yaml_parser_states
950         { start yaml_parser_state_t* }
951         { end yaml_parser_state_t* }
952         { top yaml_parser_state_t* }
953     ;
954
955     ! /** The stack of marks. */
956     STRUCT: yaml_parser_marks
957         { start yaml_mark_t* }
958         { end yaml_mark_t* }
959         { top yaml_mark_t* }
960     ;
961
962     ! /** The list of TAG directives. */
963     STRUCT: yaml_parser_tag_directives
964         { start yaml_tag_directive_t* }
965         { end yaml_tag_directive_t* }
966         { top yaml_tag_directive_t* }
967     ;
968
969     ! /** The alias data. */
970     STRUCT: yaml_parser_aliases
971         { start yaml_alias_data_t* }
972         { end yaml_alias_data_t* }
973         { top yaml_alias_data_t* }
974     ;
975 STRUCT: yaml_parser_t
976
977     { error yaml_error_type_t }
978     { problem c-string }
979     { problem_offset size_t }
980     { problem_value int }
981     { problem_mark yaml_mark_t }
982     { context c-string }
983     { context_mark yaml_mark_t }
984
985     { read_handler yaml_read_handler_t* }
986
987     { read_handler_data void* }
988
989     { input yaml_parser_input }
990
991     { eof int }
992
993     { buffer yaml_parser_buffer }
994
995     { unread size_t }
996
997     { raw_buffer yaml_parser_raw_buffer }
998
999     { encoding yaml_encoding_t }
1000
1001     { offset size_t }
1002
1003     { mark yaml_mark_t }
1004
1005     { stream_start_produced int }
1006
1007     { stream_end_produced int }
1008
1009     { flow_level int }
1010
1011     { tokens yaml_parser_tokens }
1012
1013     { tokens_parsed size_t }
1014
1015     { token_available int }
1016
1017     { indents yaml_parser_indents }
1018
1019     { indent int }
1020
1021     { simple_key_allowed int }
1022
1023     { simple_keys yaml_parser_simple_keys }
1024
1025     { states yaml_parser_states }
1026
1027     { state yaml_parser_state_t }
1028
1029     { marks yaml_parser_marks }
1030
1031     { tag_directives yaml_parser_tag_directives }
1032
1033     { aliases yaml_parser_aliases }
1034
1035     { document yaml_document_t* }
1036 ;
1037
1038 ! /**
1039 !  * Initialize a parser.
1040 !  *
1041 !  * This function creates a new parser object.  An application is responsible
1042 !  * for destroying the object using the yaml_parser_delete() function.
1043 !  *
1044 !  * @param[out]      parser  An empty parser object.
1045 !  *
1046 !  * @returns @c 1 if the function succeeded, @c 0 on error.
1047 !  */
1048
1049 FUNCTION: bool
1050 yaml_parser_initialize ( yaml_parser_t *parser )
1051
1052 ! /**
1053 !  * Destroy a parser.
1054 !  *
1055 !  * @param[in,out]   parser  A parser object.
1056 !  */
1057
1058 FUNCTION: void
1059 yaml_parser_delete ( yaml_parser_t *parser )
1060 DESTRUCTOR: yaml_parser_delete
1061
1062 ! /**
1063 !  * Set a string input.
1064 !  *
1065 !  * Note that the @a input pointer must be valid while the @a parser object
1066 !  * exists.  The application is responsible for destroing @a input after
1067 !  * destroying the @a parser.
1068 !  *
1069 !  * @param[in,out]   parser  A parser object.
1070 !  * @param[in]       input   A source data.
1071 !  * @param[in]       size    The length of the source data in bytes.
1072 !  */
1073
1074 FUNCTION: void
1075 yaml_parser_set_input_string ( yaml_parser_t *parser,
1076         uchar *input, size_t size )
1077
1078 ! /**
1079 !  * Set a file input.
1080 !  *
1081 !  * @a file should be a file object open for reading.  The application is
1082 !  * responsible for closing the @a file.
1083 !  *
1084 !  * @param[in,out]   parser  A parser object.
1085 !  * @param[in]       file    An open file.
1086 !  */
1087
1088 FUNCTION: void
1089 yaml_parser_set_input_file ( yaml_parser_t *parser, FILE *file )
1090
1091 ! /**
1092 !  * Set a generic input handler.
1093 !  *
1094 !  * @param[in,out]   parser  A parser object.
1095 !  * @param[in]       handler A read handler.
1096 !  * @param[in]       data    Any application data for passing to the read
1097 !  *                          handler.
1098 !  */
1099
1100 FUNCTION: void
1101 yaml_parser_set_input ( yaml_parser_t *parser,
1102         yaml_read_handler_t *handler, void *data )
1103
1104 ! /**
1105 !  * Set the source encoding.
1106 !  *
1107 !  * @param[in,out]   parser      A parser object.
1108 !  * @param[in]       encoding    The source encoding.
1109 !  */
1110
1111 FUNCTION: void
1112 yaml_parser_set_encoding ( yaml_parser_t *parser, yaml_encoding_t encoding )
1113
1114 ! /**
1115 !  * Scan the input stream and produce the next token.
1116 !  *
1117 !  * Call the function subsequently to produce a sequence of tokens corresponding
1118 !  * to the input stream.  The initial token has the type
1119 !  * @c YAML_STREAM_START_TOKEN while the ending token has the type
1120 !  * @c YAML_STREAM_END_TOKEN.
1121 !  *
1122 !  * An application is responsible for freeing any buffers associated with the
1123 !  * produced token object using the @c yaml_token_delete function.
1124 !  *
1125 !  * An application must not alternate the calls of yaml_parser_scan() with the
1126 !  * calls of yaml_parser_parse() or yaml_parser_load(). Doing this will break
1127 !  * the parser.
1128 !  *
1129 !  * @param[in,out]   parser      A parser object.
1130 !  * @param[out]      token       An empty token object.
1131 !  *
1132 !  * @returns @c 1 if the function succeeded, @c 0 on error.
1133 !  */
1134
1135 FUNCTION: bool
1136 yaml_parser_scan ( yaml_parser_t *parser, yaml_token_t *token )
1137
1138 ! /**
1139 !  * Parse the input stream and produce the next parsing event.
1140 !  *
1141 !  * Call the function subsequently to produce a sequence of events corresponding
1142 !  * to the input stream.  The initial event has the type
1143 !  * @c YAML_STREAM_START_EVENT while the ending event has the type
1144 !  * @c YAML_STREAM_END_EVENT.
1145 !  *
1146 !  * An application is responsible for freeing any buffers associated with the
1147 !  * produced event object using the yaml_event_delete() function.
1148 !  *
1149 !  * An application must not alternate the calls of yaml_parser_parse() with the
1150 !  * calls of yaml_parser_scan() or yaml_parser_load(). Doing this will break the
1151 !  * parser.
1152 !  *
1153 !  * @param[in,out]   parser      A parser object.
1154 !  * @param[out]      event       An empty event object.
1155 !  *
1156 !  * @returns @c 1 if the function succeeded, @c 0 on error.
1157 !  */
1158
1159 FUNCTION: bool
1160 yaml_parser_parse ( yaml_parser_t *parser, yaml_event_t *event )
1161
1162 ! /**
1163 !  * Parse the input stream and produce the next YAML document.
1164 !  *
1165 !  * Call this function subsequently to produce a sequence of documents
1166 !  * constituting the input stream.
1167 !  *
1168 !  * If the produced document has no root node, it means that the document
1169 !  * end has been reached.
1170 !  *
1171 !  * An application is responsible for freeing any data associated with the
1172 !  * produced document object using the yaml_document_delete() function.
1173 !  *
1174 !  * An application must not alternate the calls of yaml_parser_load() with the
1175 !  * calls of yaml_parser_scan() or yaml_parser_parse(). Doing this will break
1176 !  * the parser.
1177 !  *
1178 !  * @param[in,out]   parser      A parser object.
1179 !  * @param[out]      document    An empty document object.
1180 !  *
1181 !  * @return @c 1 if the function succeeded, @c 0 on error.
1182 !  */
1183
1184 FUNCTION: bool
1185 yaml_parser_load ( yaml_parser_t *parser, yaml_document_t *document )
1186
1187 ! /** @} */
1188
1189 ! /**
1190 !  * @defgroup emitter Emitter Definitions
1191 !  * @{
1192 !  */
1193
1194 ! /**
1195 !  * The prototype of a write handler.
1196 !  *
1197 !  * The write handler is called when the emitter needs to flush the accumulated
1198 !  * characters to the output.  The handler should write @a size bytes of the
1199 !  * @a buffer to the output.
1200 !  *
1201 !  * @param[in,out]   data        A pointer to an application data specified by
1202 !  *                              yaml_emitter_set_output().
1203 !  * @param[in]       buffer      The buffer with bytes to be written.
1204 !  * @param[in]       size        The size of the buffer.
1205 !  *
1206 !  * @returns On success, the handler should return @c 1.  If the handler failed,
1207 !  * the returned value should be @c 0.
1208 !  */
1209
1210 CALLBACK: bool yaml_write_handler_t ( void *data, uchar *buffer, size_t size )
1211
1212 ! /** The emitter states. */
1213 ENUM: yaml_emitter_state_t
1214     YAML_EMIT_STREAM_START_STATE
1215     YAML_EMIT_FIRST_DOCUMENT_START_STATE
1216     YAML_EMIT_DOCUMENT_START_STATE
1217     YAML_EMIT_DOCUMENT_CONTENT_STATE
1218     YAML_EMIT_DOCUMENT_END_STATE
1219     YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE
1220     YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE
1221     YAML_EMIT_FLOW_MAPPING_FIRST_KEY_STATE
1222     YAML_EMIT_FLOW_MAPPING_KEY_STATE
1223     YAML_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE
1224     YAML_EMIT_FLOW_MAPPING_VALUE_STATE
1225     YAML_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE
1226     YAML_EMIT_BLOCK_SEQUENCE_ITEM_STATE
1227     YAML_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE
1228     YAML_EMIT_BLOCK_MAPPING_KEY_STATE
1229     YAML_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE
1230     YAML_EMIT_BLOCK_MAPPING_VALUE_STATE
1231     YAML_EMIT_END_STATE
1232 ;
1233
1234 ! /**
1235 !  * The emitter structure.
1236 !  *
1237 !  * All members are internal.  Manage the structure using the @c yaml_emitter_
1238 !  * family of functions.
1239 !  */
1240
1241     ! /** Standard (string or file) output data. */
1242         ! /** String output data. */
1243         STRUCT: yaml_emitter_output_string
1244             { buffer uchar* }
1245             { size size_t }
1246             { size_written size_t* }
1247         ;
1248
1249     UNION-STRUCT: yaml_emitter_output
1250         { string yaml_emitter_output_string }
1251
1252         { file FILE* }
1253     ;
1254
1255     ! /** The working buffer. */
1256     STRUCT: yaml_emitter_buffer
1257         { start yaml_char_t* }
1258         { end yaml_char_t* }
1259         { pointer yaml_char_t* }
1260         { last yaml_char_t* }
1261     ;
1262
1263     ! /** The raw buffer. */
1264     STRUCT: yaml_emitter_raw_buffer
1265         { start uchar* }
1266         { end uchar* }
1267         { pointer uchar* }
1268         { last uchar* }
1269     ;
1270
1271     ! /** The stack of states. */
1272     STRUCT: yaml_emitter_states
1273         { start yaml_emitter_state_t* }
1274         { end yaml_emitter_state_t* }
1275         { top yaml_emitter_state_t* }
1276     ;
1277
1278     ! /** The event queue. */
1279     STRUCT: yaml_emitter_events
1280         { start yaml_event_t* }
1281         { end yaml_event_t* }
1282         { head yaml_event_t* }
1283         { tail yaml_event_t* }
1284     ;
1285
1286     ! /** The stack of indentation levels. */
1287     STRUCT: yaml_emitter_indents
1288         { start int* }
1289         { end int* }
1290         { top int* }
1291     ;
1292
1293     ! /** The list of tag directives. */
1294     STRUCT: yaml_emitter_tag_directives
1295         { start yaml_tag_directive_t* }
1296         { end yaml_tag_directive_t* }
1297         { top yaml_tag_directive_t* }
1298     ;
1299
1300     ! /** Anchor analysis. */
1301     STRUCT: yaml_emitter_anchor_data
1302         { anchor c-string }
1303         { anchor_length size_t }
1304         { alias int }
1305     ;
1306
1307     ! /** Tag analysis. */
1308     STRUCT: yaml_emitter_tag_data
1309         { handle c-string }
1310         { handle_length size_t }
1311         { suffix c-string }
1312         { suffix_length size_t }
1313     ;
1314
1315     ! /** Scalar analysis. */
1316     STRUCT: yaml_emitter_scalar_data
1317         { value c-string }
1318         { length size_t }
1319         { multiline int }
1320         { flow_plain_allowed int }
1321         { block_plain_allowed int }
1322         { single_quoted_allowed int }
1323         { block_allowed int }
1324         { style yaml_scalar_style_t }
1325     ;
1326
1327     ! /** The information associated with the document nodes. */
1328     STRUCT: yaml_emitter_anchors
1329         { references int }
1330         { anchor int }
1331         { serialized int }
1332     ;
1333 STRUCT: yaml_emitter_t
1334
1335     { error yaml_error_type_t }
1336     { problem c-string }
1337
1338     { write_handler yaml_write_handler_t* }
1339
1340     { write_handler_data void* }
1341
1342     { output yaml_emitter_output }
1343
1344     { buffer yaml_emitter_buffer }
1345
1346     { raw_buffer yaml_emitter_raw_buffer }
1347
1348     { encoding yaml_encoding_t }
1349
1350     { canonical int }
1351     { best_indent int }
1352     { best_width int }
1353     { unicode int }
1354     { line_break yaml_break_t }
1355
1356     { states yaml_emitter_states }
1357     { state yaml_emitter_state_t }
1358
1359     { events yaml_emitter_events }
1360
1361     { indents yaml_emitter_indents }
1362
1363     { tag_directives yaml_emitter_tag_directives }
1364
1365     { indent int }
1366
1367     { flow_level int }
1368
1369     { root_context int }
1370     { sequence_context int }
1371     { mapping_context int }
1372     { simple_key_context int }
1373
1374     { line int }
1375     { column int }
1376     { whitespace int }
1377     { indention int }
1378     { open_ended int }
1379
1380     { anchor_data yaml_emitter_anchor_data }
1381
1382     { tag_data yaml_emitter_tag_data }
1383
1384     { scalar_data yaml_emitter_scalar_data }
1385
1386     { opened int }
1387     { closed int }
1388
1389     { anchors yaml_emitter_anchors* }
1390
1391     { last_anchor_id int }
1392
1393     { document yaml_document_t* }
1394
1395 ;
1396
1397 ! /**
1398 !  * Initialize an emitter.
1399 !  *
1400 !  * This function creates a new emitter object.  An application is responsible
1401 !  * for destroying the object using the yaml_emitter_delete() function.
1402 !  *
1403 !  * @param[out]      emitter     An empty parser object.
1404 !  *
1405 !  * @returns @c 1 if the function succeeded, @c 0 on error.
1406 !  */
1407
1408 FUNCTION: bool
1409 yaml_emitter_initialize ( yaml_emitter_t *emitter )
1410
1411 ! /**
1412 !  * Destroy an emitter.
1413 !  *
1414 !  * @param[in,out]   emitter     An emitter object.
1415 !  */
1416
1417 FUNCTION: void
1418 yaml_emitter_delete ( yaml_emitter_t *emitter )
1419 DESTRUCTOR: yaml_emitter_delete
1420
1421 ! /**
1422 !  * Set a string output.
1423 !  *
1424 !  * The emitter will write the output characters to the @a output buffer of the
1425 !  * size @a size.  The emitter will set @a size_written to the number of written
1426 !  * bytes.  If the buffer is smaller than required, the emitter produces the
1427 !  * YAML_WRITE_ERROR error.
1428 !  *
1429 !  * @param[in,out]   emitter         An emitter object.
1430 !  * @param[in]       output          An output buffer.
1431 !  * @param[in]       size            The buffer size.
1432 !  * @param[in]       size_written    The pointer to save the number of written
1433 !  *                                  bytes.
1434 !  */
1435
1436 FUNCTION: void
1437 yaml_emitter_set_output_string ( yaml_emitter_t *emitter,
1438         uchar *output, size_t size, size_t *size_written )
1439
1440 ! /**
1441 !  * Set a file output.
1442 !  *
1443 !  * @a file should be a file object open for writing.  The application is
1444 !  * responsible for closing the @a file.
1445 !  *
1446 !  * @param[in,out]   emitter     An emitter object.
1447 !  * @param[in]       file        An open file.
1448 !  */
1449
1450 FUNCTION: void
1451 yaml_emitter_set_output_file ( yaml_emitter_t *emitter, FILE *file )
1452
1453 ! /**
1454 !  * Set a generic output handler.
1455 !  *
1456 !  * @param[in,out]   emitter     An emitter object.
1457 !  * @param[in]       handler     A write handler.
1458 !  * @param[in]       data        Any application data for passing to the write
1459 !  *                              handler.
1460 !  */
1461
1462 FUNCTION: void
1463 yaml_emitter_set_output ( yaml_emitter_t *emitter,
1464         yaml_write_handler_t *handler, void *data )
1465
1466 ! /**
1467 !  * Set the output encoding.
1468 !  *
1469 !  * @param[in,out]   emitter     An emitter object.
1470 !  * @param[in]       encoding    The output encoding.
1471 !  */
1472
1473 FUNCTION: void
1474 yaml_emitter_set_encoding ( yaml_emitter_t *emitter, yaml_encoding_t encoding )
1475
1476 ! /**
1477 !  * Set if the output should be in the "canonical" format as in the YAML
1478 !  * specification.
1479 !  *
1480 !  * @param[in,out]   emitter     An emitter object.
1481 !  * @param[in]       canonical   If the output is canonical.
1482 !  */
1483
1484 FUNCTION: void
1485 yaml_emitter_set_canonical ( yaml_emitter_t *emitter, bool canonical )
1486
1487 ! /**
1488 !  * Set the intendation increment.
1489 !  *
1490 !  * @param[in,out]   emitter     An emitter object.
1491 !  * @param[in]       indent      The indentation increment (1 < . < 10).
1492 !  */
1493
1494 FUNCTION: void
1495 yaml_emitter_set_indent ( yaml_emitter_t *emitter, int indent )
1496
1497 ! /**
1498 !  * Set the preferred line width. @c -1 means unlimited.
1499 !  *
1500 !  * @param[in,out]   emitter     An emitter object.
1501 !  * @param[in]       width       The preferred line width.
1502 !  */
1503
1504 FUNCTION: void
1505 yaml_emitter_set_width ( yaml_emitter_t *emitter, int width )
1506
1507 ! /**
1508 !  * Set if unescaped non-ASCII characters are allowed.
1509 !  *
1510 !  * @param[in,out]   emitter     An emitter object.
1511 !  * @param[in]       unicode     If unescaped Unicode characters are allowed.
1512 !  */
1513
1514 FUNCTION: void
1515 yaml_emitter_set_unicode ( yaml_emitter_t *emitter, bool unicode )
1516
1517 ! /**
1518 !  * Set the preferred line break.
1519 !  *
1520 !  * @param[in,out]   emitter     An emitter object.
1521 !  * @param[in]       line_break  The preferred line break.
1522 !  */
1523
1524 FUNCTION: void
1525 yaml_emitter_set_break ( yaml_emitter_t *emitter, yaml_break_t line_break )
1526
1527 ! /**
1528 !  * Emit an event.
1529 !  *
1530 !  * The event object may be generated using the yaml_parser_parse() function.
1531 !  * The emitter takes the responsibility for the event object and destroys its
1532 !  * content after it is emitted. The event object is destroyed even if the
1533 !  * function fails.
1534 !  *
1535 !  * @param[in,out]   emitter     An emitter object.
1536 !  * @param[in,out]   event       An event object.
1537 !  *
1538 !  * @returns @c 1 if the function succeeded, @c 0 on error.
1539 !  */
1540
1541 FUNCTION: bool
1542 yaml_emitter_emit ( yaml_emitter_t *emitter, yaml_event_t *event )
1543
1544 ! /**
1545 !  * Start a YAML stream.
1546 !  *
1547 !  * This function should be used before yaml_emitter_dump() is called.
1548 !  *
1549 !  * @param[in,out]   emitter     An emitter object.
1550 !  *
1551 !  * @returns @c 1 if the function succeeded, @c 0 on error.
1552 !  */
1553
1554 FUNCTION: bool
1555 yaml_emitter_open ( yaml_emitter_t *emitter )
1556
1557 ! /**
1558 !  * Finish a YAML stream.
1559 !  *
1560 !  * This function should be used after yaml_emitter_dump() is called.
1561 !  *
1562 !  * @param[in,out]   emitter     An emitter object.
1563 !  *
1564 !  * @returns @c 1 if the function succeeded, @c 0 on error.
1565 !  */
1566
1567 FUNCTION: bool
1568 yaml_emitter_close ( yaml_emitter_t *emitter )
1569
1570 ! /**
1571 !  * Emit a YAML document.
1572 !  *
1573 !  * The documen object may be generated using the yaml_parser_load() function
1574 !  * or the yaml_document_initialize() function.  The emitter takes the
1575 !  * responsibility for the document object and destoys its content after
1576 !  * it is emitted. The document object is destroyedeven if the function fails.
1577 !  *
1578 !  * @param[in,out]   emitter     An emitter object.
1579 !  * @param[in,out]   document    A document object.
1580 !  *
1581 !  * @returns @c 1 if the function succeeded, @c 0 on error.
1582 !  */
1583
1584 FUNCTION: bool
1585 yaml_emitter_dump ( yaml_emitter_t *emitter, yaml_document_t *document )
1586
1587 ! /**
1588 !  * Flush the accumulated characters to the output.
1589 !  *
1590 !  * @param[in,out]   emitter     An emitter object.
1591 !  *
1592 !  * @returns @c 1 if the function succeeded, @c 0 on error.
1593 !  */
1594
1595 FUNCTION: bool
1596 yaml_emitter_flush ( yaml_emitter_t *emitter )
1597
1598 ! /** @} */
1599
1600 ! #ifdef __cplusplus
1601 ! }
1602 ! #endif
1603
1604 ! #endif /* #ifndef YAML_H */