47template <
typename Derived>
69 throw std::runtime_error(
"This object is not an unsigned integer.");
81 throw std::runtime_error(
"This object is not a signed integer.");
93 throw std::runtime_error(
"This object is not a boolean.");
105 throw std::runtime_error(
106 "This object is not a 32-bit floating-point number.");
118 throw std::runtime_error(
119 "This object is not a 64-bit floating-point number.");
131 throw std::runtime_error(
"This object is not a string.");
133 return std::string_view(
144 throw std::runtime_error(
"This object is not a binary.");
157 throw std::runtime_error(
"This object is not an array.");
169 throw std::runtime_error(
"This object is not a map.");
181 throw std::runtime_error(
"This object is not an extension.");
212 [[nodiscard]]
const Derived&
derived() const noexcept {
213 return *
static_cast<const Derived*
>(
this);
229template <
typename Derived,
typename Allocator>
301 auto* ptr =
allocator().allocate_char(value.size());
302 std::memcpy(ptr, value.data(), value.size());
315 auto* ptr =
allocator().allocate_unsigned_char(value.
size());
316 std::memcpy(ptr, value.
data(), value.
size());
349 allocator().allocate_key_value_pair_data(size);
364 auto* ptr =
allocator().allocate_unsigned_char(value_data.
size());
365 std::memcpy(ptr, value_data.
data(), value_data.
size());
395 throw std::runtime_error(
"This object is not an array.");
408 throw std::runtime_error(
"This object is not a map.");
461 return *
static_cast<Derived*
>(
this);
469 [[nodiscard]]
const Derived&
derived() const noexcept {
470 return *
static_cast<const Derived*
>(
this);
Definition of allocator_wrapper class.
Definition of classes of references to arrays.
Definition of binary class.
Class to refer binary data.
std::size_t size() const noexcept
Get the size of the data.
const unsigned char * data() const noexcept
Get the pointer to the data.
Class to access constant arrays.
Class to access constant extension value.
Class to access constant maps.
Class to wrap allocators.
Base class of constant objects in MessagePack.
const details::object_data & data() const noexcept
Get the internal data.
const_array_ref as_array() const
Get data as an array.
bool as_boolean() const
Get data as a boolean.
const Derived & derived() const noexcept
Access the derived class.
std::int64_t as_signed_integer() const
Get data as a signed integer.
const_map_ref as_map() const
Get data as a map.
const_extension_ref as_extension() const
Get data as an extension.
std::string_view as_string() const
Get data as a string.
const_object_base()=default
Constructor.
float as_float32() const
Get data as a 32-bit floating-pointe number.
binary_view as_binary() const
Get data as a binary.
std::uint64_t as_unsigned_integer() const
Get data as an unsigned integer.
object_data_type type() const noexcept
Get the type of this object.
double as_float64() const
Get data as a 64-bit floating-pointe number.
Allocator allocator_type
Type of the allocator.
void set_unsigned_integer(std::uint64_t value) noexcept
Set this object to an unsigned integer.
void set_float32(float value) noexcept
Set this object to a 32-bit floating-point number.
void set_string(std::string_view value)
Set this object to a string.
mutable_array_ref< Allocator > as_array()
Get data as an array.
void set_signed_integer(std::int64_t value) noexcept
Set this object to a signed integer.
mutable_object_base()=default
Constructor.
const details::object_data & data() const noexcept
Get the internal data.
allocator_wrapper< Allocator > & allocator() noexcept
Get the allocator.
mutable_array_ref< Allocator > set_array(std::size_t size=0U)
Set this object to an array.
void set_boolean(bool value) noexcept
Set this object to a boolean value.
void clear() noexcept
Clear the data.
Derived & derived() noexcept
Access the derived class.
void set_float64(double value) noexcept
Set this object to a 64-bit floating-point number.
mutable_map_ref< Allocator > set_map(std::size_t size=0U)
Set this object to a map.
details::object_data & data() noexcept
Get the internal data.
mutable_map_ref< Allocator > as_map()
Get data as a map.
const Derived & derived() const noexcept
Access the derived class.
void set_extension(std::int8_t type, binary_view value_data)
Set this object to a extension value.
void set_binary(binary_view value)
Set this object to a binary.
Class to access non-constant arrays.
Class to access non-constant maps.
Definition of classes of references to extension values.
Definition of classes of references to maps.
Namespace of internal implementations.
void clear_object_data(object_data &data, allocator_wrapper< Allocator > &allocator) noexcept
Clear data.
object_data_type
Enumeration to specify types of data in objects.
@ unsigned_integer
Unsigned integer.
@ signed_integer
Signed integer.
@ float32
32-bit floating-point numbers.
@ float64
64-bit floating-point numbers.
Definition of object_data struct.
Definition of object_type enumeration.
Definition of helper functions for implementation of object class.
Declaration of classes of references to objects.
std::size_t size
Size of the data.
unsigned char * data
Data.
std::size_t size
Size of the data.
std::size_t size
Size of the data.
unsigned char * data
Data.
Struct of data of key-value pairs in maps.
std::size_t size
Size of the data.
key_value_pair_data * data
Data.
Struct of data of objects in MessagePack.
extension_data extension_value
Extension.
binary_data binary_value
Binary.
std::int64_t signed_integer_value
Signed integer.
double double_value
64-bit floating-point numbers.
array_data array_value
Array.
union msgpack_light::details::object_data::@227127335344143142004214331276031357231211344336 data
Data.
object_data_type type
Type of the data.
float float_value
32-bit floating-point numbers.
std::uint64_t unsigned_integer_value
Unsigned integer.
string_data string_value
String.
std::size_t size
Size of the data.