static void __print_value (string & result , string const & key , json::value const & value , print_spec const & pspec , int indent) { result.append(__stringify(key)); result.append(pspec.ws_before_kvseparator); result.append(pspec.key_separator); if (value.is_scalar()) { result.append(pspec.ws_after_kvseparator); __print_scalar(result, value); } else { if (pspec.brace_position == json::brace_same_line) { result.append(pspec.ws_after_kvseparator); } else if (pspec.brace_position == json::brace_next_line) { result.append(pspec.new_line); __print_indent(result, pspec, indent); __print_brace_indent(result, pspec, pspec.brace_indent); } indent += pspec.brace_indent; __print_container(result, value, pspec, indent); indent -= pspec.brace_indent; } }
static string __to_string (json::value const & v, print_spec const & pspec) { string r; if (v.is_scalar()) { __print_scalar(r, v); return r; } json::__print_container(r, v, pspec, 0); return r; }
static void __print_value (string & result , json::value const & value , print_spec const & pspec , int indent) { // __print_indent(result, pspec, indent); if (value.is_scalar()) { __print_scalar(result, value); } else { __print_container(result, value, pspec, indent); } }
void Value::fprint(FILE* os) const { fprintf(os, "Value\n"); fprintf(os, "{\n"); fprintf(os, " type=%s\n", _type_name(_type)); fprintf(os, " null=%s\n", _null ? "true" : "false"); // Don't display values when null set. Info unreliable at least // for strings. if (_null) { fprintf(os, " value= NONE\n"); return; } fprintf(os, " value="); switch (_type) { case NONE: fputc('\n', os); break; case BOOLEAN: __print_scalar(os, _type, &_boolean); fputc('\n', os); break; case UINT8: __print_scalar(os, _type, &_uint8); fputc('\n', os); break; case SINT8: __print_scalar(os, _type, &_sint8); fputc('\n', os); break; case UINT16: __print_scalar(os, _type, &_uint16); fputc('\n', os); break; case SINT16: __print_scalar(os, _type, &_sint16); fputc('\n', os); break; case UINT32: __print_scalar(os, _type, &_uint32); fputc('\n', os); break; case SINT32: __print_scalar(os, _type, &_sint32); fputc('\n', os); break; case UINT64: __print_scalar(os, _type, &_uint64); fputc('\n', os); break; case SINT64: __print_scalar(os, _type, &_sint64); fputc('\n', os); break; case REAL32: __print_scalar(os, _type, &_real32); fputc('\n', os); break; case REAL64: __print_scalar(os, _type, &_real64); fputc('\n', os); break; case CHAR16: __print_scalar(os, _type, &_char16); fputc('\n', os); break; case STRING: __print_scalar(os, _type, &_string); fputc('\n', os); break; case DATETIME: __print_scalar(os, _type, &_datetime); fputc('\n', os); break; case INSTANCE: cimple::fprint(os,_instance); break; case BOOLEAN_ARRAY: __print_array(os, _type & 0x7F, &_boolean, 1); fputc('\n', os); break; case UINT8_ARRAY: __print_array(os, _type & 0x7F, &_uint8, 1); fputc('\n', os); break; case SINT8_ARRAY: __print_array(os, _type & 0x7F, &_sint8, 1); fputc('\n', os); break; case UINT16_ARRAY: __print_array(os, _type & 0x7F, &_uint16, 1); fputc('\n', os); break; case SINT16_ARRAY: __print_array(os, _type & 0x7F, &_sint16, 1); fputc('\n', os); break; case UINT32_ARRAY: __print_array(os, _type & 0x7F, &_uint32, 1); fputc('\n', os); break; case SINT32_ARRAY: __print_array(os, _type & 0x7F, &_sint32, 1); fputc('\n', os); break; case UINT64_ARRAY: __print_array(os, _type & 0x7F, &_uint64, 1); fputc('\n', os); break; case SINT64_ARRAY: __print_array(os, _type & 0x7F, &_sint64, 1); fputc('\n', os); break; case REAL32_ARRAY: __print_array(os, _type & 0x7F, &_real32, 1); fputc('\n', os); break; case REAL64_ARRAY: __print_array(os, _type & 0x7F, &_real64, 1); fputc('\n', os); break; case CHAR16_ARRAY: __print_array(os, _type & 0x7F, &_char16, 1); fputc('\n', os); break; case STRING_ARRAY: __print_array(os, _type & 0x7F, &_string, 1); fputc('\n', os); break; case DATETIME_ARRAY: __print_array(os, _type & 0x7F, &_datetime, 1); fputc('\n', os); break; case INSTANCE_ARRAY: { fprintf(os, "\n {\n"); const Array_Instance& arr = *((Array_Instance*)_array); for (size_t i = 0; i < arr.size(); i++) __print_aux(os, arr[i], 0, 2, false); fprintf(os, " }\n"); break; } default: break; } fprintf(os, "}\n"); }