TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ 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 
)
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 14989 of file json.hpp.

14991 {
14992 const auto header_size = calc_bson_entry_header_size(name, j);
14993
14994 switch (j.type())
14995 {
14996 case value_t::object:
14997 return header_size + calc_bson_object_size(*j.m_value.object);
14998
14999 case value_t::array:
15000 return header_size + calc_bson_array_size(*j.m_value.array);
15001
15002 case value_t::binary:
15003 return header_size + calc_bson_binary_size(*j.m_value.binary);
15004
15005 case value_t::boolean:
15006 return header_size + 1ul;
15007
15009 return header_size + 8ul;
15010
15012 return header_size + calc_bson_integer_size(j.m_value.number_integer);
15013
15015 return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned);
15016
15017 case value_t::string:
15018 return header_size + calc_bson_string_size(*j.m_value.string);
15019
15020 case value_t::null:
15021 return header_size + 0ul;
15022
15023 // LCOV_EXCL_START
15024 case value_t::discarded:
15025 default:
15026 JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert)
15027 return 0ul;
15028 // LCOV_EXCL_STOP
15029 }
15030 }
static std::size_t calc_bson_entry_header_size(const string_t &name, const BasicJsonType &j)
Definition: json.hpp:14787
static std::size_t calc_bson_binary_size(const typename BasicJsonType::binary_t &value)
Definition: json.hpp:14950
static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept
Definition: json.hpp:14893
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.
Definition: json.hpp:15085
static std::size_t calc_bson_string_size(const string_t &value)
Definition: json.hpp:14835
static std::size_t calc_bson_integer_size(const std::int64_t value)
Definition: json.hpp:14864
static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t &value)
Definition: json.hpp:14937
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)