Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
nlohmann::detail::serializer< BasicJsonType > Class Template Reference

#include <json.hpp>

Public Member Functions

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...
 
serializeroperator= (const serializer &)=delete
 
 serializer (output_adapter_t< char > s, const char ichar)
 
 serializer (const serializer &)=delete
 

Private Types

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
 
using string_t = typename BasicJsonType::string_t
 

Private Member Functions

void dump_escaped (const string_t &s, const bool ensure_ascii)
 dump escaped string 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)
 
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...
 

Static Private Member Functions

static uint8_t decode (uint8_t &state, uint32_t &codep, const uint8_t byte) noexcept
 check whether a string is UTF-8 encoded More...
 

Private Attributes

const char decimal_point = '\0'
 the locale's decimal point character More...
 
const char indent_char
 the indentation character More...
 
string_t indent_string
 the indentation string More...
 
const std::lconv * loc = nullptr
 the locale More...
 
std::array< char, 64 > number_buffer {{}}
 a (hopefully) large enough character buffer More...
 
output_adapter_t< char > o = nullptr
 the output of the serializer More...
 
std::array< char, 512 > string_buffer {{}}
 string buffer More...
 
const char thousands_sep = '\0'
 the locale's thousand separator character More...
 

Static Private Attributes

static constexpr uint8_t UTF8_ACCEPT = 0
 
static constexpr uint8_t UTF8_REJECT = 1
 

Detailed Description

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

Definition at line 8265 of file json.hpp.

Member Typedef Documentation

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

Definition at line 8268 of file json.hpp.

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

Definition at line 8269 of file json.hpp.

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

Definition at line 8270 of file json.hpp.

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

Definition at line 8267 of file json.hpp.

Constructor & Destructor Documentation

template<typename BasicJsonType >
nlohmann::detail::serializer< BasicJsonType >::serializer ( output_adapter_t< char >  s,
const char  ichar 
)
inline
Parameters
[in]soutput stream to serialize to
[in]icharindentation character to use

Definition at line 8279 of file json.hpp.

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

Member Function Documentation

template<typename BasicJsonType >
static uint8_t nlohmann::detail::serializer< BasicJsonType >::decode ( uint8_t &  state,
uint32_t &  codep,
const 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 8809 of file json.hpp.

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
Parameters
[in]valvalue to serialize
[in]pretty_printwhether the output shall be pretty-printed
[in]indent_stepthe indent level
[in]current_indentthe current indent level (only used internally)

Definition at line 8307 of file json.hpp.

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 sequences

Linear in the length of string s.

Definition at line 8514 of file json.hpp.

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 8710 of file json.hpp.

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

Definition at line 8731 of file json.hpp.

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

Definition at line 8739 of file json.hpp.

template<typename BasicJsonType >
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 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 8669 of file json.hpp.

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

Member Data Documentation

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

the locale's decimal point character

Definition at line 8853 of file json.hpp.

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

the indentation character

Definition at line 8859 of file json.hpp.

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

the indentation string

Definition at line 8861 of file json.hpp.

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

the locale

Definition at line 8849 of file json.hpp.

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

a (hopefully) large enough character buffer

Definition at line 8846 of file json.hpp.

template<typename BasicJsonType >
output_adapter_t<char> nlohmann::detail::serializer< BasicJsonType >::o = nullptr
private

the output of the serializer

Definition at line 8843 of file json.hpp.

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

string buffer

Definition at line 8856 of file json.hpp.

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

the locale's thousand separator character

Definition at line 8851 of file json.hpp.

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

Definition at line 8271 of file json.hpp.

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

Definition at line 8272 of file json.hpp.


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


json_transport
Author(s): Paul Bovbel
autogenerated on Thu Jun 13 2019 19:12:24