BmnRoot
Loading...
Searching...
No Matches
nlohmann::detail::serializer< BasicJsonType > Class Template Reference

#include <json.hpp>

Collaboration diagram for nlohmann::detail::serializer< BasicJsonType >:
[legend]

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
 
 for (std::size_t i=0;i< s.size();++i)
 
 if (JSON_HEDLEY_LIKELY(state==UTF8_ACCEPT))
 
 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
 
 for (std::size_t i=0;i< s.size();++i)
 
 if (JSON_HEDLEY_LIKELY(state==UTF8_ACCEPT))
 
 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
 
 for (std::size_t i=0;i< s.size();++i)
 
 if (JSON_HEDLEY_LIKELY(state==UTF8_ACCEPT))
 

Public Attributes

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

Detailed Description

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

Definition at line 16085 of file json.hpp.

Constructor & Destructor Documentation

◆ serializer() [1/9]

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

◆ serializer() [2/9]

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

◆ serializer() [3/9]

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

◆ ~serializer() [1/3]

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

◆ serializer() [4/9]

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

◆ serializer() [5/9]

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

◆ serializer() [6/9]

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

◆ ~serializer() [2/3]

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

◆ serializer() [7/9]

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

◆ serializer() [8/9]

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

◆ serializer() [9/9]

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

◆ ~serializer() [3/3]

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

Member Function Documentation

◆ dump() [1/3]

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

References nlohmann::detail::array, nlohmann::detail::binary, nlohmann::detail::boolean, nlohmann::detail::discarded, nlohmann::detail::serializer< BasicJsonType >::dump(), nlohmann::detail::serializer< BasicJsonType >::ensure_ascii, i, nlohmann::detail::serializer< BasicJsonType >::indent_string, JSON_ASSERT, JSON_HEDLEY_UNLIKELY, nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::object, and nlohmann::detail::string.

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

◆ dump() [2/3]

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

References nlohmann::detail::array, nlohmann::detail::binary, nlohmann::detail::boolean, nlohmann::detail::discarded, nlohmann::detail::serializer< BasicJsonType >::dump(), nlohmann::detail::serializer< BasicJsonType >::ensure_ascii, i, nlohmann::detail::serializer< BasicJsonType >::indent_string, JSON_ASSERT, JSON_HEDLEY_UNLIKELY, nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::object, and nlohmann::detail::string.

◆ dump() [3/3]

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

References nlohmann::detail::array, nlohmann::detail::binary, nlohmann::detail::boolean, nlohmann::detail::discarded, nlohmann::detail::serializer< BasicJsonType >::dump(), nlohmann::detail::serializer< BasicJsonType >::ensure_ascii, i, nlohmann::detail::serializer< BasicJsonType >::indent_string, JSON_ASSERT, JSON_HEDLEY_UNLIKELY, nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::object, and nlohmann::detail::string.

◆ for() [1/3]

◆ for() [2/3]

◆ for() [3/3]

◆ if() [1/3]

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

◆ if() [2/3]

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

◆ if() [3/3]

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

◆ operator=() [1/6]

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

◆ operator=() [2/6]

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

◆ operator=() [3/6]

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

◆ operator=() [4/6]

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

◆ operator=() [5/6]

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

◆ operator=() [6/6]

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

Member Data Documentation

◆ __pad0__

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

Definition at line 16410 of file json.hpp.

◆ bytes

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

◆ bytes_after_last_accept

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

Definition at line 16432 of file json.hpp.

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

◆ decimal_point

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

the locale's decimal point character

Definition at line 16997 of file json.hpp.

◆ else

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

Definition at line 16634 of file json.hpp.

◆ ensure_ascii

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

Definition at line 16425 of file json.hpp.

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

◆ error_handler

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

error_handler how to react on decoding errors

Definition at line 17008 of file json.hpp.

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

◆ indent_char

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

the indentation character

Definition at line 17003 of file json.hpp.

◆ indent_string

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

the indentation string

Definition at line 17005 of file json.hpp.

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

◆ loc

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

the locale

Definition at line 16993 of file json.hpp.

◆ number_buffer

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

a (hopefully) large enough character buffer

Definition at line 16990 of file json.hpp.

◆ state

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

Definition at line 16428 of file json.hpp.

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

◆ string_buffer

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

◆ thousands_sep

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

the locale's thousand separator character

Definition at line 16995 of file json.hpp.

◆ undumped_chars

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

Definition at line 16433 of file json.hpp.

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


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