24#ifndef GP_JSON_WRITER_H
25#define GP_JSON_WRITER_H
36 void (*
err_print)(
void *err_print_priv,
const char *line);
53#define GP_JSON_WRITER_INIT(vout, vout_priv) { \
54 .err_print = GP_JSON_ERR_PRINT, \
55 .err_print_priv = GP_JSON_ERR_PRINT_PRIV, \
57 .out_priv = vout_priv \
83 return self->out_priv;
117 return !!self->err[0];
Common JSON reader/writer definitions.
#define GP_JSON_RECURSION_MAX
Maximal recursion depth allowed.
#define GP_JSON_ERR_MAX
Maximal error message length.
int gp_json_obj_finish(gp_json_writer *self)
Finishes a JSON object.
gp_json_writer * gp_json_writer_file_open(const char *path)
Allocates a JSON file writer.
gp_json_writer * gp_json_writer_vec_new(void)
Allocates a JSON writer with a vector as a storage.
int gp_json_writer_finish(gp_json_writer *self)
Finalizes json writer.
int gp_json_bool_add(gp_json_writer *self, const char *id, int val)
Adds a bool value.
static int gp_json_writer_err(gp_json_writer *self)
Returns true if writer error happened.
void gp_json_writer_vec_free(gp_json_writer *self)
Frees a JSON writer with a vector as a storage.
int gp_json_null_add(gp_json_writer *self, const char *id)
Adds a null value.
int gp_json_arr_finish(gp_json_writer *self)
Finishes a JSON array.
int gp_json_str_add(gp_json_writer *self, const char *id, const char *str)
Adds a string value.
int gp_json_float_add(gp_json_writer *self, const char *id, double val)
Adds a float value.
int gp_json_int_add(gp_json_writer *self, const char *id, long val)
Adds an integer value.
int gp_json_arr_start(gp_json_writer *self, const char *id)
Starts a JSON array.
int gp_json_writer_file_close(gp_json_writer *self)
Closes and frees a JSON file writer.
int gp_json_obj_start(gp_json_writer *self, const char *id)
Starts a JSON object.
static char * gp_json_writer_vec(gp_json_writer *self)
Returns a pointer to a vector storage.
int(* out)(struct gp_json_writer *self, const char *buf, size_t buf_size)
void(* err_print)(void *err_print_priv, const char *line)