Changes between Version 9 and Version 10 of LibYAML


Ignore:
Timestamp:
07/19/06 14:09:56 (8 years ago)
Author:
xi
Comment:

Update the API synopsis.

Legend:

Unmodified
Added
Removed
Modified
  • LibYAML

    v9 v10  
    9999   * `encoding` - the document encoding; `utf-8|utf-16-le|utf-16-be`. 
    100100 * `DOCUMENT-START` 
    101    * `version` - the version specified with the `%YAML` directive; the only valid value is `1.1`; may be `NULL`. 
    102    * `tag` - a set of tag handles and the corresponding tag prefixes specified with the `%TAG` directive; 
     101   * `version_directive` - the version specified with the `%YAML` directive; the only valid value is `1.1`; may be `NULL`. 
     102   * `tag_directives` - a set of tag handles and the corresponding tag prefixes specified with the `%TAG` directive; 
    103103     tag handles should match `!|!!|![0-9a-zA-Z_-]+!` while tag prefixes should be prefixes of valid local 
    104104     or global tags; may be `NULL`. 
     
    127127{{{ 
    128128#!c 
    129 #include <yaml/yaml.h> 
    130  
    131 yaml_parser_t *parser; 
    132 yaml_event_t *event; 
     129#include <yaml.h> 
     130 
     131yaml_parser_t parser; 
     132yaml_event_t event; 
    133133 
    134134/* Create the Parser object. */ 
    135 parser = yaml_parser_new(); 
     135yaml_parser_initialize(&parser); 
    136136 
    137137/* Set a string input. */ 
     
    139139size_t length = strlen(input); 
    140140 
    141 yaml_parser_set_string_input(parser, input, length); 
     141yaml_parser_set_string_input(&parser, input, length); 
    142142 
    143143/* Set a file input. */ 
    144144FILE *input = fopen("...", "rb"); 
    145145 
    146 yaml_parser_set_file_input(parser, input); 
     146yaml_parser_set_file_input(&parser, input); 
    147147 
    148148/* Set a generic reader. */ 
     
    156156} 
    157157 
    158 yaml_parser_set_input(parser, read_handler, ext); 
     158yaml_parser_set_input(&parser, read_handler, ext); 
    159159 
    160160/* Read the event sequence. */ 
    161161do { 
     162    int result; 
     163 
    162164    /* Get the next event. */ 
    163     event = yaml_parser_parse(parser); 
    164  
    165     if (!event) goto error; 
     165    result = yaml_parser_parse(&parser, &event); 
     166 
     167    if (!result) goto error; 
    166168 
    167169    /* 
     
    171173    */ 
    172174 
    173     /* The application is responsible for destroing the event object. */ 
    174     yaml_event_delete(event); 
    175  
    176 } while(event->type != YAML_STREAM_END_EVENT); 
     175    /* The application is responsible for destroying the event object. */ 
     176    yaml_event_delete(&event); 
     177 
     178} while(event.type != YAML_STREAM_END_EVENT); 
    177179 
    178180/* Destroy the Parser object. */ 
    179 yaml_parser_delete(parser); 
     181yaml_parser_delete(&parser); 
    180182 
    181183/* On error. */ 
    182 error: 
     184error: /* FIXME */ 
    183185 
    184186/* Error type: YAML_READER_ERROR, YAML_SCANNER_ERROR, YAML_PARSER_ERROR. */ 
     
    214216{{{ 
    215217#!c 
    216 #include <yaml/yaml.h> 
    217  
    218 yaml_emitter_t *emitter; 
    219 yaml_event_t *event; 
     218#include <yaml.h> 
     219 
     220yaml_emitter_t emitter; 
    220221 
    221222/* Create the Emitter object. */ 
    222 emitter = yaml_emitter_new(); 
     223yaml_emitter_initialize(&emitter); 
    223224 
    224225/* Set a file output. */ 
    225226FILE *output = fopen("...", "wb"); 
    226227 
    227 yaml_emitter_set_file_output(emitter, output); 
     228yaml_emitter_set_file_output(&emitter, output); 
    228229 
    229230/* Set a generic writer. */ 
     
    238239} 
    239240 
    240 yaml_emitter_set_output(emitter, write_handler, ext); 
    241  
    242 /* Create the STREAM-START event. */ 
    243 event = yaml_event_new_stream_start(YAML_UTF8_ENCODING); 
    244  
    245 /* Emit the event. The application is no longer responsible for the event object. */ 
    246 int result = yaml_emitter_emit(emitter, event); 
     241yaml_emitter_set_output(&emitter, write_handler, ext); 
     242 
     243/* Emit the STREAM-START event. */ 
     244int result = yaml_emitter_emit_stream_start(&emitter, YAML_UTF8_ENCODING); 
    247245 
    248246if (!result) goto error; 
     
    254252*/ 
    255253 
    256 /* Create and emit the STREAM-END event. */ 
    257 if (!yaml_emitter_emit(emitter, yaml_event_new_event_end())) goto error; 
     254/* EMIT the STREAM-END event. */ 
     255if (!yaml_emitter_emit_stream_end(&emitter) goto error; 
    258256 
    259257/* Destroy the Emitter object. */ 
    260 yaml_emitter_delete(emitter); 
     258yaml_emitter_delete(&emitter); 
    261259 
    262260/* On error. */ 
    263 error: 
     261error: /* FIXME */ 
    264262 
    265263/* Error type: YAML_WRITER_ERROR, YAML_EMITTER_ERROR. */