ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nlohmann::detail::binary_writer< BasicJsonType, CharType > Class Template Reference

serialization to CBOR and MessagePack values More...

#include <acts/blob/master/thirdparty/nlohmann_json/single_include/nlohmann/json.hpp>

Public Member Functions

 binary_writer (output_adapter_t< CharType > adapter)
 create a binary writer
 
void write_bson (const BasicJsonType &j)
 
void write_cbor (const BasicJsonType &j)
 
void write_msgpack (const BasicJsonType &j)
 
void write_ubjson (const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix=true)
 

Static Public Member Functions

template<typename C = CharType, enable_if_t< std::is_signed< C >::value and std::is_signed< char >::value > * = nullptr>
static constexpr CharType to_char_type (std::uint8_t x) noexcept
 
template<typename C = CharType, enable_if_t< std::is_signed< C >::value and std::is_unsigned< char >::value > * = nullptr>
static CharType to_char_type (std::uint8_t x) noexcept
 
template<typename C = CharType, enable_if_t< std::is_unsigned< C >::value > * = nullptr>
static constexpr CharType to_char_type (std::uint8_t x) noexcept
 
template<typename InputCharType , typename C = CharType, enable_if_t< std::is_signed< C >::value andstd::is_signed< char >::value andstd::is_same< char, typename std::remove_cv< InputCharType >::type >::value > * = nullptr>
static constexpr CharType to_char_type (InputCharType x) noexcept
 

Private Types

using string_t = typename BasicJsonType::string_t
 

Private Member Functions

void write_bson_entry_header (const string_t &name, const std::uint8_t element_type)
 Writes the given element_type and name to the output adapter.
 
void write_bson_boolean (const string_t &name, const bool value)
 Writes a BSON element with key name and boolean value value.
 
void write_bson_double (const string_t &name, const double value)
 Writes a BSON element with key name and double value value.
 
void write_bson_string (const string_t &name, const string_t &value)
 Writes a BSON element with key name and string value value.
 
void write_bson_null (const string_t &name)
 Writes a BSON element with key name and null value.
 
void write_bson_integer (const string_t &name, const std::int64_t value)
 Writes a BSON element with key name and integer value.
 
void write_bson_unsigned (const string_t &name, const std::uint64_t value)
 Writes a BSON element with key name and unsigned value.
 
void write_bson_object_entry (const string_t &name, const typename BasicJsonType::object_t &value)
 Writes a BSON element with key name and object value.
 
void write_bson_array (const string_t &name, const typename BasicJsonType::array_t &value)
 Writes a BSON element with key name and array value.
 
void write_bson_element (const string_t &name, const BasicJsonType &j)
 Serializes the JSON value j to BSON and associates it with the key name.
 
void write_bson_object (const typename BasicJsonType::object_t &value)
 
template<typename NumberType , typename std::enable_if< std::is_floating_point< NumberType >::value, int >::type = 0>
void write_number_with_ubjson_prefix (const NumberType n, const bool add_prefix)
 
template<typename NumberType , typename std::enable_if< std::is_unsigned< NumberType >::value, int >::type = 0>
void write_number_with_ubjson_prefix (const NumberType n, const bool add_prefix)
 
template<typename NumberType , typename std::enable_if< std::is_signed< NumberType >::value andnot std::is_floating_point< NumberType >::value, int >::type = 0>
void write_number_with_ubjson_prefix (const NumberType n, const bool add_prefix)
 
CharType ubjson_prefix (const BasicJsonType &j) const noexcept
 determine the type prefix of container values
 
template<typename NumberType , bool OutputIsLittleEndian = false>
void write_number (const NumberType n)
 

Static Private Member Functions

static std::size_t calc_bson_entry_header_size (const string_t &name)
 
static std::size_t calc_bson_string_size (const string_t &value)
 
static std::size_t calc_bson_integer_size (const std::int64_t value)
 
static constexpr std::size_t calc_bson_unsigned_size (const std::uint64_t value) noexcept
 
static std::size_t calc_bson_array_size (const typename BasicJsonType::array_t &value)
 
static std::size_t calc_bson_element_size (const string_t &name, const BasicJsonType &j)
 Calculates the size necessary to serialize the JSON value j with its name.
 
static std::size_t calc_bson_object_size (const typename BasicJsonType::object_t &value)
 Calculates the size of the BSON serialization of the given JSON-object j.
 
static constexpr CharType get_cbor_float_prefix (float)
 
static constexpr CharType get_cbor_float_prefix (double)
 
static constexpr CharType get_msgpack_float_prefix (float)
 
static constexpr CharType get_msgpack_float_prefix (double)
 
static constexpr CharType get_ubjson_float_prefix (float)
 
static constexpr CharType get_ubjson_float_prefix (double)
 

Private Attributes

const bool is_little_endian = binary_reader<BasicJsonType>::little_endianess()
 whether we can assume little endianess
 
output_adapter_t< CharType > oa = nullptr
 the output
 

Detailed Description

template<typename BasicJsonType, typename CharType>
class nlohmann::detail::binary_writer< BasicJsonType, CharType >

serialization to CBOR and MessagePack values

Definition at line 11318 of file json.hpp.

View newest version in sPHENIX GitHub at line 11318 of file json.hpp

Member Typedef Documentation

template<typename BasicJsonType , typename CharType >
using nlohmann::detail::binary_writer< BasicJsonType, CharType >::string_t = typename BasicJsonType::string_t
private

Definition at line 11320 of file json.hpp.

View newest version in sPHENIX GitHub at line 11320 of file json.hpp

Constructor & Destructor Documentation

template<typename BasicJsonType , typename CharType >
nlohmann::detail::binary_writer< BasicJsonType, CharType >::binary_writer ( output_adapter_t< CharType >  adapter)
inlineexplicit

create a binary writer

Parameters
[in]adapteroutput adapter to write to

Definition at line 11328 of file json.hpp.

View newest version in sPHENIX GitHub at line 11328 of file json.hpp

Member Function Documentation

template<typename BasicJsonType , typename CharType >
static std::size_t nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_array_size ( const typename BasicJsonType::array_t &  value)
inlinestaticprivate
Returns
The size of the BSON-encoded array value

Definition at line 12154 of file json.hpp.

View newest version in sPHENIX GitHub at line 12154 of file json.hpp

References nlohmann::to_string().

+ Here is the call graph for this function:

template<typename BasicJsonType , typename CharType >
static std::size_t nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_element_size ( const string_t name,
const BasicJsonType &  j 
)
inlinestaticprivate

Calculates the size necessary to serialize the JSON value j with its name.

Returns
The calculated size for the BSON document entry for j with the given name.

Definition at line 12189 of file json.hpp.

View newest version in sPHENIX GitHub at line 12189 of file json.hpp

template<typename BasicJsonType , typename CharType >
static std::size_t nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_entry_header_size ( const string_t name)
inlinestaticprivate
Returns
The size of a BSON document entry header, including the id marker and the entry name size (and its null-terminator).

Definition at line 12007 of file json.hpp.

View newest version in sPHENIX GitHub at line 12007 of file json.hpp

References it, JSON_HEDLEY_UNLIKELY, JSON_THROW, nlohmann::to_string(), and Acts::UnitConstants::u.

+ Here is the call graph for this function:

template<typename BasicJsonType , typename CharType >
static std::size_t nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_integer_size ( const std::int64_t  value)
inlinestaticprivate
Returns
The size of the BSON-encoded integer value

Definition at line 12084 of file json.hpp.

View newest version in sPHENIX GitHub at line 12084 of file json.hpp

References max, and min.

template<typename BasicJsonType , typename CharType >
static std::size_t nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_object_size ( const typename BasicJsonType::object_t &  value)
inlinestaticprivate

Calculates the size of the BSON serialization of the given JSON-object j.

Parameters
[in]jJSON value to serialize
Precondition
j.type() == value_t::object

Definition at line 12277 of file json.hpp.

View newest version in sPHENIX GitHub at line 12277 of file json.hpp

template<typename BasicJsonType , typename CharType >
static std::size_t nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_string_size ( const string_t value)
inlinestaticprivate
Returns
The size of the BSON-encoded string in value

Definition at line 12054 of file json.hpp.

View newest version in sPHENIX GitHub at line 12054 of file json.hpp

template<typename BasicJsonType , typename CharType >
static constexpr std::size_t nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_unsigned_size ( const std::uint64_t  value)
inlinestaticprivatenoexcept
Returns
The size of the BSON-encoded unsigned integer in j

Definition at line 12112 of file json.hpp.

View newest version in sPHENIX GitHub at line 12112 of file json.hpp

References max.

template<typename BasicJsonType , typename CharType >
static constexpr CharType nlohmann::detail::binary_writer< BasicJsonType, CharType >::get_cbor_float_prefix ( float  )
inlinestaticprivate

Definition at line 12308 of file json.hpp.

View newest version in sPHENIX GitHub at line 12308 of file json.hpp

template<typename BasicJsonType , typename CharType >
static constexpr CharType nlohmann::detail::binary_writer< BasicJsonType, CharType >::get_cbor_float_prefix ( double  )
inlinestaticprivate

Definition at line 12313 of file json.hpp.

View newest version in sPHENIX GitHub at line 12313 of file json.hpp

template<typename BasicJsonType , typename CharType >
static constexpr CharType nlohmann::detail::binary_writer< BasicJsonType, CharType >::get_msgpack_float_prefix ( float  )
inlinestaticprivate

Definition at line 12322 of file json.hpp.

View newest version in sPHENIX GitHub at line 12322 of file json.hpp

template<typename BasicJsonType , typename CharType >
static constexpr CharType nlohmann::detail::binary_writer< BasicJsonType, CharType >::get_msgpack_float_prefix ( double  )
inlinestaticprivate

Definition at line 12327 of file json.hpp.

View newest version in sPHENIX GitHub at line 12327 of file json.hpp

template<typename BasicJsonType , typename CharType >
static constexpr CharType nlohmann::detail::binary_writer< BasicJsonType, CharType >::get_ubjson_float_prefix ( float  )
inlinestaticprivate

Definition at line 12536 of file json.hpp.

View newest version in sPHENIX GitHub at line 12536 of file json.hpp

template<typename BasicJsonType , typename CharType >
static constexpr CharType nlohmann::detail::binary_writer< BasicJsonType, CharType >::get_ubjson_float_prefix ( double  )
inlinestaticprivate

Definition at line 12541 of file json.hpp.

View newest version in sPHENIX GitHub at line 12541 of file json.hpp

template<typename BasicJsonType , typename CharType >
template<typename C = CharType, enable_if_t< std::is_signed< C >::value and std::is_signed< char >::value > * = nullptr>
static constexpr CharType nlohmann::detail::binary_writer< BasicJsonType, CharType >::to_char_type ( std::uint8_t  x)
inlinestaticnoexcept

Definition at line 12585 of file json.hpp.

View newest version in sPHENIX GitHub at line 12585 of file json.hpp

References x.

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

+ Here is the caller graph for this function:

template<typename BasicJsonType , typename CharType >
template<typename C = CharType, enable_if_t< std::is_signed< C >::value and std::is_unsigned< char >::value > * = nullptr>
static CharType nlohmann::detail::binary_writer< BasicJsonType, CharType >::to_char_type ( std::uint8_t  x)
inlinestaticnoexcept

Definition at line 12592 of file json.hpp.

View newest version in sPHENIX GitHub at line 12592 of file json.hpp

References x.

template<typename BasicJsonType , typename CharType >
template<typename C = CharType, enable_if_t< std::is_unsigned< C >::value > * = nullptr>
static constexpr CharType nlohmann::detail::binary_writer< BasicJsonType, CharType >::to_char_type ( std::uint8_t  x)
inlinestaticnoexcept

Definition at line 12603 of file json.hpp.

View newest version in sPHENIX GitHub at line 12603 of file json.hpp

References x.

template<typename BasicJsonType , typename CharType >
template<typename InputCharType , typename C = CharType, enable_if_t< std::is_signed< C >::value andstd::is_signed< char >::value andstd::is_same< char, typename std::remove_cv< InputCharType >::type >::value > * = nullptr>
static constexpr CharType nlohmann::detail::binary_writer< BasicJsonType, CharType >::to_char_type ( InputCharType  x)
inlinestaticnoexcept

Definition at line 12614 of file json.hpp.

View newest version in sPHENIX GitHub at line 12614 of file json.hpp

References x.

template<typename BasicJsonType , typename CharType >
CharType nlohmann::detail::binary_writer< BasicJsonType, CharType >::ubjson_prefix ( const BasicJsonType &  j) const
inlineprivatenoexcept

determine the type prefix of container values

Note
This function does not need to be 100% accurate when it comes to integer limits. In case a number exceeds the limits of int64_t, this will be detected by a later call to function write_number_with_ubjson_prefix. Therefore, we return 'L' for any value that does not fit the previous limits.

Definition at line 12465 of file json.hpp.

View newest version in sPHENIX GitHub at line 12465 of file json.hpp

References max, and min.

template<typename BasicJsonType , typename CharType >
void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson ( const BasicJsonType &  j)
inline
Parameters
[in]jJSON value to serialize
Precondition
j.type() == value_t::object

Definition at line 11337 of file json.hpp.

View newest version in sPHENIX GitHub at line 11337 of file json.hpp

References JSON_THROW.

template<typename BasicJsonType , typename CharType >
void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_array ( const string_t name,
const typename BasicJsonType::array_t &  value 
)
inlineprivate

Writes a BSON element with key name and array value.

Definition at line 12169 of file json.hpp.

View newest version in sPHENIX GitHub at line 12169 of file json.hpp

References nlohmann::to_string().

+ Here is the call graph for this function:

template<typename BasicJsonType , typename CharType >
void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_boolean ( const string_t name,
const bool  value 
)
inlineprivate

Writes a BSON element with key name and boolean value value.

Definition at line 12034 of file json.hpp.

View newest version in sPHENIX GitHub at line 12034 of file json.hpp

template<typename BasicJsonType , typename CharType >
void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_double ( const string_t name,
const double  value 
)
inlineprivate

Writes a BSON element with key name and double value value.

Definition at line 12044 of file json.hpp.

View newest version in sPHENIX GitHub at line 12044 of file json.hpp

template<typename BasicJsonType , typename CharType >
void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_element ( const string_t name,
const BasicJsonType &  j 
)
inlineprivate

Serializes the JSON value j to BSON and associates it with the key name.

Parameters
nameThe name to associate with the JSON entity j within the current BSON document
Returns
The size of the BSON entry

Definition at line 12234 of file json.hpp.

View newest version in sPHENIX GitHub at line 12234 of file json.hpp

template<typename BasicJsonType , typename CharType >
void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_entry_header ( const string_t name,
const std::uint8_t  element_type 
)
inlineprivate

Writes the given element_type and name to the output adapter.

Definition at line 12022 of file json.hpp.

View newest version in sPHENIX GitHub at line 12022 of file json.hpp

References Acts::UnitConstants::u.

template<typename BasicJsonType , typename CharType >
void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_integer ( const string_t name,
const std::int64_t  value 
)
inlineprivate

Writes a BSON element with key name and integer value.

Definition at line 12094 of file json.hpp.

View newest version in sPHENIX GitHub at line 12094 of file json.hpp

References max, and min.

template<typename BasicJsonType , typename CharType >
void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_null ( const string_t name)
inlineprivate

Writes a BSON element with key name and null value.

Definition at line 12076 of file json.hpp.

View newest version in sPHENIX GitHub at line 12076 of file json.hpp

template<typename BasicJsonType , typename CharType >
void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_object ( const typename BasicJsonType::object_t &  value)
inlineprivate
Parameters
[in]jJSON value to serialize
Precondition
j.type() == value_t::object

Definition at line 12292 of file json.hpp.

View newest version in sPHENIX GitHub at line 12292 of file json.hpp

template<typename BasicJsonType , typename CharType >
void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_object_entry ( const string_t name,
const typename BasicJsonType::object_t &  value 
)
inlineprivate

Writes a BSON element with key name and object value.

Definition at line 12144 of file json.hpp.

View newest version in sPHENIX GitHub at line 12144 of file json.hpp

template<typename BasicJsonType , typename CharType >
void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_string ( const string_t name,
const string_t value 
)
inlineprivate

Writes a BSON element with key name and string value value.

Definition at line 12062 of file json.hpp.

View newest version in sPHENIX GitHub at line 12062 of file json.hpp

template<typename BasicJsonType , typename CharType >
void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_unsigned ( const string_t name,
const std::uint64_t  value 
)
inlineprivate

Writes a BSON element with key name and unsigned value.

Definition at line 12122 of file json.hpp.

View newest version in sPHENIX GitHub at line 12122 of file json.hpp

References JSON_THROW, max, and nlohmann::to_string().

+ Here is the call graph for this function:

template<typename BasicJsonType , typename CharType >
void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_cbor ( const BasicJsonType &  j)
inline
Parameters
[in]jJSON value to serialize

Definition at line 11357 of file json.hpp.

View newest version in sPHENIX GitHub at line 11357 of file json.hpp

References max, and N.

template<typename BasicJsonType , typename CharType >
void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_msgpack ( const BasicJsonType &  j)
inline
Parameters
[in]jJSON value to serialize

Definition at line 11601 of file json.hpp.

View newest version in sPHENIX GitHub at line 11601 of file json.hpp

References max, min, and N.

template<typename BasicJsonType , typename CharType >
template<typename NumberType , bool OutputIsLittleEndian = false>
void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number ( const NumberType  n)
inlineprivate

Definition at line 12562 of file json.hpp.

View newest version in sPHENIX GitHub at line 12562 of file json.hpp

References n, and reverse.

template<typename BasicJsonType , typename CharType >
template<typename NumberType , typename std::enable_if< std::is_floating_point< NumberType >::value, int >::type = 0>
void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number_with_ubjson_prefix ( const NumberType  n,
const bool  add_prefix 
)
inlineprivate

Definition at line 12339 of file json.hpp.

View newest version in sPHENIX GitHub at line 12339 of file json.hpp

template<typename BasicJsonType , typename CharType >
template<typename NumberType , typename std::enable_if< std::is_unsigned< NumberType >::value, int >::type = 0>
void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number_with_ubjson_prefix ( const NumberType  n,
const bool  add_prefix 
)
inlineprivate

Definition at line 12352 of file json.hpp.

View newest version in sPHENIX GitHub at line 12352 of file json.hpp

References JSON_THROW, max, and nlohmann::to_string().

+ Here is the call graph for this function:

template<typename BasicJsonType , typename CharType >
template<typename NumberType , typename std::enable_if< std::is_signed< NumberType >::value andnot std::is_floating_point< NumberType >::value, int >::type = 0>
void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number_with_ubjson_prefix ( const NumberType  n,
const bool  add_prefix 
)
inlineprivate

Definition at line 12405 of file json.hpp.

View newest version in sPHENIX GitHub at line 12405 of file json.hpp

References JSON_THROW, max, min, and nlohmann::to_string().

+ Here is the call graph for this function:

template<typename BasicJsonType , typename CharType >
void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_ubjson ( const BasicJsonType &  j,
const bool  use_count,
const bool  use_type,
const bool  add_prefix = true 
)
inline
Parameters
[in]jJSON value to serialize
[in]use_countwhether to use '#' prefixes (optimized format)
[in]use_typewhether to use '$' prefixes (optimized format)
[in]add_prefixwhether prefixes need to be used for this value

Definition at line 11843 of file json.hpp.

View newest version in sPHENIX GitHub at line 11843 of file json.hpp

References v.

Member Data Documentation

template<typename BasicJsonType , typename CharType >
const bool nlohmann::detail::binary_writer< BasicJsonType, CharType >::is_little_endian = binary_reader<BasicJsonType>::little_endianess()
private

whether we can assume little endianess

Definition at line 12621 of file json.hpp.

View newest version in sPHENIX GitHub at line 12621 of file json.hpp

template<typename BasicJsonType , typename CharType >
output_adapter_t<CharType> nlohmann::detail::binary_writer< BasicJsonType, CharType >::oa = nullptr
private

the output

Definition at line 12624 of file json.hpp.

View newest version in sPHENIX GitHub at line 12624 of file json.hpp


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