Changes between Version 9 and Version 10 of LibYAML
- Timestamp:
- 07/19/06 14:09:56 (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
LibYAML
v9 v10 99 99 * `encoding` - the document encoding; `utf-8|utf-16-le|utf-16-be`. 100 100 * `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; 103 103 tag handles should match `!|!!|![0-9a-zA-Z_-]+!` while tag prefixes should be prefixes of valid local 104 104 or global tags; may be `NULL`. … … 127 127 {{{ 128 128 #!c 129 #include <yaml /yaml.h>130 131 yaml_parser_t *parser;132 yaml_event_t *event;129 #include <yaml.h> 130 131 yaml_parser_t parser; 132 yaml_event_t event; 133 133 134 134 /* Create the Parser object. */ 135 parser = yaml_parser_new();135 yaml_parser_initialize(&parser); 136 136 137 137 /* Set a string input. */ … … 139 139 size_t length = strlen(input); 140 140 141 yaml_parser_set_string_input( parser, input, length);141 yaml_parser_set_string_input(&parser, input, length); 142 142 143 143 /* Set a file input. */ 144 144 FILE *input = fopen("...", "rb"); 145 145 146 yaml_parser_set_file_input( parser, input);146 yaml_parser_set_file_input(&parser, input); 147 147 148 148 /* Set a generic reader. */ … … 156 156 } 157 157 158 yaml_parser_set_input( parser, read_handler, ext);158 yaml_parser_set_input(&parser, read_handler, ext); 159 159 160 160 /* Read the event sequence. */ 161 161 do { 162 int result; 163 162 164 /* 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; 166 168 167 169 /* … … 171 173 */ 172 174 173 /* The application is responsible for destro ing 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); 177 179 178 180 /* Destroy the Parser object. */ 179 yaml_parser_delete( parser);181 yaml_parser_delete(&parser); 180 182 181 183 /* On error. */ 182 error: 184 error: /* FIXME */ 183 185 184 186 /* Error type: YAML_READER_ERROR, YAML_SCANNER_ERROR, YAML_PARSER_ERROR. */ … … 214 216 {{{ 215 217 #!c 216 #include <yaml/yaml.h> 217 218 yaml_emitter_t *emitter; 219 yaml_event_t *event; 218 #include <yaml.h> 219 220 yaml_emitter_t emitter; 220 221 221 222 /* Create the Emitter object. */ 222 emitter = yaml_emitter_new();223 yaml_emitter_initialize(&emitter); 223 224 224 225 /* Set a file output. */ 225 226 FILE *output = fopen("...", "wb"); 226 227 227 yaml_emitter_set_file_output( emitter, output);228 yaml_emitter_set_file_output(&emitter, output); 228 229 229 230 /* Set a generic writer. */ … … 238 239 } 239 240 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); 241 yaml_emitter_set_output(&emitter, write_handler, ext); 242 243 /* Emit the STREAM-START event. */ 244 int result = yaml_emitter_emit_stream_start(&emitter, YAML_UTF8_ENCODING); 247 245 248 246 if (!result) goto error; … … 254 252 */ 255 253 256 /* Create and emitthe STREAM-END event. */257 if (!yaml_emitter_emit (emitter, yaml_event_new_event_end())) goto error;254 /* EMIT the STREAM-END event. */ 255 if (!yaml_emitter_emit_stream_end(&emitter) goto error; 258 256 259 257 /* Destroy the Emitter object. */ 260 yaml_emitter_delete( emitter);258 yaml_emitter_delete(&emitter); 261 259 262 260 /* On error. */ 263 error: 261 error: /* FIXME */ 264 262 265 263 /* Error type: YAML_WRITER_ERROR, YAML_EMITTER_ERROR. */
