Changes between Version 3 and Version 4 of LibYAML


Ignore:
Timestamp:
05/16/06 14:32:30 (9 years ago)
Author:
xi
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • LibYAML

    v3 v4  
    22 
    33LibYAML is a YAML 1.1 parser and emitter written in C. It's in an early stage of development. 
     4 
     5You may leave your remarks here at the end of the page or post your comments to 
     6[http://lists.sourceforge.net/lists/listinfo/yaml-core the YAML-core mailing list]. 
    47 
    58[[PageOutline]] 
     
    147150do { 
    148151    /* Get the next event. */ 
    149     event = yaml_parser_get_event(parser); 
     152    event = yaml_parser_parse(parser); 
    150153 
    151154    if (!event) goto error; 
     
    184187 
    185188/* Get the error data. */ 
    186 yaml_parser_get_error(&error, &context, &context_mark, &problem, &problem_mark); 
     189yaml_parser_get_error(parser, &error, &context, &context_mark, &problem, &problem_mark); 
    187190 
    188191/* 
     
    195198yaml_parser_delete(parser); 
    196199}}} 
     200 
     201=== Emitter API Synopsis === 
     202 
     203{{{ 
     204#!c 
     205#include <yaml.h> 
     206 
     207yaml_emitter_t *emitter; 
     208yaml_event_t *event; 
     209 
     210/* Create the Emitter object. */ 
     211emitter = yaml_emitter_new(); 
     212 
     213/* Set a file output. */ 
     214FILE *output = fopen("...", "wb"); 
     215 
     216yaml_emitter_set_file_output(emitter, output); 
     217 
     218/* Set a generic writer. */ 
     219void *ext = ...; 
     220int write_handler(void *ext, char *buffer, int size) { 
     221    /* 
     222       ... 
     223       Write `size` bytes. 
     224       ... 
     225    */ 
     226    return error ? 0 : 1; 
     227} 
     228 
     229yaml_emitter_set_output(emitter, write_handler, ext); 
     230 
     231/* Create the STREAM-START event. */ 
     232event = yaml_event_new_stream_start(YAML_UTF8_ENCODING); 
     233 
     234/* Emit the event. The application is no longer responsible for the event object. */ 
     235int result = yaml_emitter_emit(emitter, event); 
     236 
     237if (!result) goto error; 
     238 
     239/* 
     240  ... 
     241  Emit more events. 
     242  ... 
     243*/ 
     244 
     245/* Create and emit the STREAM-END event. */ 
     246if (!yaml_emitter_emit(emitter, yaml_event_new_event_end())) goto error; 
     247 
     248/* Destroy the Emitter object. */ 
     249yaml_emitter_delete(emitter); 
     250 
     251/* On error. */ 
     252error: 
     253 
     254/* Error type: YAML_WRITER_ERROR, YAML_EMITTER_ERROR. */ 
     255yaml_error_t error; 
     256 
     257/* The problem description. */ 
     258char *problem; 
     259 
     260/* Get the error data. */ 
     261yaml_emitter_get_error(emitter, &error, &problem); 
     262 
     263/* 
     264  ... 
     265  Report the problem to the user. 
     266  ... 
     267*/ 
     268 
     269/* Destroy the Emitter object. */ 
     270yaml_emitter_delete(emitter); 
     271}}} 
     272 
     273== Feedback == 
     274 
     275''Leave your comments here.''