#include <json.h>
Public Member Functions | |
serializer (output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict) | |
serializer (const serializer &)=delete | |
serializer & | operator= (const serializer &)=delete |
serializer (serializer &&)=delete | |
serializer & | operator= (serializer &&)=delete |
~serializer ()=default | |
void | dump (const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent=0) |
internal implementation of the serialization function More... | |
|
private |
|
private |
|
private |
|
private |
|
private |
|
inline |
|
delete |
|
delete |
|
default |
|
inlineprivatenoexcept |
count digits
Count the number of decimal (base 10) digits for an input unsigned integer.
[in] | x | unsigned integer number to count its digits |
Definition at line 16073 of file json.h.
Referenced by nlohmann::detail::serializer< BasicJsonType >::dump_integer().
|
inlinestaticprivatenoexcept |
check whether a string is UTF-8 encoded
The function checks each byte of a string whether it is UTF-8 encoded. The result of the check is stored in the state parameter. The function must be called initially with state 0 (accept). State 1 means the string must be rejected, because the current byte is not allowed. If the string is completely processed, but the state is non-zero, the string ended prematurely; that is, the last byte indicated more bytes should have followed.
[in,out] | state | the state of the decoding |
[in,out] | codep | codepoint (valid only if resulting state is UTF8_ACCEPT) |
[in] | byte | next byte to decode |
Definition at line 16298 of file json.h.
References nlohmann::detail::JSON_ASSERT(), and nlohmann::detail::serializer< BasicJsonType >::UTF8_ACCEPT.
Referenced by nlohmann::detail::serializer< BasicJsonType >::dump_escaped().
|
inline |
internal implementation of the serialization function
This function is called by the public member function dump and organizes the serialization internally. The indentation level is propagated as additional parameter. In case of arrays and objects, the function is called recursively.
escape_string()
operator<<
"%g"
format[in] | val | value to serialize |
[in] | pretty_print | whether the output shall be pretty-printed |
[in] | ensure_ascii | If ensure_ascii is true, all non-ASCII characters in the output are escaped with \uXXXX sequences, and the result consists of ASCII characters only. |
[in] | indent_step | the indent level |
[in] | current_indent | the current indent level (only used internally) |
Definition at line 15533 of file json.h.
References nlohmann::detail::array, nlohmann::detail::binary, nlohmann::detail::boolean, nlohmann::detail::discarded, nlohmann::detail::serializer< BasicJsonType >::dump_escaped(), nlohmann::detail::serializer< BasicJsonType >::dump_float(), nlohmann::detail::serializer< BasicJsonType >::dump_integer(), nlohmann::detail::serializer< BasicJsonType >::indent_string, nlohmann::detail::JSON_ASSERT(), nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::serializer< BasicJsonType >::o, nlohmann::detail::object, and nlohmann::detail::string.
|
inlineprivate |
dump escaped string
Escape a string by replacing certain special characters by a sequence of an escape character (backslash) and another character and other control characters by a sequence of "\u" followed by a four-digit hex representation. The escaped string is written to output stream o.
[in] | s | the string to escape |
[in] | ensure_ascii | whether to escape non-ASCII characters with \uXXXX sequences |
@complexity Linear in the length of string s.
Definition at line 15817 of file json.h.
References nlohmann::detail::type_error::create(), nlohmann::detail::serializer< BasicJsonType >::decode(), nlohmann::detail::serializer< BasicJsonType >::error_handler, nlohmann::detail::ignore, nlohmann::detail::JSON_ASSERT(), nlohmann::detail::serializer< BasicJsonType >::o, nlohmann::detail::replace, nlohmann::detail::strict, nlohmann::detail::serializer< BasicJsonType >::string_buffer, nlohmann::detail::binary_writer< BasicJsonType, CharType >::to_char_type(), nlohmann::to_string(), nlohmann::detail::serializer< BasicJsonType >::UTF8_ACCEPT, and nlohmann::detail::serializer< BasicJsonType >::UTF8_REJECT.
Referenced by nlohmann::detail::serializer< BasicJsonType >::dump().
|
inlineprivate |
dump a floating-point number
Dump a given floating-point number to output stream o. Works internally with number_buffer.
[in] | x | floating-point number to dump |
Definition at line 16199 of file json.h.
References nlohmann::detail::serializer< BasicJsonType >::o.
Referenced by nlohmann::detail::serializer< BasicJsonType >::dump().
|
inlineprivate |
Definition at line 16228 of file json.h.
References nlohmann::detail::serializer< BasicJsonType >::decimal_point, nlohmann::detail::JSON_ASSERT(), nlohmann::detail::len, nlohmann::detail::serializer< BasicJsonType >::number_buffer, nlohmann::detail::serializer< BasicJsonType >::o, and nlohmann::detail::serializer< BasicJsonType >::thousands_sep.
|
inlineprivate |
Definition at line 16220 of file json.h.
References nlohmann::detail::serializer< BasicJsonType >::number_buffer, and nlohmann::detail::serializer< BasicJsonType >::o.
|
inlineprivate |
dump an integer
Dump a given integer to output stream o. Works internally with number_buffer.
[in] | x | integer number (signed or unsigned) to dump |
NumberType | either number_integer_t or number_unsigned_t |
Definition at line 16113 of file json.h.
References nlohmann::detail::serializer< BasicJsonType >::count_digits(), nlohmann::detail::JSON_ASSERT(), nlohmann::detail::serializer< BasicJsonType >::number_buffer, nlohmann::detail::serializer< BasicJsonType >::o, nlohmann::detail::serializer< BasicJsonType >::remove_sign(), and nlohmann::detail::value.
Referenced by nlohmann::detail::serializer< BasicJsonType >::dump().
|
delete |
|
delete |
|
inlineprivatenoexcept |
Definition at line 16352 of file json.h.
References nlohmann::detail::JSON_ASSERT().
|
inlineprivate |
Definition at line 16337 of file json.h.
References nlohmann::detail::JSON_ASSERT().
Referenced by nlohmann::detail::serializer< BasicJsonType >::dump_integer().
|
private |
the locale's decimal point character
Definition at line 16370 of file json.h.
Referenced by nlohmann::detail::serializer< BasicJsonType >::dump_float().
|
private |
error_handler how to react on decoding errors
Definition at line 16381 of file json.h.
Referenced by nlohmann::detail::serializer< BasicJsonType >::dump_escaped().
|
private |
|
private |
the indentation string
Definition at line 16378 of file json.h.
Referenced by nlohmann::detail::serializer< BasicJsonType >::dump().
|
private |
|
private |
a (hopefully) large enough character buffer
Definition at line 16363 of file json.h.
Referenced by nlohmann::detail::serializer< BasicJsonType >::dump_float(), and nlohmann::detail::serializer< BasicJsonType >::dump_integer().
|
private |
the output of the serializer
Definition at line 16360 of file json.h.
Referenced by nlohmann::detail::serializer< BasicJsonType >::dump(), nlohmann::detail::serializer< BasicJsonType >::dump_escaped(), nlohmann::detail::serializer< BasicJsonType >::dump_float(), and nlohmann::detail::serializer< BasicJsonType >::dump_integer().
|
private |
string buffer
Definition at line 16373 of file json.h.
Referenced by nlohmann::detail::serializer< BasicJsonType >::dump_escaped().
|
private |
the locale's thousand separator character
Definition at line 16368 of file json.h.
Referenced by nlohmann::detail::serializer< BasicJsonType >::dump_float().
|
staticconstexprprivate |
Definition at line 15484 of file json.h.
Referenced by nlohmann::detail::serializer< BasicJsonType >::decode(), and nlohmann::detail::serializer< BasicJsonType >::dump_escaped().
|
staticconstexprprivate |
Definition at line 15485 of file json.h.
Referenced by nlohmann::detail::serializer< BasicJsonType >::dump_escaped().