A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
detail::serializer< BasicJsonType > Class Template Reference

#include "json.h"

+ Collaboration diagram for detail::serializer< BasicJsonType >:

Public Member Functions

 serializer (const serializer &)=delete
 
 serializer (output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
 
 serializer (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
 
 for (std::size_t i=0;i< s.size();++i)
 
 if (JSON_HEDLEY_LIKELY(state==UTF8_ACCEPT))
 
serializeroperator= (const serializer &)=delete
 
serializeroperator= (serializer &&)=delete
 

Public Attributes

JSON_PRIVATE_UNLESS_TESTED : void dump_escaped(const string_t& s
 
std::size_t bytes = 0
 
std::size_t bytes_after_last_accept = 0
 
const char decimal_point = '\0'
 the locale's decimal point character
 
 else
 
JSON_PRIVATE_UNLESS_TESTED const bool ensure_ascii
 
const error_handler_t error_handler
 error_handler how to react on decoding errors
 
const char indent_char
 the indentation character
 
string_t indent_string
 the indentation string
 
const std::lconv * loc = nullptr
 the locale
 
std::array< char, 64 > number_buffer {{}}
 a (hopefully) large enough character buffer
 
std::uint8_t state = UTF8_ACCEPT
 
std::array< char, 512 > string_buffer {{}}
 string buffer
 
const char thousands_sep = '\0'
 the locale's thousand separator character
 
std::size_t undumped_chars = 0
 

Private Types

using binary_char_t = typename BasicJsonType::binary_t::value_type
 
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
 

Static Private Attributes

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

Detailed Description

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

Definition at line 18863 of file json.h.

Member Typedef Documentation

◆ binary_char_t

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

Definition at line 18869 of file json.h.

◆ number_float_t

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

Definition at line 18866 of file json.h.

◆ number_integer_t

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

Definition at line 18867 of file json.h.

◆ number_unsigned_t

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

Definition at line 18868 of file json.h.

◆ string_t

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

Definition at line 18865 of file json.h.

Constructor & Destructor Documentation

◆ serializer() [1/3]

template<typename BasicJsonType >
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 18879 of file json.h.

◆ serializer() [2/3]

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

◆ serializer() [3/3]

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

◆ ~serializer()

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

Member Function Documentation

◆ dump()

template<typename BasicJsonType >
void 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 18919 of file json.h.

References JSON_ASSERT, and JSON_HEDLEY_UNLIKELY.

◆ for()

template<typename BasicJsonType >
detail::serializer< BasicJsonType >::for ( )
inline

Definition at line 19213 of file json.h.

References detail::concat(), JSON_ASSERT, JSON_THROW, and detail::binary_writer< BasicJsonType, CharType >::to_char_type().

+ Here is the call graph for this function:

◆ if()

template<typename BasicJsonType >
detail::serializer< BasicJsonType >::if ( JSON_HEDLEY_LIKELY(state==UTF8_ACCEPT )
inline

Definition at line 19402 of file json.h.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

Member Data Documentation

◆ __pad0__

template<typename BasicJsonType >
JSON_PRIVATE_UNLESS_TESTED detail::serializer< BasicJsonType >::__pad0__

Definition at line 19188 of file json.h.

◆ bytes

template<typename BasicJsonType >
std::size_t detail::serializer< BasicJsonType >::bytes = 0

Definition at line 19207 of file json.h.

◆ bytes_after_last_accept

template<typename BasicJsonType >
std::size_t detail::serializer< BasicJsonType >::bytes_after_last_accept = 0

Definition at line 19210 of file json.h.

◆ decimal_point

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

the locale's decimal point character

Definition at line 19785 of file json.h.

◆ else

template<typename BasicJsonType >
detail::serializer< BasicJsonType >::else

Definition at line 19410 of file json.h.

◆ ensure_ascii

template<typename BasicJsonType >
JSON_PRIVATE_UNLESS_TESTED const bool detail::serializer< BasicJsonType >::ensure_ascii
Initial value:
{
std::uint32_t codepoint{}

Definition at line 19203 of file json.h.

◆ error_handler

template<typename BasicJsonType >
const error_handler_t detail::serializer< BasicJsonType >::error_handler

error_handler how to react on decoding errors

Definition at line 19796 of file json.h.

◆ indent_char

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

the indentation character

Definition at line 19791 of file json.h.

◆ indent_string

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

the indentation string

Definition at line 19793 of file json.h.

◆ loc

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

the locale

Definition at line 19781 of file json.h.

◆ number_buffer

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

a (hopefully) large enough character buffer

Definition at line 19778 of file json.h.

◆ state

template<typename BasicJsonType >
std::uint8_t detail::serializer< BasicJsonType >::state = UTF8_ACCEPT

Definition at line 19206 of file json.h.

◆ string_buffer

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

string buffer

Definition at line 19788 of file json.h.

◆ thousands_sep

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

the locale's thousand separator character

Definition at line 19783 of file json.h.

◆ undumped_chars

template<typename BasicJsonType >
std::size_t detail::serializer< BasicJsonType >::undumped_chars = 0

Definition at line 19211 of file json.h.

◆ UTF8_ACCEPT

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

Definition at line 18870 of file json.h.

◆ UTF8_REJECT

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

Definition at line 18871 of file json.h.


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