#include <json.hpp>
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 Types | |
using | string_t = typename BasicJsonType::string_t |
using | number_float_t = typename BasicJsonType::number_float_t |
using | number_integer_t = typename BasicJsonType::number_integer_t |
using | number_unsigned_t = typename BasicJsonType::number_unsigned_t |
Private Member Functions | |
void | dump_escaped (const string_t &s, const bool ensure_ascii) |
dump escaped string More... | |
unsigned int | count_digits (number_unsigned_t x) noexcept |
count digits More... | |
template<typename NumberType , detail::enable_if_t< std::is_same< NumberType, number_unsigned_t >::value orstd::is_same< NumberType, number_integer_t >::value, int > = 0> | |
void | dump_integer (NumberType x) |
dump an integer More... | |
void | dump_float (number_float_t x) |
dump a floating-point number More... | |
void | dump_float (number_float_t x, std::true_type) |
void | dump_float (number_float_t x, std::false_type) |
number_unsigned_t | remove_sign (number_unsigned_t x) |
number_unsigned_t | remove_sign (number_integer_t x) noexcept |
Static Private Member Functions | |
static std::uint8_t | decode (std::uint8_t &state, std::uint32_t &codep, const std::uint8_t byte) noexcept |
check whether a string is UTF-8 encoded More... | |
Private Attributes | |
output_adapter_t< char > | o = nullptr |
the output of the serializer More... | |
std::array< char, 64 > | number_buffer {{}} |
a (hopefully) large enough character buffer More... | |
const std::lconv * | loc = nullptr |
the locale More... | |
const char | thousands_sep = '\0' |
the locale's thousand separator character More... | |
const char | decimal_point = '\0' |
the locale's decimal point character More... | |
std::array< char, 512 > | string_buffer {{}} |
string buffer More... | |
const char | indent_char |
the indentation character More... | |
string_t | indent_string |
the indentation string More... | |
const error_handler_t | error_handler |
error_handler how to react on decoding errors More... | |
Static Private Attributes | |
static constexpr std::uint8_t | UTF8_ACCEPT = 0 |
static constexpr std::uint8_t | UTF8_REJECT = 1 |
|
private |
|
private |
|
private |
|
private |
|
inline |
[in] | s | output stream to serialize to |
[in] | ichar | indentation character to use |
[in] | error_handler_ | how to react on decoding errors |
Definition at line 13802 of file json.hpp.
|
delete |
|
delete |
|
default |
|
inlineprivatenoexcept |
|
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 14527 of file json.hpp.
|
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] | indent_step | the indent level |
[in] | current_indent | the current indent level (only used internally) |
Definition at line 13837 of file json.hpp.
|
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 sequences |
Linear in the length of string s.
Definition at line 14047 of file json.hpp.
|
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 14428 of file json.hpp.
|
inlineprivate |
Definition at line 14449 of file json.hpp.
|
inlineprivate |
Definition at line 14457 of file json.hpp.
|
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 14342 of file json.hpp.
|
delete |
|
delete |
|
inlineprivate |
|
inlineprivatenoexcept |
Definition at line 14579 of file json.hpp.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
|
staticprivate |