24#ifndef GP_JSON_WRITER_H
25#define GP_JSON_WRITER_H
32 char depth_type[GP_JSON_RECURSION_MAX/8];
33 char depth_first[GP_JSON_RECURSION_MAX/8];
36 void (*
err_print)(
void *err_print_priv,
const char *line);
38 char err[GP_JSON_ERR_MAX];
45#define GP_JSON_WRITER_INIT(out_, out_priv_) { \
46 .err_print = GP_JSON_ERR_PRINT, \
47 .err_print_priv = GP_JSON_ERR_PRINT_PRIV, \
49 .out_priv = out_priv_ \
73 return self->out_priv;
83 return !!self->err[0];
Common JSON reader/writer definitions.
int gp_json_obj_finish(gp_json_writer *self)
Finishes a JSON object.
int gp_json_finish(gp_json_writer *self)
Finalizes json writer.
gp_json_writer * gp_json_writer_vec_new(void)
Allocates a JSON writer with a vector as a storage.
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 an json array.
int gp_json_obj_start(gp_json_writer *self, const char *id)
Starts an 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)