|
STAR
Cal STAR — firmware, DAQ server, and engine design
|
serialization to CBOR and MessagePack values More...
#include <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, const bool use_bjdata=false) |
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. | |
| 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 BasicJsonType &j) |
| 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_binary (const string_t &name, const binary_t &value) |
| Writes a BSON element with key name and binary value 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, const bool use_bjdata) |
| 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, const bool use_bjdata) |
| 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, const bool use_bjdata) |
| CharType | ubjson_prefix (const BasicJsonType &j, const bool use_bjdata) const noexcept |
| determine the type prefix of container values | |
| bool | write_bjdata_ndarray (const typename BasicJsonType::object_t &value, const bool use_count, const bool use_type) |
| template<typename NumberType> | |
| **void | write_number (const NumberType n, const bool OutputIsLittleEndian=false) |
| 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. | |
| 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 | |
| *whether we can assume little endianness const bool | is_little_endian = little_endianness() |
| *the output output_adapter_t< CharType > | oa = nullptr |
serialization to CBOR and MessagePack values
|
private |
|
private |
|
private |
|
inlineexplicit |
create a binary writer
| [in] | adapter | output adapter to write to |
Definition at line 15090 of file json.hpp.
References JSON_ASSERT, and oa.
|
inlinestaticprivate |
Definition at line 16146 of file json.hpp.
References array_index(), calc_bson_element_size(), result, and detail::static_const< T >::value.
Referenced by calc_bson_element_size(), and write_bson_array().
|
inlinestaticprivate |
Definition at line 16161 of file json.hpp.
References detail::static_const< T >::value.
Referenced by calc_bson_element_size().
|
inlinestaticprivate |
Calculates the size necessary to serialize the JSON value j with its name.
Definition at line 16203 of file json.hpp.
References detail::array, detail::binary, detail::boolean, calc_bson_array_size(), calc_bson_binary_size(), calc_bson_entry_header_size(), calc_bson_integer_size(), calc_bson_object_size(), calc_bson_string_size(), calc_bson_unsigned_size(), detail::discarded, JSON_ASSERT, detail::null, detail::number_float, detail::number_integer, detail::number_unsigned, detail::object, and detail::string.
Referenced by calc_bson_array_size().
|
inlinestaticprivate |
Definition at line 15999 of file json.hpp.
References detail::concat(), detail::out_of_range::create(), JSON_HEDLEY_UNLIKELY, and JSON_THROW.
Referenced by calc_bson_element_size().
|
inlinestaticprivate |
Definition at line 16076 of file json.hpp.
References detail::static_const< T >::value.
Referenced by calc_bson_element_size().
|
inlinestaticprivate |
Calculates the size of the BSON serialization of the given JSON-object j.
| [in] | value | JSON value to serialize |
Definition at line 16298 of file json.hpp.
References result, and detail::static_const< T >::value.
Referenced by calc_bson_element_size(), and write_bson_object().
|
inlinestaticprivate |
Definition at line 16046 of file json.hpp.
References detail::static_const< T >::value.
Referenced by calc_bson_element_size().
|
inlinestaticconstexprprivatenoexcept |
Definition at line 16104 of file json.hpp.
References detail::static_const< T >::value.
Referenced by calc_bson_element_size().
|
inlinestaticconstexprprivate |
Definition at line 16334 of file json.hpp.
References to_char_type().
|
inlinestaticconstexprprivate |
Definition at line 16329 of file json.hpp.
References to_char_type().
Referenced by write_compact_float().
|
inlinestaticconstexprprivate |
Definition at line 16348 of file json.hpp.
References to_char_type().
|
inlinestaticconstexprprivate |
Definition at line 16343 of file json.hpp.
References to_char_type().
Referenced by write_compact_float().
|
inlinestaticconstexprprivate |
|
inlinestaticconstexprprivate |
Definition at line 16644 of file json.hpp.
Referenced by ubjson_prefix(), and write_number_with_ubjson_prefix().
|
inlinestaticconstexprnoexcept |
|
inlinestaticconstexprnoexcept |
|
inlinestaticnoexcept |
|
inlinestaticconstexprnoexcept |
Definition at line 16834 of file json.hpp.
Referenced by detail::serializer< BasicJsonType >::for(), get_cbor_float_prefix(), get_cbor_float_prefix(), get_msgpack_float_prefix(), get_msgpack_float_prefix(), write_bson_array(), write_bson_boolean(), write_bson_entry_header(), write_bson_object(), write_cbor(), write_msgpack(), write_number_with_ubjson_prefix(), and write_ubjson().
|
inlineprivatenoexcept |
determine the type prefix of container values
Definition at line 16543 of file json.hpp.
References detail::array, detail::binary, detail::boolean, detail::discarded, get_ubjson_float_prefix(), detail::null, detail::number_float, detail::number_integer, detail::number_unsigned, detail::object, and detail::string.
Referenced by write_ubjson().
|
inlineprivate |
Definition at line 16657 of file json.hpp.
References json_sax< BasicJsonType >::key(), oa, detail::static_const< T >::value, write_number(), and write_ubjson().
Referenced by write_ubjson().
|
inline |
| [in] | j | JSON value to serialize |
Definition at line 15099 of file json.hpp.
References detail::array, detail::binary, detail::boolean, detail::concat(), detail::type_error::create(), detail::discarded, JSON_THROW, detail::null, detail::number_float, detail::number_integer, detail::number_unsigned, detail::object, detail::string, and write_bson_object().
|
inlineprivate |
Writes a BSON element with key name and array value.
Definition at line 16169 of file json.hpp.
References array_index(), calc_bson_array_size(), oa, detail::static_const< T >::value, to_char_type(), write_bson_element(), write_bson_entry_header(), and write_number().
Referenced by write_bson_element().
|
inlineprivate |
Writes a BSON element with key name and binary value value.
Definition at line 16188 of file json.hpp.
References oa, detail::static_const< T >::value, write_bson_entry_header(), and write_number().
Referenced by write_bson_element().
|
inlineprivate |
Writes a BSON element with key name and boolean value value.
Definition at line 16026 of file json.hpp.
References oa, detail::static_const< T >::value, to_char_type(), and write_bson_entry_header().
Referenced by write_bson_element().
|
inlineprivate |
Writes a BSON element with key name and double value value.
Definition at line 16036 of file json.hpp.
References detail::static_const< T >::value, write_bson_entry_header(), and write_number().
Referenced by write_bson_element().
|
inlineprivate |
Serializes the JSON value j to BSON and associates it with the key name.
| name | The name to associate with the JSON entity j within the current BSON document |
Definition at line 16251 of file json.hpp.
References detail::array, detail::binary, detail::boolean, detail::discarded, JSON_ASSERT, detail::null, detail::number_float, detail::number_integer, detail::number_unsigned, detail::object, detail::string, write_bson_array(), write_bson_binary(), write_bson_boolean(), write_bson_double(), write_bson_integer(), write_bson_null(), write_bson_object_entry(), write_bson_string(), and write_bson_unsigned().
Referenced by write_bson_array(), and write_bson_object().
|
inlineprivate |
Writes the given element_type and name to the output adapter.
Definition at line 16014 of file json.hpp.
References oa, and to_char_type().
Referenced by write_bson_array(), write_bson_binary(), write_bson_boolean(), write_bson_double(), write_bson_integer(), write_bson_null(), write_bson_object_entry(), write_bson_string(), and write_bson_unsigned().
|
inlineprivate |
Writes a BSON element with key name and integer value.
Definition at line 16086 of file json.hpp.
References detail::static_const< T >::value, write_bson_entry_header(), and write_number().
Referenced by write_bson_element().
|
inlineprivate |
Writes a BSON element with key name and null value.
Definition at line 16068 of file json.hpp.
References write_bson_entry_header().
Referenced by write_bson_element().
|
inlineprivate |
| [in] | value | JSON value to serialize |
Definition at line 16313 of file json.hpp.
References calc_bson_object_size(), oa, detail::static_const< T >::value, to_char_type(), write_bson_element(), and write_number().
Referenced by write_bson(), and write_bson_object_entry().
|
inlineprivate |
Writes a BSON element with key name and object value.
Definition at line 16136 of file json.hpp.
References detail::static_const< T >::value, write_bson_entry_header(), and write_bson_object().
Referenced by write_bson_element().
|
inlineprivate |
Writes a BSON element with key name and string value value.
Definition at line 16054 of file json.hpp.
References oa, detail::static_const< T >::value, write_bson_entry_header(), and write_number().
Referenced by write_bson_element().
|
inlineprivate |
Writes a BSON element with key name and unsigned value.
Definition at line 16114 of file json.hpp.
References detail::concat(), detail::out_of_range::create(), JSON_THROW, write_bson_entry_header(), and write_number().
Referenced by write_bson_element().
|
inline |
| [in] | j | JSON value to serialize |
Definition at line 15128 of file json.hpp.
References detail::array, detail::binary, detail::boolean, detail::cbor, detail::discarded, detail::null, detail::number_float, detail::number_integer, detail::number_unsigned, oa, detail::object, detail::string, to_char_type(), write_cbor(), write_compact_float(), and write_number().
Referenced by write_cbor().
|
inlineprivate |
Definition at line 16800 of file json.hpp.
References detail::cbor, format(), get_cbor_float_prefix(), get_msgpack_float_prefix(), oa, and write_number().
Referenced by write_cbor(), and write_msgpack().
|
inline |
| [in] | j | JSON value to serialize |
Definition at line 15452 of file json.hpp.
References detail::array, detail::binary, detail::boolean, detail::discarded, detail::msgpack, detail::null, detail::number_float, detail::number_integer, detail::number_unsigned, oa, detail::object, detail::string, to_char_type(), write_compact_float(), write_msgpack(), and write_number().
Referenced by write_msgpack().
|
inlineprivate |
Definition at line 16784 of file json.hpp.
References is_little_endian, and oa.
Referenced by write_bjdata_ndarray(), write_bson_array(), write_bson_binary(), write_bson_double(), write_bson_integer(), write_bson_object(), write_bson_string(), write_bson_unsigned(), write_cbor(), write_compact_float(), write_msgpack(), and write_number_with_ubjson_prefix().
|
inlineprivate |
Definition at line 16462 of file json.hpp.
References oa, to_char_type(), write_number(), and write_number_with_ubjson_prefix().
|
inlineprivate |
Definition at line 16374 of file json.hpp.
References oa, to_char_type(), write_number(), and write_number_with_ubjson_prefix().
|
inlineprivate |
Definition at line 16360 of file json.hpp.
References get_ubjson_float_prefix(), oa, and write_number().
Referenced by write_number_with_ubjson_prefix(), and write_ubjson().
|
inline |
| [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 |
| [in] | use_bjdata | whether write in BJData format, default is false |
Definition at line 15778 of file json.hpp.
References detail::array, detail::binary, detail::boolean, detail::discarded, JSON_ASSERT, detail::null, detail::number_float, detail::number_integer, detail::number_unsigned, oa, detail::object, detail::string, to_char_type(), ubjson_prefix(), write_bjdata_ndarray(), write_number_with_ubjson_prefix(), and write_ubjson().
Referenced by write_bjdata_ndarray(), and write_ubjson().
|
private |
Definition at line 16870 of file json.hpp.
Referenced by write_number().
|
private |
Definition at line 16873 of file json.hpp.
Referenced by binary_writer(), write_bjdata_ndarray(), write_bson_array(), write_bson_binary(), write_bson_boolean(), write_bson_entry_header(), write_bson_object(), write_bson_string(), write_cbor(), write_compact_float(), write_msgpack(), write_number(), write_number_with_ubjson_prefix(), and write_ubjson().