• Home
  • Raw
  • Download

Lines Matching full:self

33 static void jsonw_indent(json_writer_t *self)  in jsonw_indent()  argument
36 for (i = 0; i < self->depth; ++i) in jsonw_indent()
37 fputs(" ", self->out); in jsonw_indent()
41 static void jsonw_eol(json_writer_t *self) in jsonw_eol() argument
43 if (!self->pretty) in jsonw_eol()
46 putc('\n', self->out); in jsonw_eol()
47 jsonw_indent(self); in jsonw_eol()
51 static void jsonw_eor(json_writer_t *self) in jsonw_eor() argument
53 if (self->sep != '\0') in jsonw_eor()
54 putc(self->sep, self->out); in jsonw_eor()
55 self->sep = ','; in jsonw_eor()
61 static void jsonw_puts(json_writer_t *self, const char *str) in jsonw_puts() argument
63 putc('"', self->out); in jsonw_puts()
67 fputs("\\t", self->out); in jsonw_puts()
70 fputs("\\n", self->out); in jsonw_puts()
73 fputs("\\r", self->out); in jsonw_puts()
76 fputs("\\f", self->out); in jsonw_puts()
79 fputs("\\b", self->out); in jsonw_puts()
82 fputs("\\n", self->out); in jsonw_puts()
85 fputs("\\\"", self->out); in jsonw_puts()
88 fputs("\\\'", self->out); in jsonw_puts()
91 putc(*str, self->out); in jsonw_puts()
93 putc('"', self->out); in jsonw_puts()
99 json_writer_t *self = malloc(sizeof(*self)); in jsonw_new() local
100 if (self) { in jsonw_new()
101 self->out = f; in jsonw_new()
102 self->depth = 0; in jsonw_new()
103 self->pretty = false; in jsonw_new()
104 self->sep = '\0'; in jsonw_new()
106 return self; in jsonw_new()
112 json_writer_t *self = *self_p; in jsonw_destroy() local
114 assert(self->depth == 0); in jsonw_destroy()
115 fputs("\n", self->out); in jsonw_destroy()
116 fflush(self->out); in jsonw_destroy()
117 free(self); in jsonw_destroy()
121 void jsonw_pretty(json_writer_t *self, bool on) in jsonw_pretty() argument
123 self->pretty = on; in jsonw_pretty()
127 static void jsonw_begin(json_writer_t *self, int c) in jsonw_begin() argument
129 jsonw_eor(self); in jsonw_begin()
130 putc(c, self->out); in jsonw_begin()
131 ++self->depth; in jsonw_begin()
132 self->sep = '\0'; in jsonw_begin()
135 static void jsonw_end(json_writer_t *self, int c) in jsonw_end() argument
137 assert(self->depth > 0); in jsonw_end()
139 --self->depth; in jsonw_end()
140 if (self->sep != '\0') in jsonw_end()
141 jsonw_eol(self); in jsonw_end()
142 putc(c, self->out); in jsonw_end()
143 self->sep = ','; in jsonw_end()
148 void jsonw_name(json_writer_t *self, const char *name) in jsonw_name() argument
150 jsonw_eor(self); in jsonw_name()
151 jsonw_eol(self); in jsonw_name()
152 self->sep = '\0'; in jsonw_name()
153 jsonw_puts(self, name); in jsonw_name()
154 putc(':', self->out); in jsonw_name()
155 if (self->pretty) in jsonw_name()
156 putc(' ', self->out); in jsonw_name()
159 void jsonw_vprintf_enquote(json_writer_t *self, const char *fmt, va_list ap) in jsonw_vprintf_enquote() argument
161 jsonw_eor(self); in jsonw_vprintf_enquote()
162 putc('"', self->out); in jsonw_vprintf_enquote()
163 vfprintf(self->out, fmt, ap); in jsonw_vprintf_enquote()
164 putc('"', self->out); in jsonw_vprintf_enquote()
167 void jsonw_printf(json_writer_t *self, const char *fmt, ...) in jsonw_printf() argument
172 jsonw_eor(self); in jsonw_printf()
173 vfprintf(self->out, fmt, ap); in jsonw_printf()
178 void jsonw_start_object(json_writer_t *self) in jsonw_start_object() argument
180 jsonw_begin(self, '{'); in jsonw_start_object()
183 void jsonw_end_object(json_writer_t *self) in jsonw_end_object() argument
185 jsonw_end(self, '}'); in jsonw_end_object()
188 void jsonw_start_array(json_writer_t *self) in jsonw_start_array() argument
190 jsonw_begin(self, '['); in jsonw_start_array()
193 void jsonw_end_array(json_writer_t *self) in jsonw_end_array() argument
195 jsonw_end(self, ']'); in jsonw_end_array()
199 void jsonw_string(json_writer_t *self, const char *value) in jsonw_string() argument
201 jsonw_eor(self); in jsonw_string()
202 jsonw_puts(self, value); in jsonw_string()
205 void jsonw_bool(json_writer_t *self, bool val) in jsonw_bool() argument
207 jsonw_printf(self, "%s", val ? "true" : "false"); in jsonw_bool()
210 void jsonw_null(json_writer_t *self) in jsonw_null() argument
212 jsonw_printf(self, "null"); in jsonw_null()
215 void jsonw_float_fmt(json_writer_t *self, const char *fmt, double num) in jsonw_float_fmt() argument
217 jsonw_printf(self, fmt, num); in jsonw_float_fmt()
221 void jsonw_float(json_writer_t *self, double num) in jsonw_float() argument
223 jsonw_printf(self, "%g", num); in jsonw_float()
227 void jsonw_hu(json_writer_t *self, unsigned short num) in jsonw_hu() argument
229 jsonw_printf(self, "%hu", num); in jsonw_hu()
232 void jsonw_uint(json_writer_t *self, uint64_t num) in jsonw_uint() argument
234 jsonw_printf(self, "%"PRIu64, num); in jsonw_uint()
237 void jsonw_lluint(json_writer_t *self, unsigned long long int num) in jsonw_lluint() argument
239 jsonw_printf(self, "%llu", num); in jsonw_lluint()
242 void jsonw_int(json_writer_t *self, int64_t num) in jsonw_int() argument
244 jsonw_printf(self, "%"PRId64, num); in jsonw_int()
248 void jsonw_string_field(json_writer_t *self, const char *prop, const char *val) in jsonw_string_field() argument
250 jsonw_name(self, prop); in jsonw_string_field()
251 jsonw_string(self, val); in jsonw_string_field()
254 void jsonw_bool_field(json_writer_t *self, const char *prop, bool val) in jsonw_bool_field() argument
256 jsonw_name(self, prop); in jsonw_bool_field()
257 jsonw_bool(self, val); in jsonw_bool_field()
261 void jsonw_float_field(json_writer_t *self, const char *prop, double val) in jsonw_float_field() argument
263 jsonw_name(self, prop); in jsonw_float_field()
264 jsonw_float(self, val); in jsonw_float_field()
268 void jsonw_float_field_fmt(json_writer_t *self, in jsonw_float_field_fmt() argument
273 jsonw_name(self, prop); in jsonw_float_field_fmt()
274 jsonw_float_fmt(self, fmt, val); in jsonw_float_field_fmt()
277 void jsonw_uint_field(json_writer_t *self, const char *prop, uint64_t num) in jsonw_uint_field() argument
279 jsonw_name(self, prop); in jsonw_uint_field()
280 jsonw_uint(self, num); in jsonw_uint_field()
283 void jsonw_hu_field(json_writer_t *self, const char *prop, unsigned short num) in jsonw_hu_field() argument
285 jsonw_name(self, prop); in jsonw_hu_field()
286 jsonw_hu(self, num); in jsonw_hu_field()
289 void jsonw_lluint_field(json_writer_t *self, in jsonw_lluint_field() argument
293 jsonw_name(self, prop); in jsonw_lluint_field()
294 jsonw_lluint(self, num); in jsonw_lluint_field()
297 void jsonw_int_field(json_writer_t *self, const char *prop, int64_t num) in jsonw_int_field() argument
299 jsonw_name(self, prop); in jsonw_int_field()
300 jsonw_int(self, num); in jsonw_int_field()
303 void jsonw_null_field(json_writer_t *self, const char *prop) in jsonw_null_field() argument
305 jsonw_name(self, prop); in jsonw_null_field()
306 jsonw_null(self); in jsonw_null_field()