Lines Matching full:emitter
78 /* Internal convenience function. Write to the emitter the given string. */
81 emitter_printf(emitter_t *emitter, const char *format, ...) { in emitter_printf() argument
85 malloc_vcprintf(emitter->write_cb, emitter->cbopaque, format, ap); in emitter_printf()
117 emitter_print_value(emitter_t *emitter, emitter_justify_t justify, int width, in emitter_print_value() argument
132 emitter_printf(emitter, \ in emitter_print_value()
138 emitter_printf(emitter, in emitter_print_value()
162 emitter_printf(emitter, in emitter_print_value()
184 emitter_nest_inc(emitter_t *emitter) { in emitter_nest_inc() argument
185 emitter->nesting_depth++; in emitter_nest_inc()
186 emitter->item_at_depth = false; in emitter_nest_inc()
190 emitter_nest_dec(emitter_t *emitter) { in emitter_nest_dec() argument
191 emitter->nesting_depth--; in emitter_nest_dec()
192 emitter->item_at_depth = true; in emitter_nest_dec()
196 emitter_indent(emitter_t *emitter) { in emitter_indent() argument
197 int amount = emitter->nesting_depth; in emitter_indent()
199 if (emitter->output == emitter_output_json) { in emitter_indent()
206 emitter_printf(emitter, "%s", indent_str); in emitter_indent()
211 emitter_json_key_prefix(emitter_t *emitter) { in emitter_json_key_prefix() argument
212 if (emitter->emitted_key) { in emitter_json_key_prefix()
213 emitter->emitted_key = false; in emitter_json_key_prefix()
216 emitter_printf(emitter, "%s\n", emitter->item_at_depth ? "," : ""); in emitter_json_key_prefix()
217 emitter_indent(emitter); in emitter_json_key_prefix()
224 emitter_init(emitter_t *emitter, emitter_output_t emitter_output, in emitter_init() argument
226 emitter->output = emitter_output; in emitter_init()
227 emitter->write_cb = write_cb; in emitter_init()
228 emitter->cbopaque = cbopaque; in emitter_init()
229 emitter->item_at_depth = false; in emitter_init()
230 emitter->emitted_key = false; in emitter_init()
231 emitter->nesting_depth = 0; in emitter_init()
242 emitter_json_key(emitter_t *emitter, const char *json_key) { in emitter_json_key() argument
243 if (emitter->output == emitter_output_json) { in emitter_json_key()
244 emitter_json_key_prefix(emitter); in emitter_json_key()
245 emitter_printf(emitter, "\"%s\": ", json_key); in emitter_json_key()
246 emitter->emitted_key = true; in emitter_json_key()
251 emitter_json_value(emitter_t *emitter, emitter_type_t value_type, in emitter_json_value() argument
253 if (emitter->output == emitter_output_json) { in emitter_json_value()
254 emitter_json_key_prefix(emitter); in emitter_json_value()
255 emitter_print_value(emitter, emitter_justify_none, -1, in emitter_json_value()
257 emitter->item_at_depth = true; in emitter_json_value()
263 emitter_json_kv(emitter_t *emitter, const char *json_key, in emitter_json_kv() argument
265 emitter_json_key(emitter, json_key); in emitter_json_kv()
266 emitter_json_value(emitter, value_type, value); in emitter_json_kv()
270 emitter_json_array_begin(emitter_t *emitter) { in emitter_json_array_begin() argument
271 if (emitter->output == emitter_output_json) { in emitter_json_array_begin()
272 emitter_json_key_prefix(emitter); in emitter_json_array_begin()
273 emitter_printf(emitter, "["); in emitter_json_array_begin()
274 emitter_nest_inc(emitter); in emitter_json_array_begin()
280 emitter_json_array_kv_begin(emitter_t *emitter, const char *json_key) { in emitter_json_array_kv_begin() argument
281 emitter_json_key(emitter, json_key); in emitter_json_array_kv_begin()
282 emitter_json_array_begin(emitter); in emitter_json_array_kv_begin()
286 emitter_json_array_end(emitter_t *emitter) { in emitter_json_array_end() argument
287 if (emitter->output == emitter_output_json) { in emitter_json_array_end()
288 assert(emitter->nesting_depth > 0); in emitter_json_array_end()
289 emitter_nest_dec(emitter); in emitter_json_array_end()
290 emitter_printf(emitter, "\n"); in emitter_json_array_end()
291 emitter_indent(emitter); in emitter_json_array_end()
292 emitter_printf(emitter, "]"); in emitter_json_array_end()
297 emitter_json_object_begin(emitter_t *emitter) { in emitter_json_object_begin() argument
298 if (emitter->output == emitter_output_json) { in emitter_json_object_begin()
299 emitter_json_key_prefix(emitter); in emitter_json_object_begin()
300 emitter_printf(emitter, "{"); in emitter_json_object_begin()
301 emitter_nest_inc(emitter); in emitter_json_object_begin()
307 emitter_json_object_kv_begin(emitter_t *emitter, const char *json_key) { in emitter_json_object_kv_begin() argument
308 emitter_json_key(emitter, json_key); in emitter_json_object_kv_begin()
309 emitter_json_object_begin(emitter); in emitter_json_object_kv_begin()
313 emitter_json_object_end(emitter_t *emitter) { in emitter_json_object_end() argument
314 if (emitter->output == emitter_output_json) { in emitter_json_object_end()
315 assert(emitter->nesting_depth > 0); in emitter_json_object_end()
316 emitter_nest_dec(emitter); in emitter_json_object_end()
317 emitter_printf(emitter, "\n"); in emitter_json_object_end()
318 emitter_indent(emitter); in emitter_json_object_end()
319 emitter_printf(emitter, "}"); in emitter_json_object_end()
328 emitter_table_dict_begin(emitter_t *emitter, const char *table_key) { in emitter_table_dict_begin() argument
329 if (emitter->output == emitter_output_table) { in emitter_table_dict_begin()
330 emitter_indent(emitter); in emitter_table_dict_begin()
331 emitter_printf(emitter, "%s\n", table_key); in emitter_table_dict_begin()
332 emitter_nest_inc(emitter); in emitter_table_dict_begin()
337 emitter_table_dict_end(emitter_t *emitter) { in emitter_table_dict_end() argument
338 if (emitter->output == emitter_output_table) { in emitter_table_dict_end()
339 emitter_nest_dec(emitter); in emitter_table_dict_end()
344 emitter_table_kv_note(emitter_t *emitter, const char *table_key, in emitter_table_kv_note() argument
348 if (emitter->output == emitter_output_table) { in emitter_table_kv_note()
349 emitter_indent(emitter); in emitter_table_kv_note()
350 emitter_printf(emitter, "%s: ", table_key); in emitter_table_kv_note()
351 emitter_print_value(emitter, emitter_justify_none, -1, in emitter_table_kv_note()
354 emitter_printf(emitter, " (%s: ", table_note_key); in emitter_table_kv_note()
355 emitter_print_value(emitter, emitter_justify_none, -1, in emitter_table_kv_note()
357 emitter_printf(emitter, ")"); in emitter_table_kv_note()
359 emitter_printf(emitter, "\n"); in emitter_table_kv_note()
361 emitter->item_at_depth = true; in emitter_table_kv_note()
365 emitter_table_kv(emitter_t *emitter, const char *table_key, in emitter_table_kv() argument
367 emitter_table_kv_note(emitter, table_key, value_type, value, NULL, in emitter_table_kv()
372 /* Write to the emitter the given string, but only in table mode. */
375 emitter_table_printf(emitter_t *emitter, const char *format, ...) { in emitter_table_printf() argument
376 if (emitter->output == emitter_output_table) { in emitter_table_printf()
379 malloc_vcprintf(emitter->write_cb, emitter->cbopaque, format, ap); in emitter_table_printf()
385 emitter_table_row(emitter_t *emitter, emitter_row_t *row) { in emitter_table_row() argument
386 if (emitter->output != emitter_output_table) { in emitter_table_row()
391 emitter_print_value(emitter, col->justify, col->width, in emitter_table_row()
394 emitter_table_printf(emitter, "\n"); in emitter_table_row()
419 emitter_kv_note(emitter_t *emitter, const char *json_key, const char *table_key, in emitter_kv_note() argument
423 if (emitter->output == emitter_output_json) { in emitter_kv_note()
424 emitter_json_key(emitter, json_key); in emitter_kv_note()
425 emitter_json_value(emitter, value_type, value); in emitter_kv_note()
427 emitter_table_kv_note(emitter, table_key, value_type, value, in emitter_kv_note()
430 emitter->item_at_depth = true; in emitter_kv_note()
434 emitter_kv(emitter_t *emitter, const char *json_key, const char *table_key, in emitter_kv() argument
436 emitter_kv_note(emitter, json_key, table_key, value_type, value, NULL, in emitter_kv()
441 emitter_dict_begin(emitter_t *emitter, const char *json_key, in emitter_dict_begin() argument
443 if (emitter->output == emitter_output_json) { in emitter_dict_begin()
444 emitter_json_key(emitter, json_key); in emitter_dict_begin()
445 emitter_json_object_begin(emitter); in emitter_dict_begin()
447 emitter_table_dict_begin(emitter, table_header); in emitter_dict_begin()
452 emitter_dict_end(emitter_t *emitter) { in emitter_dict_end() argument
453 if (emitter->output == emitter_output_json) { in emitter_dict_end()
454 emitter_json_object_end(emitter); in emitter_dict_end()
456 emitter_table_dict_end(emitter); in emitter_dict_end()
461 emitter_begin(emitter_t *emitter) { in emitter_begin() argument
462 if (emitter->output == emitter_output_json) { in emitter_begin()
463 assert(emitter->nesting_depth == 0); in emitter_begin()
464 emitter_printf(emitter, "{"); in emitter_begin()
465 emitter_nest_inc(emitter); in emitter_begin()
473 emitter_printf(emitter, "%s", ""); in emitter_begin()
478 emitter_end(emitter_t *emitter) { in emitter_end() argument
479 if (emitter->output == emitter_output_json) { in emitter_end()
480 assert(emitter->nesting_depth == 1); in emitter_end()
481 emitter_nest_dec(emitter); in emitter_end()
482 emitter_printf(emitter, "\n}\n"); in emitter_end()