Lines Matching refs:emitter
86 emitter_init(emitter_t *emitter, emitter_output_t emitter_output, in emitter_init() argument
88 emitter->output = emitter_output; in emitter_init()
89 emitter->write_cb = write_cb; in emitter_init()
90 emitter->cbopaque = cbopaque; in emitter_init()
91 emitter->item_at_depth = false; in emitter_init()
92 emitter->nesting_depth = 0; in emitter_init()
98 emitter_printf(emitter_t *emitter, const char *format, ...) { in emitter_printf() argument
102 malloc_vcprintf(emitter->write_cb, emitter->cbopaque, format, ap); in emitter_printf()
109 emitter_table_printf(emitter_t *emitter, const char *format, ...) { in emitter_table_printf() argument
110 if (emitter->output == emitter_output_table) { in emitter_table_printf()
113 malloc_vcprintf(emitter->write_cb, emitter->cbopaque, format, ap); in emitter_table_printf()
144 emitter_print_value(emitter_t *emitter, emitter_justify_t justify, int width, in emitter_print_value() argument
160 emitter_printf(emitter, fmt, *(const type *)value); \ in emitter_print_value()
165 emitter_printf(emitter, fmt, *(const bool *)value ? in emitter_print_value()
189 emitter_printf(emitter, fmt, buf); in emitter_print_value()
210 emitter_nest_inc(emitter_t *emitter) { in emitter_nest_inc() argument
211 emitter->nesting_depth++; in emitter_nest_inc()
212 emitter->item_at_depth = false; in emitter_nest_inc()
216 emitter_nest_dec(emitter_t *emitter) { in emitter_nest_dec() argument
217 emitter->nesting_depth--; in emitter_nest_dec()
218 emitter->item_at_depth = true; in emitter_nest_dec()
222 emitter_indent(emitter_t *emitter) { in emitter_indent() argument
223 int amount = emitter->nesting_depth; in emitter_indent()
225 if (emitter->output == emitter_output_json) { in emitter_indent()
232 emitter_printf(emitter, "%s", indent_str); in emitter_indent()
237 emitter_json_key_prefix(emitter_t *emitter) { in emitter_json_key_prefix() argument
238 emitter_printf(emitter, "%s\n", emitter->item_at_depth ? "," : ""); in emitter_json_key_prefix()
239 emitter_indent(emitter); in emitter_json_key_prefix()
243 emitter_begin(emitter_t *emitter) { in emitter_begin() argument
244 if (emitter->output == emitter_output_json) { in emitter_begin()
245 assert(emitter->nesting_depth == 0); in emitter_begin()
246 emitter_printf(emitter, "{"); in emitter_begin()
247 emitter_nest_inc(emitter); in emitter_begin()
250 emitter_printf(emitter, "%s", ""); in emitter_begin()
255 emitter_end(emitter_t *emitter) { in emitter_end() argument
256 if (emitter->output == emitter_output_json) { in emitter_end()
257 assert(emitter->nesting_depth == 1); in emitter_end()
258 emitter_nest_dec(emitter); in emitter_end()
259 emitter_printf(emitter, "\n}\n"); in emitter_end()
268 emitter_kv_note(emitter_t *emitter, const char *json_key, const char *table_key, in emitter_kv_note() argument
272 if (emitter->output == emitter_output_json) { in emitter_kv_note()
273 assert(emitter->nesting_depth > 0); in emitter_kv_note()
274 emitter_json_key_prefix(emitter); in emitter_kv_note()
275 emitter_printf(emitter, "\"%s\": ", json_key); in emitter_kv_note()
276 emitter_print_value(emitter, emitter_justify_none, -1, in emitter_kv_note()
279 emitter_indent(emitter); in emitter_kv_note()
280 emitter_printf(emitter, "%s: ", table_key); in emitter_kv_note()
281 emitter_print_value(emitter, emitter_justify_none, -1, in emitter_kv_note()
284 emitter_printf(emitter, " (%s: ", table_note_key); in emitter_kv_note()
285 emitter_print_value(emitter, emitter_justify_none, -1, in emitter_kv_note()
287 emitter_printf(emitter, ")"); in emitter_kv_note()
289 emitter_printf(emitter, "\n"); in emitter_kv_note()
291 emitter->item_at_depth = true; in emitter_kv_note()
295 emitter_kv(emitter_t *emitter, const char *json_key, const char *table_key, in emitter_kv() argument
297 emitter_kv_note(emitter, json_key, table_key, value_type, value, NULL, in emitter_kv()
302 emitter_json_kv(emitter_t *emitter, const char *json_key, in emitter_json_kv() argument
304 if (emitter->output == emitter_output_json) { in emitter_json_kv()
305 emitter_kv(emitter, json_key, NULL, value_type, value); in emitter_json_kv()
310 emitter_table_kv(emitter_t *emitter, const char *table_key, in emitter_table_kv() argument
312 if (emitter->output == emitter_output_table) { in emitter_table_kv()
313 emitter_kv(emitter, NULL, table_key, value_type, value); in emitter_table_kv()
318 emitter_dict_begin(emitter_t *emitter, const char *json_key, in emitter_dict_begin() argument
320 if (emitter->output == emitter_output_json) { in emitter_dict_begin()
321 emitter_json_key_prefix(emitter); in emitter_dict_begin()
322 emitter_printf(emitter, "\"%s\": {", json_key); in emitter_dict_begin()
323 emitter_nest_inc(emitter); in emitter_dict_begin()
325 emitter_indent(emitter); in emitter_dict_begin()
326 emitter_printf(emitter, "%s\n", table_header); in emitter_dict_begin()
327 emitter_nest_inc(emitter); in emitter_dict_begin()
332 emitter_dict_end(emitter_t *emitter) { in emitter_dict_end() argument
333 if (emitter->output == emitter_output_json) { in emitter_dict_end()
334 assert(emitter->nesting_depth > 0); in emitter_dict_end()
335 emitter_nest_dec(emitter); in emitter_dict_end()
336 emitter_printf(emitter, "\n"); in emitter_dict_end()
337 emitter_indent(emitter); in emitter_dict_end()
338 emitter_printf(emitter, "}"); in emitter_dict_end()
340 emitter_nest_dec(emitter); in emitter_dict_end()
345 emitter_json_dict_begin(emitter_t *emitter, const char *json_key) { in emitter_json_dict_begin() argument
346 if (emitter->output == emitter_output_json) { in emitter_json_dict_begin()
347 emitter_dict_begin(emitter, json_key, NULL); in emitter_json_dict_begin()
352 emitter_json_dict_end(emitter_t *emitter) { in emitter_json_dict_end() argument
353 if (emitter->output == emitter_output_json) { in emitter_json_dict_end()
354 emitter_dict_end(emitter); in emitter_json_dict_end()
359 emitter_table_dict_begin(emitter_t *emitter, const char *table_key) { in emitter_table_dict_begin() argument
360 if (emitter->output == emitter_output_table) { in emitter_table_dict_begin()
361 emitter_dict_begin(emitter, NULL, table_key); in emitter_table_dict_begin()
366 emitter_table_dict_end(emitter_t *emitter) { in emitter_table_dict_end() argument
367 if (emitter->output == emitter_output_table) { in emitter_table_dict_end()
368 emitter_dict_end(emitter); in emitter_table_dict_end()
373 emitter_json_arr_begin(emitter_t *emitter, const char *json_key) { in emitter_json_arr_begin() argument
374 if (emitter->output == emitter_output_json) { in emitter_json_arr_begin()
375 emitter_json_key_prefix(emitter); in emitter_json_arr_begin()
376 emitter_printf(emitter, "\"%s\": [", json_key); in emitter_json_arr_begin()
377 emitter_nest_inc(emitter); in emitter_json_arr_begin()
382 emitter_json_arr_end(emitter_t *emitter) { in emitter_json_arr_end() argument
383 if (emitter->output == emitter_output_json) { in emitter_json_arr_end()
384 assert(emitter->nesting_depth > 0); in emitter_json_arr_end()
385 emitter_nest_dec(emitter); in emitter_json_arr_end()
386 emitter_printf(emitter, "\n"); in emitter_json_arr_end()
387 emitter_indent(emitter); in emitter_json_arr_end()
388 emitter_printf(emitter, "]"); in emitter_json_arr_end()
393 emitter_json_arr_obj_begin(emitter_t *emitter) { in emitter_json_arr_obj_begin() argument
394 if (emitter->output == emitter_output_json) { in emitter_json_arr_obj_begin()
395 emitter_json_key_prefix(emitter); in emitter_json_arr_obj_begin()
396 emitter_printf(emitter, "{"); in emitter_json_arr_obj_begin()
397 emitter_nest_inc(emitter); in emitter_json_arr_obj_begin()
402 emitter_json_arr_obj_end(emitter_t *emitter) { in emitter_json_arr_obj_end() argument
403 if (emitter->output == emitter_output_json) { in emitter_json_arr_obj_end()
404 assert(emitter->nesting_depth > 0); in emitter_json_arr_obj_end()
405 emitter_nest_dec(emitter); in emitter_json_arr_obj_end()
406 emitter_printf(emitter, "\n"); in emitter_json_arr_obj_end()
407 emitter_indent(emitter); in emitter_json_arr_obj_end()
408 emitter_printf(emitter, "}"); in emitter_json_arr_obj_end()
413 emitter_json_arr_value(emitter_t *emitter, emitter_type_t value_type, in emitter_json_arr_value() argument
415 if (emitter->output == emitter_output_json) { in emitter_json_arr_value()
416 emitter_json_key_prefix(emitter); in emitter_json_arr_value()
417 emitter_print_value(emitter, emitter_justify_none, -1, in emitter_json_arr_value()
423 emitter_table_row(emitter_t *emitter, emitter_row_t *row) { in emitter_table_row() argument
424 if (emitter->output != emitter_output_table) { in emitter_table_row()
429 emitter_print_value(emitter, col->justify, col->width, in emitter_table_row()
432 emitter_table_printf(emitter, "\n"); in emitter_table_row()