MUQ  0.4.3
nlohmann::detail::serializer< BasicJsonType > Class Template Reference

#include <json.h>

Detailed Description

template<typename BasicJsonType>
class nlohmann::detail::serializer< BasicJsonType >

Definition at line 15477 of file 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
 
serializeroperator= (const serializer &)=delete
 
 serializer (serializer &&)=delete
 
serializeroperator= (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...
 

Member Typedef Documentation

◆ binary_char_t

template<typename BasicJsonType >
using nlohmann::detail::serializer< BasicJsonType >::binary_char_t = typename BasicJsonType::binary_t::value_type
private

Definition at line 15483 of file json.h.

◆ number_float_t

template<typename BasicJsonType >
using nlohmann::detail::serializer< BasicJsonType >::number_float_t = typename BasicJsonType::number_float_t
private

Definition at line 15480 of file json.h.

◆ number_integer_t

template<typename BasicJsonType >
using nlohmann::detail::serializer< BasicJsonType >::number_integer_t = typename BasicJsonType::number_integer_t
private

Definition at line 15481 of file json.h.

◆ number_unsigned_t

template<typename BasicJsonType >
using nlohmann::detail::serializer< BasicJsonType >::number_unsigned_t = typename BasicJsonType::number_unsigned_t
private

Definition at line 15482 of file json.h.

◆ string_t

template<typename BasicJsonType >
using nlohmann::detail::serializer< BasicJsonType >::string_t = typename BasicJsonType::string_t
private

Definition at line 15479 of file json.h.

Constructor & Destructor Documentation

◆ serializer() [1/3]

template<typename BasicJsonType >
nlohmann::detail::serializer< BasicJsonType >::serializer ( output_adapter_t< char >  s,
const char  ichar,
error_handler_t  error_handler_ = error_handler_t::strict 
)
inline
Parameters
[in]soutput stream to serialize to
[in]icharindentation character to use
[in]error_handler_how to react on decoding errors

Definition at line 15493 of file json.h.

◆ serializer() [2/3]

template<typename BasicJsonType >
nlohmann::detail::serializer< BasicJsonType >::serializer ( const serializer< BasicJsonType > &  )
delete

◆ serializer() [3/3]

template<typename BasicJsonType >
nlohmann::detail::serializer< BasicJsonType >::serializer ( serializer< BasicJsonType > &&  )
delete

◆ ~serializer()

template<typename BasicJsonType >
nlohmann::detail::serializer< BasicJsonType >::~serializer ( )
default

Member Function Documentation

◆ count_digits()

template<typename BasicJsonType >
unsigned int nlohmann::detail::serializer< BasicJsonType >::count_digits ( number_unsigned_t  x)
inlineprivatenoexcept

count digits

Count the number of decimal (base 10) digits for an input unsigned integer.

Parameters
[in]xunsigned integer number to count its digits
Returns
number of decimal digits

Definition at line 16073 of file json.h.

Referenced by nlohmann::detail::serializer< BasicJsonType >::dump_integer().

◆ decode()

template<typename BasicJsonType >
static std::uint8_t nlohmann::detail::serializer< BasicJsonType >::decode ( std::uint8_t &  state,
std::uint32_t &  codep,
const std::uint8_t  byte 
)
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.

Parameters
[in,out]statethe state of the decoding
[in,out]codepcodepoint (valid only if resulting state is UTF8_ACCEPT)
[in]bytenext byte to decode
Returns
new state
Note
The function has been edited: a std::array is used.
See also
http://bjoern.hoehrmann.de/utf-8/decoder/dfa/

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().

◆ dump()

template<typename BasicJsonType >
void nlohmann::detail::serializer< BasicJsonType >::dump ( const BasicJsonType &  val,
const bool  pretty_print,
const bool  ensure_ascii,
const unsigned int  indent_step,
const unsigned int  current_indent = 0 
)
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.

  • strings and object keys are escaped using escape_string()
  • integer numbers are converted implicitly via operator<<
  • floating-point numbers are converted to a string using "%g" format
  • binary values are serialized as objects containing the subtype and the byte array
Parameters
[in]valvalue to serialize
[in]pretty_printwhether the output shall be pretty-printed
[in]ensure_asciiIf 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_stepthe indent level
[in]current_indentthe 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.

Referenced by nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType >::dump().

◆ dump_escaped()

template<typename BasicJsonType >
void nlohmann::detail::serializer< BasicJsonType >::dump_escaped ( const string_t s,
const bool  ensure_ascii 
)
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.

Parameters
[in]sthe string to escape
[in]ensure_asciiwhether 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().

◆ dump_float() [1/3]

template<typename BasicJsonType >
void nlohmann::detail::serializer< BasicJsonType >::dump_float ( number_float_t  x)
inlineprivate

dump a floating-point number

Dump a given floating-point number to output stream o. Works internally with number_buffer.

Parameters
[in]xfloating-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().

◆ dump_float() [2/3]

◆ dump_float() [3/3]

template<typename BasicJsonType >
void nlohmann::detail::serializer< BasicJsonType >::dump_float ( number_float_t  x,
std::true_type   
)
inlineprivate

◆ dump_integer()

template<typename BasicJsonType >
template<typename NumberType , detail::enable_if_t< std::is_same< NumberType, number_unsigned_t >::value||std::is_same< NumberType, number_integer_t >::value||std::is_same< NumberType, binary_char_t >::value, int > = 0>
void nlohmann::detail::serializer< BasicJsonType >::dump_integer ( NumberType  x)
inlineprivate

dump an integer

Dump a given integer to output stream o. Works internally with number_buffer.

Parameters
[in]xinteger number (signed or unsigned) to dump
Template Parameters
NumberTypeeither 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().

◆ operator=() [1/2]

template<typename BasicJsonType >
serializer& nlohmann::detail::serializer< BasicJsonType >::operator= ( const serializer< BasicJsonType > &  )
delete

◆ operator=() [2/2]

template<typename BasicJsonType >
serializer& nlohmann::detail::serializer< BasicJsonType >::operator= ( serializer< BasicJsonType > &&  )
delete

◆ remove_sign() [1/2]

template<typename BasicJsonType >
number_unsigned_t nlohmann::detail::serializer< BasicJsonType >::remove_sign ( number_integer_t  x)
inlineprivatenoexcept

Definition at line 16352 of file json.h.

References nlohmann::detail::JSON_ASSERT().

◆ remove_sign() [2/2]

template<typename BasicJsonType >
number_unsigned_t nlohmann::detail::serializer< BasicJsonType >::remove_sign ( number_unsigned_t  x)
inlineprivate

Member Data Documentation

◆ decimal_point

template<typename BasicJsonType >
const char nlohmann::detail::serializer< BasicJsonType >::decimal_point = '\0'
private

the locale's decimal point character

Definition at line 16370 of file json.h.

Referenced by nlohmann::detail::serializer< BasicJsonType >::dump_float().

◆ error_handler

template<typename BasicJsonType >
const error_handler_t nlohmann::detail::serializer< BasicJsonType >::error_handler
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().

◆ indent_char

template<typename BasicJsonType >
const char nlohmann::detail::serializer< BasicJsonType >::indent_char
private

the indentation character

Definition at line 16376 of file json.h.

◆ indent_string

template<typename BasicJsonType >
string_t nlohmann::detail::serializer< BasicJsonType >::indent_string
private

the indentation string

Definition at line 16378 of file json.h.

Referenced by nlohmann::detail::serializer< BasicJsonType >::dump().

◆ loc

template<typename BasicJsonType >
const std::lconv* nlohmann::detail::serializer< BasicJsonType >::loc = nullptr
private

the locale

Definition at line 16366 of file json.h.

◆ number_buffer

template<typename BasicJsonType >
std::array<char, 64> nlohmann::detail::serializer< BasicJsonType >::number_buffer {{}}
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().

◆ o

◆ string_buffer

template<typename BasicJsonType >
std::array<char, 512> nlohmann::detail::serializer< BasicJsonType >::string_buffer {{}}
private

string buffer

Definition at line 16373 of file json.h.

Referenced by nlohmann::detail::serializer< BasicJsonType >::dump_escaped().

◆ thousands_sep

template<typename BasicJsonType >
const char nlohmann::detail::serializer< BasicJsonType >::thousands_sep = '\0'
private

the locale's thousand separator character

Definition at line 16368 of file json.h.

Referenced by nlohmann::detail::serializer< BasicJsonType >::dump_float().

◆ UTF8_ACCEPT

template<typename BasicJsonType >
constexpr std::uint8_t nlohmann::detail::serializer< BasicJsonType >::UTF8_ACCEPT = 0
staticconstexprprivate

◆ UTF8_REJECT

template<typename BasicJsonType >
constexpr std::uint8_t nlohmann::detail::serializer< BasicJsonType >::UTF8_REJECT = 1
staticconstexprprivate

The documentation for this class was generated from the following file: