15 #include <apr_buckets.h>
39 impl_put_quoted_to_json(
44 impl_convert_boolean_to_json(
49 impl_convert_list_to_json(
54 impl_convert_object_to_json(
59 impl_convert_value_to_json(
63 AFW_DEFINE_STATIC_INLINE(
void)
69 wa->callback(wa->context, &ch, 1, wa->p, wa->xctx);
73 AFW_DEFINE_STATIC_INLINE(
void)
77 wa->callback(wa->context, s, strlen(s), wa->p, wa->xctx);
81 AFW_DEFINE_STATIC_INLINE(
void)
85 wa->callback(wa->context, buffer, size, wa->p, wa->xctx);
96 va_start(arg, format_z);
100 wa->callback(wa->context, s->s, s->len, wa->p, wa->xctx);
110 if (!wa->skip_next_ws) {
112 for (indent = 1; indent <= wa->indent; indent++) {
117 wa->skip_next_ws = 0;
123 impl_put_json_string(
140 if (c ==
'\\' || c ==
'"') {
151 impl_puts(wa,
"\\n");
156 impl_puts(wa,
"\\r");
161 impl_puts(wa,
"\\t");
166 impl_puts(wa,
"\\f");
171 impl_puts(wa,
"\\b");
179 impl_printf(wa,
"\\u%04x", c);
191 impl_put_quoted_to_json(
198 impl_write(wa, s->s, s->len);
205 impl_convert_boolean_to_json(
210 impl_puts(wa, AFW_JSON_Q_PRIMITIVE_BOOLEAN_TRUE);
213 impl_puts(wa, AFW_JSON_Q_PRIMITIVE_BOOLEAN_FALSE);
219 impl_convert_list_to_json(
230 list_iterator = NULL;
235 impl_convert_value_to_json(wa, next);
252 impl_convert_object_to_json(
265 (wa->object_depth)++;
268 starting_comma_needed =
false;
270 wa->options, wa->p, wa->xctx);
273 wa->skip_next_ws = 1;
275 impl_puts(wa,
"\"_meta_\": ");
278 impl_puts(wa,
"\"_meta_\":");
281 impl_convert_object_to_json(wa, meta);
282 starting_comma_needed =
true;
286 property_iterator = NULL;
288 &property_name, wa->xctx);
291 if (starting_comma_needed) {
293 starting_comma_needed =
false;
296 wa->skip_next_ws = 1;
297 impl_put_quoted_to_json(wa, property_name);
304 impl_convert_value_to_json(wa, next);
306 &property_iterator, &property_name, wa->xctx);
314 (wa->object_depth)--;
321 impl_convert_value_to_json(
340 if (wa->do_typed_values) {
349 "Unevaluated value encountered producing json "
366 impl_convert_object_to_json(wa,
375 &AFW_JSON_S_PRIMITIVE_NULL))
377 impl_puts(wa, AFW_JSON_Q_PRIMITIVE_NULL);
382 &AFW_JSON_S_PRIMITIVE_STRING))
388 impl_put_json_string(wa,
string);
393 &AFW_JSON_S_PRIMITIVE_NUMBER))
406 impl_put_json_string(wa,
string);
414 impl_write(wa, string->s, string->len);
420 &AFW_JSON_S_PRIMITIVE_BOOLEAN))
422 impl_convert_boolean_to_json(wa,
429 "Value inf is invalid", wa->xctx);
434 if (wa->do_typed_values) {
437 if (value_data_type) {
448 impl_put_json_string(wa, s);
451 impl_put_json_string(wa, &value_data_type->data_type_id);
455 impl_puts(wa,
"null");
466 afw_json_internal_write_value(
480 wa.options = options;
484 wa.context = context;
485 wa.callback = callback;
488 impl_convert_value_to_json(&wa, value);
504 afw_json_internal_write_value(value, options,
505 writer->context, writer->callback, p, xctx);
532 if (c ==
'\\' || c ==
'"') {
572 c2[0] = c / 16 +
'0';
573 c2[1] = c % 16 +
'0';
AFW_DEFINE(const afw_object_t *)
Adaptive Framework Core Internal.
afw_value_evaluated_ia5String_inf
Unmanaged evaluated value inf for data type ia5String.
#define afw_value_is_integer(A_VALUE)
Macro to determine if value is evaluated integer.
#define afw_value_is_list(A_VALUE)
Macro to determine if value is evaluated list.
#define afw_value_is_object(A_VALUE)
Macro to determine if value is evaluated object.
#define AFW_UTF8_FMT_ARG(A_STRING)
Convenience Macro for use with AFW_UTF8_FMT to specify arg.
struct afw_iterator_s afw_iterator_t
#define AFW_UTF8_FMT_OPTIONAL_ARG(A_STRING)
Convenience Macro for use with AFW_UTF8_FMT to specify optional arg.
unsigned char afw_byte_t
A byte of memory (unsigned).
#define AFW_UTF8_FMT
Format string specifier used for afw_utf8_t.
afw_utf8_octet_t afw_utf8_z_t
NFC normalized UTF-8 null terminated string.
char afw_utf8_octet_t
8 bits of utf-8 codepoint.
apr_size_t afw_size_t
size_t.
#define AFW_INTEGER_IS_SAFE_DOUBLE(integer)
Tests integer to be safely held in a double.
afw_size_t(* afw_write_cb_t)(void *context, const void *buffer, afw_size_t size, const afw_pool_t *p, afw_xctx_t *xctx)
Typedef for write callback function.
#define afw_data_type_internal_to_utf8(instance, from_internal, p, xctx)
Call method internal_to_utf8 of interface afw_data_type.
#define AFW_THROW_ERROR_FZ(code, xctx, format_z,...)
Macro used to set error and 0 rv in xctx and throw it.
#define AFW_THROW_ERROR_Z(code, message_z, xctx)
Macro used to set error and 0 rv in xctx and throw it.
afw_json_utf8_string_create(const afw_utf8_t *string, const afw_pool_t *p, afw_xctx_t *xctx)
Create a json encoded quoted string.
afw_json_write_encoded_string(const afw_utf8_t *string, const afw_writer_t *writer, afw_xctx_t *xctx)
Write string as json encoded string.
afw_json_from_value(const afw_value_t *value, const afw_object_options_t *options, const afw_pool_t *p, afw_xctx_t *xctx)
Convert an adaptive value to JSON.
#define afw_list_get_next_value(instance, iterator, p, xctx)
Call method get_next_value of interface afw_list.
#define afw_memory_clear(to)
Clear preallocated memory for sizeof(*(to)).
afw_memory_writer_retrieve_and_release(const afw_memory_writer_t *writer, afw_xctx_t *xctx)
Retrieve memory as one chunk from memory writer and release writer.
afw_memory_create_writer(const afw_pool_t *p, afw_xctx_t *xctx)
Create a memory writer.
#define afw_memory_copy(to, from)
Copy to preallocated memory of same type.
#define afw_object_get_next_property(instance, iterator, property_name, xctx)
Call method get_next_property of interface afw_object.
#define AFW_OBJECT_OPTION_IS(_options, _option)
Test mask.
const afw_utf8_t * afw_utf8_from_raw(const afw_memory_t *raw, const afw_pool_t *p, afw_xctx_t *xctx)
Convert raw to a utf-8 NFC normalizing if necessary in specified pool.
afw_utf8_printf_v(const afw_utf8_z_t *format, va_list arg, const afw_pool_t *p, afw_xctx_t *xctx)
Create a utf-8 string using a c format string in specified pool.
afw_boolean_t afw_utf8_equal(const afw_utf8_t *s1, const afw_utf8_t *s2)
Check to see if a string equals another string.
afw_utf8_printf(const afw_pool_t *p, afw_xctx_t *xctx, const afw_utf8_z_t *format,...)
Create a utf-8 string using a c format string in specified pool.
#define afw_value_get_data_type(instance, xctx)
Call method get_data_type of interface afw_value.
#define afw_value_get_info(instance, info, p, xctx)
Call method get_info of interface afw_value.
afw_value_as_utf8(const afw_value_t *value, const afw_pool_t *p, afw_xctx_t *xctx)
#define afw_value_is_defined_and_evaluated(A_VALUE)
Macro to determine if value is defined and evaluated.
afw_value_null
Adaptive value null.
#define afw_writer_write(instance, buffer, size, xctx)
Call method write of interface afw_writer.
#define afw_writer_write_z(writer, s_z, xctx)
Call afw_writer_write() with zero terminated string.
Interface afw_data_type public struct.
Interface afw_list public struct.
Struct for memory pointer and size.
Return value from afw_memory_create_writer().
Struct for object processing options.
Interface afw_object public struct.
Interface afw_pool public struct.
NFC normalized UTF-8 string.
struct for data type boolean values.
Struct to access internal of all evaluated values.
Filled in by afw_value get_info method.
struct for data type integer values.
struct for data type list values.
struct for data type object values.
Interface afw_value public struct.
struct for data type string values.
Interface afw_writer public struct.
Interface afw_xctx public struct.