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