flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY
nlohmann::json_abi_v3_11_3::detail::serializer< BasicJsonType > Class Template Reference

#include <json.hpp>

Collaboration diagram for nlohmann::json_abi_v3_11_3::detail::serializer< BasicJsonType >:
Collaboration graph

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
 
serializeroperator= (serializer &&)=delete
 
 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
 

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
 

Private Member Functions

unsigned int count_digits (number_unsigned_t x) noexcept
 count digits More...
 
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::false_type)
 
void dump_float (number_float_t x, std::true_type)
 
template<typename NumberType , detail::enable_if_t< std::is_integral< NumberType >::value||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 dump_integer (NumberType x)
 dump an integer More...
 
template<typename NumberType , enable_if_t< std::is_signed< NumberType >::value, int > = 0>
bool is_negative_number (NumberType x)
 
template<typename NumberType , enable_if_t< std::is_unsigned< NumberType >::value, int > = 0>
bool is_negative_number (NumberType)
 
number_unsigned_t remove_sign (number_integer_t x) noexcept
 
number_unsigned_t remove_sign (number_unsigned_t x)
 

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...
 
static std::string hex_bytes (std::uint8_t byte)
 convert a byte to a uppercase hex representation More...
 

Private Attributes

const char decimal_point = '\0'
 the locale's decimal point character More...
 
const error_handler_t error_handler
 error_handler how to react on decoding errors 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 std::uint8_t UTF8_ACCEPT = 0
 
static constexpr std::uint8_t UTF8_REJECT = 1
 

Detailed Description

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

Definition at line 18059 of file json.hpp.

Member Typedef Documentation

◆ binary_char_t

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

Definition at line 18065 of file json.hpp.

◆ number_float_t

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

Definition at line 18062 of file json.hpp.

◆ number_integer_t

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

Definition at line 18063 of file json.hpp.

◆ number_unsigned_t

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

Definition at line 18064 of file json.hpp.

◆ string_t

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

Definition at line 18061 of file json.hpp.

Constructor & Destructor Documentation

◆ serializer() [1/3]

template<typename BasicJsonType >
nlohmann::json_abi_v3_11_3::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 18075 of file json.hpp.

◆ serializer() [2/3]

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

◆ serializer() [3/3]

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

◆ ~serializer()

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

Member Function Documentation

◆ count_digits()

template<typename BasicJsonType >
unsigned int nlohmann::json_abi_v3_11_3::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 18654 of file json.hpp.

◆ decode()

template<typename BasicJsonType >
static std::uint8_t nlohmann::json_abi_v3_11_3::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 18908 of file json.hpp.

References JSON_ASSERT.

◆ dump()

template<typename BasicJsonType >
void nlohmann::json_abi_v3_11_3::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 18115 of file json.hpp.

References JSON_ASSERT, and JSON_HEDLEY_UNLIKELY.

◆ dump_escaped()

template<typename BasicJsonType >
void nlohmann::json_abi_v3_11_3::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 18399 of file json.hpp.

References nlohmann::json_abi_v3_11_3::detail::concat(), JSON_ASSERT, JSON_HEDLEY_LIKELY, JSON_THROW, and nlohmann::json_abi_v3_11_3::to_string().

◆ dump_float() [1/3]

template<typename BasicJsonType >
void nlohmann::json_abi_v3_11_3::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 18807 of file json.hpp.

◆ dump_float() [2/3]

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

Definition at line 18836 of file json.hpp.

References nlohmann::json_abi_v3_11_3::detail2::end(), and JSON_ASSERT.

◆ dump_float() [3/3]

template<typename BasicJsonType >
void nlohmann::json_abi_v3_11_3::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_integral< NumberType >::value||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::json_abi_v3_11_3::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 18722 of file json.hpp.

References JSON_ASSERT.

◆ hex_bytes()

template<typename BasicJsonType >
static std::string nlohmann::json_abi_v3_11_3::detail::serializer< BasicJsonType >::hex_bytes ( std::uint8_t  byte)
inlinestaticprivate

convert a byte to a uppercase hex representation

Parameters
[in]bytebyte to represent
Returns
representation ("00".."FF")

Definition at line 18685 of file json.hpp.

◆ is_negative_number() [1/2]

template<typename BasicJsonType >
template<typename NumberType , enable_if_t< std::is_signed< NumberType >::value, int > = 0>
bool nlohmann::json_abi_v3_11_3::detail::serializer< BasicJsonType >::is_negative_number ( NumberType  x)
inlineprivate

Definition at line 18696 of file json.hpp.

◆ is_negative_number() [2/2]

template<typename BasicJsonType >
template<typename NumberType , enable_if_t< std::is_unsigned< NumberType >::value, int > = 0>
bool nlohmann::json_abi_v3_11_3::detail::serializer< BasicJsonType >::is_negative_number ( NumberType  )
inlineprivate

Definition at line 18702 of file json.hpp.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ remove_sign() [1/2]

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

Definition at line 18963 of file json.hpp.

References JSON_ASSERT.

◆ remove_sign() [2/2]

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

Definition at line 18948 of file json.hpp.

References JSON_ASSERT.

Member Data Documentation

◆ decimal_point

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

the locale's decimal point character

Definition at line 18981 of file json.hpp.

◆ error_handler

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

error_handler how to react on decoding errors

Definition at line 18992 of file json.hpp.

◆ indent_char

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

the indentation character

Definition at line 18987 of file json.hpp.

◆ indent_string

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

the indentation string

Definition at line 18989 of file json.hpp.

◆ loc

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

the locale

Definition at line 18977 of file json.hpp.

◆ number_buffer

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

a (hopefully) large enough character buffer

Definition at line 18974 of file json.hpp.

◆ o

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

the output of the serializer

Definition at line 18971 of file json.hpp.

◆ string_buffer

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

string buffer

Definition at line 18984 of file json.hpp.

◆ thousands_sep

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

the locale's thousand separator character

Definition at line 18979 of file json.hpp.

◆ UTF8_ACCEPT

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

Definition at line 18066 of file json.hpp.

◆ UTF8_REJECT

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

Definition at line 18067 of file json.hpp.


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