CUDNN Frontend API 8.3.0

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

serialization to CBOR and MessagePack values More...

`#include <json.hpp>`

Collaboration diagram for nlohmann::detail::binary_writer< BasicJsonType, CharType >:

## Public Member Functions
| binary_writer (output_adapter_t< CharType > adapter)
| create a binary writer More...
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 &&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 &&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 &&std::is_signed< char >::value &&std::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
using | binary_t = typename BasicJsonType::binary_t
using | number_float_t = typename BasicJsonType::number_float_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. More...
void | write_bson_boolean (const string_t &name, const bool value)
| Writes a BSON element with key name and boolean value value. More...
void | write_bson_double (const string_t &name, const double value)
| Writes a BSON element with key name and double value value. More...
void | write_bson_string (const string_t &name, const string_t &value)
| Writes a BSON element with key name and string value value. More...
void | write_bson_null (const string_t &name)
| Writes a BSON element with key name and null value. More...
void | write_bson_integer (const string_t &name, const std::int64_t value)
| Writes a BSON element with key name and integer value. More...
void | write_bson_unsigned (const string_t &name, const BasicJsonType &j)
| Writes a BSON element with key name and unsigned value. More...
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. More...
void | write_bson_array (const string_t &name, const typename BasicJsonType::array_t &value)
| Writes a BSON element with key name and array value. More...
void | write_bson_binary (const string_t &name, const binary_t &value)
| Writes a BSON element with key name and binary value value. More...
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. More...
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 &&!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 More...
template<typename NumberType , bool OutputIsLittleEndian = false>
void | write_number (const NumberType n)
void | write_compact_float (const number_float_t n, detail::input_format_t format)

## Static Private Member Functions
static std::size_t | calc_bson_entry_header_size (const string_t &name, const BasicJsonType &j)
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_binary_size (const typename BasicJsonType::binary_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. More...
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. More...
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 = little_endianess()
| whether we can assume little endianess More...
output_adapter_t< CharType > | oa = nullptr
| the output More...

## Detailed Description

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

serialization to CBOR and MessagePack values

Definition at line 13262 of file json.hpp.

## Member Typedef Documentation

## ◆ binary_t

template<typename BasicJsonType , typename CharType >

using nlohmann::detail::binary_writer< BasicJsonType, CharType >::binary_t = typename BasicJsonType::binary_t
| private

Definition at line 13265 of file json.hpp.

## ◆ number_float_t

template<typename BasicJsonType , typename CharType >

using nlohmann::detail::binary_writer< BasicJsonType, CharType >::number_float_t = typename BasicJsonType::number_float_t
| private

Definition at line 13266 of file json.hpp.

## ◆ string_t

template<typename BasicJsonType , typename CharType >

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

Definition at line 13264 of file json.hpp.

## Constructor & Destructor Documentation

## ◆ binary_writer()

template<typename BasicJsonType , typename CharType >

nlohmann::detail::binary_writer< BasicJsonType, CharType >::binary_writer | ( | output_adapter_t< CharType > | adapter | ) |
| inline explicit

create a binary writer

Parameters

  [in] | adapter | output adapter to write to

Definition at line 13274 of file json.hpp.

References JSON_ASSERT.

## Member Function Documentation

## ◆ calc_bson_array_size()

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 | ) |
| inline static private

Returns
  The size of the BSON-encoded array value

Definition at line 14285 of file json.hpp.

References nlohmann::to_string().

## ◆ calc_bson_binary_size()

template<typename BasicJsonType , typename CharType >

static std::size_t nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_binary_size | ( | const typename BasicJsonType::binary_t & | value | ) |
| inline static private

Returns
  The size of the BSON-encoded binary array value

Definition at line 14300 of file json.hpp.

## ◆ calc_bson_element_size()

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
| ) |  |
| inline static private

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

References nlohmann::detail::array, nlohmann::detail::binary, nlohmann::detail::boolean, JSON_ASSERT, nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::object, and nlohmann::detail::string.

## ◆ calc_bson_entry_header_size()

template<typename BasicJsonType , typename CharType >

static std::size_t nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_entry_header_size | ( | const string_t & | name,
|  | const BasicJsonType & | j
| ) |  |
| inline static private

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

References nlohmann::detail::out_of_range::create(), JSON_HEDLEY_UNLIKELY, JSON_THROW, and nlohmann::to_string().

## ◆ calc_bson_integer_size()

template<typename BasicJsonType , typename CharType >

static std::size_t nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_integer_size | ( | const std::int64_t | value | ) |
| inline static private

Returns
  The size of the BSON-encoded integer value

Definition at line 14215 of file json.hpp.

## ◆ calc_bson_object_size()

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 | ) |
| inline static private

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

Parameters

  [in] | value | JSON value to serialize

Precondition
  value.type() == value_t::object

Definition at line 14435 of file json.hpp.

## ◆ calc_bson_string_size()

template<typename BasicJsonType , typename CharType >

static std::size_t nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_string_size | ( | const string_t & | value | ) |
| inline static private

Returns
  The size of the BSON-encoded string in value

Definition at line 14185 of file json.hpp.

## ◆ calc_bson_unsigned_size()

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 | ) |
| inline static private noexcept

Returns
  The size of the BSON-encoded unsigned integer in j

Definition at line 14243 of file json.hpp.

References nlohmann::detail::value.

## ◆ get_cbor_float_prefix() [1/2]

template<typename BasicJsonType , typename CharType >

static constexpr CharType nlohmann::detail::binary_writer< BasicJsonType, CharType >::get_cbor_float_prefix | ( | float |  | ) |
| inline static private

Definition at line 14466 of file json.hpp.

## ◆ get_cbor_float_prefix() [2/2]

template<typename BasicJsonType , typename CharType >

static constexpr CharType nlohmann::detail::binary_writer< BasicJsonType, CharType >::get_cbor_float_prefix | ( | double |  | ) |
| inline static private

Definition at line 14471 of file json.hpp.

## ◆ get_msgpack_float_prefix() [1/2]

template<typename BasicJsonType , typename CharType >

static constexpr CharType nlohmann::detail::binary_writer< BasicJsonType, CharType >::get_msgpack_float_prefix | ( | float |  | ) |
| inline static private

Definition at line 14480 of file json.hpp.

## ◆ get_msgpack_float_prefix() [2/2]

template<typename BasicJsonType , typename CharType >

static constexpr CharType nlohmann::detail::binary_writer< BasicJsonType, CharType >::get_msgpack_float_prefix | ( | double |  | ) |
| inline static private

Definition at line 14485 of file json.hpp.

## ◆ get_ubjson_float_prefix() [1/2]

template<typename BasicJsonType , typename CharType >

static constexpr CharType nlohmann::detail::binary_writer< BasicJsonType, CharType >::get_ubjson_float_prefix | ( | float |  | ) |
| inline static private

Definition at line 14717 of file json.hpp.

## ◆ get_ubjson_float_prefix() [2/2]

template<typename BasicJsonType , typename CharType >

static constexpr CharType nlohmann::detail::binary_writer< BasicJsonType, CharType >::get_ubjson_float_prefix | ( | double |  | ) |
| inline static private

Definition at line 14722 of file json.hpp.

## ◆ to_char_type() [1/4]

template<typename BasicJsonType , typename CharType >
template<typename C = CharType, enable_if_t< std::is_signed< C >::value &&std::is_signed< char >::value > * = nullptr>

static constexpr CharType nlohmann::detail::binary_writer< BasicJsonType, CharType >::to_char_type | ( | std::uint8_t | x | ) |
| inline static noexcept

Definition at line 14786 of file json.hpp.

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

## ◆ to_char_type() [2/4]

template<typename BasicJsonType , typename CharType >
template<typename C = CharType, enable_if_t< std::is_signed< C >::value &&std::is_unsigned< char >::value > * = nullptr>

static CharType nlohmann::detail::binary_writer< BasicJsonType, CharType >::to_char_type | ( | std::uint8_t | x | ) |
| inline static noexcept

Definition at line 14793 of file json.hpp.

## ◆ to_char_type() [3/4]

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 | ) |
| inline static noexcept

Definition at line 14804 of file json.hpp.

## ◆ to_char_type() [4/4]

template<typename BasicJsonType , typename CharType >
template<typename InputCharType , typename C = CharType, enable_if_t< std::is_signed< C >::value &&std::is_signed< char >::value &&std::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 | ) |
| inline static noexcept

Definition at line 14815 of file json.hpp.

## ◆ ubjson_prefix()

template<typename BasicJsonType , typename CharType >

CharType nlohmann::detail::binary_writer< BasicJsonType, CharType >::ubjson_prefix | ( | const BasicJsonType & | j | ) | const
| inline private noexcept

determine the type prefix of container values

Definition at line 14637 of file json.hpp.

References nlohmann::detail::array, nlohmann::detail::binary, nlohmann::detail::boolean, nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::object, and nlohmann::detail::string.

## ◆ write_bson()

template<typename BasicJsonType , typename CharType >

void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson | ( | const BasicJsonType & | j | ) |
| inline

Parameters

  [in] | j | JSON value to serialize

Precondition
  j.type() == value_t::object

Definition at line 13283 of file json.hpp.

References nlohmann::detail::type_error::create(), JSON_THROW, nlohmann::detail::object, and nlohmann::detail::string.

## ◆ write_bson_array()

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
| ) |  |
| inline private

Writes a BSON element with key name and array value.

Definition at line 14308 of file json.hpp.

References nlohmann::to_string().

## ◆ write_bson_binary()

template<typename BasicJsonType , typename CharType >

void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_binary | ( | const string_t & | name,
|  | const binary_t & | value
| ) |  |
| inline private

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

Definition at line 14327 of file json.hpp.

## ◆ write_bson_boolean()

template<typename BasicJsonType , typename CharType >

void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_boolean | ( | const string_t & | name,
|  | const bool | value
| ) |  |
| inline private

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

Definition at line 14165 of file json.hpp.

## ◆ write_bson_double()

template<typename BasicJsonType , typename CharType >

void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_double | ( | const string_t & | name,
|  | const double | value
| ) |  |
| inline private

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

Definition at line 14175 of file json.hpp.

References nlohmann::detail::value.

## ◆ write_bson_element()

template<typename BasicJsonType , typename CharType >

void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_element | ( | const string_t & | name,
|  | const BasicJsonType & | j
| ) |  |
| inline private

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

Parameters

  name | The name to associate with the JSON entity j within the current BSON document

Definition at line 14389 of file json.hpp.

References nlohmann::detail::array, nlohmann::detail::binary, nlohmann::detail::boolean, JSON_ASSERT, nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::object, and nlohmann::detail::string.

## ◆ write_bson_entry_header()

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
| ) |  |
| inline private

Writes the given element_type and name to the output adapter.

Definition at line 14153 of file json.hpp.

## ◆ write_bson_integer()

template<typename BasicJsonType , typename CharType >

void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_integer | ( | const string_t & | name,
|  | const std::int64_t | value
| ) |  |
| inline private

Writes a BSON element with key name and integer value.

Definition at line 14225 of file json.hpp.

References nlohmann::detail::value.

## ◆ write_bson_null()

template<typename BasicJsonType , typename CharType >

void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_null | ( | const string_t & | name | ) |
| inline private

Writes a BSON element with key name and null value.

Definition at line 14207 of file json.hpp.

## ◆ write_bson_object()

template<typename BasicJsonType , typename CharType >

void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_object | ( | const typename BasicJsonType::object_t & | value | ) |
| inline private

Parameters

  [in] | value | JSON value to serialize

Precondition
  value.type() == value_t::object

Definition at line 14450 of file json.hpp.

## ◆ write_bson_object_entry()

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
| ) |  |
| inline private

Writes a BSON element with key name and object value.

Definition at line 14275 of file json.hpp.

## ◆ write_bson_string()

template<typename BasicJsonType , typename CharType >

void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_string | ( | const string_t & | name,
|  | const string_t & | value
| ) |  |
| inline private

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

Definition at line 14193 of file json.hpp.

## ◆ write_bson_unsigned()

template<typename BasicJsonType , typename CharType >

void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_unsigned | ( | const string_t & | name,
|  | const BasicJsonType & | j
| ) |  |
| inline private

Writes a BSON element with key name and unsigned value.

Definition at line 14253 of file json.hpp.

References nlohmann::detail::out_of_range::create(), JSON_THROW, and nlohmann::to_string().

## ◆ write_cbor()

template<typename BasicJsonType , typename CharType >

void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_cbor | ( | const BasicJsonType & | j | ) |
| inline

Parameters

  [in] | j | JSON value to serialize

Definition at line 13303 of file json.hpp.

References nlohmann::detail::array, nlohmann::detail::binary, nlohmann::detail::boolean, nlohmann::detail::cbor, nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::object, and nlohmann::detail::string.

## ◆ write_compact_float()

template<typename BasicJsonType , typename CharType >

void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_compact_float | ( | const number_float_t | n,
|  | detail::input_format_t | format
| ) |  |
| inline private

Definition at line 14759 of file json.hpp.

References nlohmann::detail::cbor.

## ◆ write_msgpack()

template<typename BasicJsonType , typename CharType >

void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_msgpack | ( | const BasicJsonType & | j | ) |
| inline

Parameters

  [in] | j | JSON value to serialize

Definition at line 13608 of file json.hpp.

References nlohmann::detail::array, nlohmann::detail::binary, nlohmann::detail::boolean, nlohmann::detail::msgpack, nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::object, and nlohmann::detail::string.

## ◆ write_number()

template<typename BasicJsonType , typename CharType >
template<typename NumberType , bool OutputIsLittleEndian = false>

void nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number | ( | const NumberType | n | ) |
| inline private

Definition at line 14743 of file json.hpp.

## ◆ write_number_with_ubjson_prefix() [1/3]

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
| ) |  |
| inline private

Definition at line 14497 of file json.hpp.

## ◆ write_number_with_ubjson_prefix() [2/3]

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
| ) |  |
| inline private

Definition at line 14510 of file json.hpp.

## ◆ write_number_with_ubjson_prefix() [3/3]

template<typename BasicJsonType , typename CharType >
template<typename NumberType , typename std::enable_if< std::is_signed< NumberType >::value &&!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
| ) |  |
| inline private

Definition at line 14573 of file json.hpp.

## ◆ write_ubjson()

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] | j | JSON value to serialize
  [in] | use_count | whether to use '#' prefixes (optimized format)
  [in] | use_type | whether to use '$' prefixes (optimized format)
  [in] | add_prefix | whether prefixes need to be used for this value

Definition at line 13932 of file json.hpp.

References nlohmann::detail::array, nlohmann::detail::binary, nlohmann::detail::boolean, JSON_ASSERT, nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::object, and nlohmann::detail::string.

## Member Data Documentation

## ◆ is_little_endian

template<typename BasicJsonType , typename CharType >

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

whether we can assume little endianess

Definition at line 14822 of file json.hpp.

## ◆ oa

template<typename BasicJsonType , typename CharType >

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

the output

Definition at line 14825 of file json.hpp.

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

- json.hpp