Objects in MessagePack#
Contents#
Allocators used in
msgpack_light::object
classClasses and enumerations used in
msgpack_light::object
class
Reference#
-
template<typename Allocator = standard_allocator>
class object : public msgpack_light::details::mutable_object_base<object<standard_allocator>, standard_allocator># Class of objects in MessagePack.
- Template Parameters:
Allocator – Type of the allocator.
Initialization and finalization
-
inline explicit object(allocator_type allocator = allocator_type())#
Constructor.
- Parameters:
allocator – [in] Allocator.
-
inline object(const object &other)#
Copy constructor.
- Parameters:
other – [in] Another instance to copy from.
-
inline object(object &&other) noexcept#
Move constructor.
- Parameters:
other – [inout] Another instance to move from.
-
inline object &operator=(const object &other)#
Copy assignment operator.
- Parameters:
other – [in] Another instance to copy from.
- Returns:
This instance after copy.
-
inline object &operator=(object &&other) noexcept#
Move assignment operator.
- Parameters:
other – [inout] Another instance to move from.
- Returns:
This instance after move.
-
inline void swap(object &other) noexcept#
Swap this instance with another instance.
- Parameters:
other – [inout] Another instance to move with.
-
inline ~object()#
Destructor.
Internal data
Warning
These functions are for internal implementation of this library.
-
inline details::object_data &data() noexcept#
Get the internal data.
- Returns:
Internal data.
-
inline const details::object_data &data() const noexcept#
Get the internal data.
- Returns:
Internal data.
Public Types
-
using base_type = details::mutable_object_base<object<Allocator>, Allocator>#
Type of the base class.
-
class standard_allocator#
Class of standard allocators to allocate and deallocate memory.
Public Functions
-
inline void *allocate(std::size_t size, std::size_t)#
Allocate memory.
- Parameters:
size – [in] Number of bytes to allocate.
- Returns:
Pointer to the allocated memory.
-
inline void deallocate(void *ptr) noexcept#
Deallocate memory.
- Parameters:
ptr – [in] Pointer to the deallocated memory.
-
inline void *allocate(std::size_t size, std::size_t)#
-
class monotonic_allocator#
Class of an allocator which releases memory only when the allocator is destroyed.
Public Functions
-
inline monotonic_allocator()#
Constructor.
-
inline monotonic_allocator(const monotonic_allocator&) noexcept#
Copy constructor.
Note
This simply initialize this instance without any copy.
-
inline monotonic_allocator(monotonic_allocator &&other) noexcept#
Move constructor.
- Parameters:
other – [inout] Instance to move from.
-
inline ~monotonic_allocator()#
Destructor.
-
inline void *allocate(std::size_t size, std::size_t alignment)#
Allocate memory.
- Parameters:
size – [in] Number of bytes to allocate.
alignment – [in] Alignment.
- Returns:
Pointer to the allocated memory.
-
inline void deallocate(void *ptr) noexcept#
Deallocate memory.
Note
This class does nothing in this function.
- Parameters:
ptr – [in] Pointer to the deallocated memory.
-
inline monotonic_allocator &operator=(const monotonic_allocator&) noexcept#
Copy assignment operator.
Note
This does nothing.
- Returns:
This instance after copy.
-
inline monotonic_allocator &operator=(monotonic_allocator &&other) noexcept#
Move assignment operator.
- Parameters:
other – [inout] Instance to move from.
- Returns:
This instance after move.
-
inline void swap(monotonic_allocator &other) noexcept#
Swap with another instance.
- Parameters:
other – [out] Another instance.
-
inline monotonic_allocator()#
-
enum class msgpack_light::object_data_type : std::uint8_t#
Enumeration to specify types of data in objects.
Values:
-
enumerator nil#
Nil.
-
enumerator unsigned_integer#
Unsigned integer.
-
enumerator signed_integer#
Signed integer.
-
enumerator boolean#
Boolean.
-
enumerator float32#
32-bit floating-point numbers.
-
enumerator float64#
64-bit floating-point numbers.
-
enumerator string#
String.
-
enumerator binary#
Binary.
-
enumerator array#
Array.
-
enumerator map#
Map.
-
enumerator extension#
Extension.
-
enumerator nil#
-
template<typename Derived>
class const_object_base# Base class of constant objects in MessagePack.
Warning
This class cannot be instantiated directly. Instantiate msgpack_light::object classes.
- Template Parameters:
Derived – Type of the derived class.
Subclassed by msgpack_light::details::mutable_object_base< mutable_object_ref< Allocator >, Allocator >, msgpack_light::details::mutable_object_base< object< Allocator >, Allocator >, msgpack_light::details::mutable_object_base< Derived, Allocator >
Access to data
-
inline object_data_type type() const noexcept#
Get the type of this object.
- Returns:
Type of this object.
-
inline std::uint64_t as_unsigned_integer() const#
Get data as an unsigned integer.
- Returns:
Value.
-
inline std::int64_t as_signed_integer() const#
Get data as a signed integer.
- Returns:
Value.
-
inline bool as_boolean() const#
Get data as a boolean.
- Returns:
Value.
-
inline float as_float32() const#
Get data as a 32-bit floating-pointe number.
- Returns:
Value.
-
inline double as_float64() const#
Get data as a 64-bit floating-pointe number.
- Returns:
Value.
-
inline std::string_view as_string() const#
Get data as a string.
- Returns:
Value.
-
inline binary_view as_binary() const#
Get data as a binary.
- Returns:
Value.
-
inline const_array_ref as_array() const#
Get data as an array.
- Returns:
Value.
-
inline const_map_ref as_map() const#
Get data as a map.
- Returns:
Value.
-
inline const_extension_ref as_extension() const#
Get data as an extension.
- Returns:
Value.
Internal data
Warning
These functions are for internal implementation of this library.
-
inline const details::object_data &data() const noexcept#
Get the internal data.
- Returns:
Internal data.
-
template<typename Derived, typename Allocator>
class mutable_object_base : public msgpack_light::details::const_object_base<Derived># Base class of non-constant objects in MessagePack.
Warning
This class cannot be instantiated directly. Instantiate msgpack_light::object classes.
- Template Parameters:
Derived – Type of the derived class.
Allocator – Type of the allocator.
Set data
-
inline void set_unsigned_integer(std::uint64_t value) noexcept#
Set this object to an unsigned integer.
- Parameters:
value – [in] Value.
-
inline void set_signed_integer(std::int64_t value) noexcept#
Set this object to a signed integer.
- Parameters:
value – [in] Value.
-
inline void set_boolean(bool value) noexcept#
Set this object to a boolean value.
- Parameters:
value – [in] Value.
-
inline void set_float32(float value) noexcept#
Set this object to a 32-bit floating-point number.
- Parameters:
value – [in] Value.
-
inline void set_float64(double value) noexcept#
Set this object to a 64-bit floating-point number.
- Parameters:
value – [in] Value.
-
inline void set_string(std::string_view value)#
Set this object to a string.
- Parameters:
value – [in] Value.
-
inline void set_binary(binary_view value)#
Set this object to a binary.
- Parameters:
value – [in] Value.
-
inline mutable_array_ref<Allocator> set_array(std::size_t size = 0U)#
Set this object to an array.
- Parameters:
size – [in] Number of elements.
- Returns:
Object to access the array.
-
inline mutable_map_ref<Allocator> set_map(std::size_t size = 0U)#
Set this object to a map.
- Parameters:
size – [in] Number of key-value pairs.
- Returns:
Object to access the map.
-
inline void set_extension(std::int8_t type, binary_view value_data)#
Set this object to a extension value.
- Parameters:
type – [in] Type.
value_data – [in] Data of the value.
-
inline void clear() noexcept#
Clear the data.
Access to data
-
inline mutable_array_ref<Allocator> as_array()#
Get data as an array.
- Returns:
Value.
-
inline mutable_map_ref<Allocator> as_map()#
Get data as a map.
- Returns:
Value.
-
class const_object_ref : public msgpack_light::details::const_object_base<const_object_ref>#
Class to access constant objects.
Note
Instances of this class can be created from msgpack_light::mutable_array_ref, msgpack_light::const_array_ref, msgpack_light::mutable_array_iterator, msgpack_light::const_array_iterator, msgpack_light::mutable_map_ref, msgpack_light::const_map_ref, msgpack_light::mutable_map_iterator, msgpack_light::const_map_iterator classes.
Warning
This class only holds pointers to data in msgpack_light::object class, do not call functions in this class without msgpack_light::object instances holding the data.
Initialization and finalization
-
inline explicit const_object_ref(const details::object_data &data)#
Constructor.
- Parameters:
data – [in] Data.
Internal data
Warning
These functions are for internal implementation of this library.
-
inline const details::object_data &data() const noexcept#
Get the internal data.
- Returns:
Internal data.
Public Types
-
using base_type = details::const_object_base<const_object_ref>#
Type of the base class.
-
inline explicit const_object_ref(const details::object_data &data)#
-
template<typename Allocator>
class mutable_object_ref : public msgpack_light::details::mutable_object_base<mutable_object_ref<Allocator>, Allocator># Class to access non-constant objects.
Note
Instances of this class can be created from msgpack_light::mutable_array_ref, msgpack_light::mutable_array_iterator, msgpack_light::mutable_map_ref, msgpack_light::mutable_map_iterator, classes.
Warning
This class only holds pointers to data in msgpack_light::object class, do not call functions in this class without msgpack_light::object instances holding the data.
- Template Parameters:
Allocator – Type of the allocator.
Initialization and finalization
Internal data
Warning
These functions are for internal implementation of this library.
-
inline details::object_data &data() noexcept#
Get the internal data.
- Returns:
Internal data.
-
inline const details::object_data &data() const noexcept#
Get the internal data.
- Returns:
Internal data.
Public Types
-
using base_type = details::mutable_object_base<mutable_object_ref<Allocator>, Allocator>#
Type of the base class.
-
class const_array_ref#
Class to access constant arrays.
Note
Instances of this class can be created from msgpack_light::object, msgpack_light::const_object_ref, msgpack_light::mutable_object_ref classes.
Warning
This class only holds pointers to data in msgpack_light::object class, do not call functions in this class without msgpack_light::object instances holding the data.
Public Types
-
using const_iterator = const_array_iterator#
Type of iterators.
-
using const_object_ref_type = const_object_ref#
Type to access constant objects.
-
using iterator = const_array_iterator#
Type of iterators.
Public Functions
-
inline explicit const_array_ref(const details::array_data &data)#
Constructor.
- Parameters:
data – [in] Data.
-
inline const_array_iterator begin() const noexcept#
Get an iterator to the first element.
- Returns:
Iterator.
-
inline const_array_iterator cbegin() const noexcept#
Get an iterator to the first element.
- Returns:
Iterator.
-
inline const_array_iterator cend() const noexcept#
Get an iterator to the past-the-end element.
- Returns:
Iterator.
-
inline const_array_iterator end() const noexcept#
Get an iterator to the past-the-end element.
- Returns:
Iterator.
-
inline const_object_ref_type operator[](std::size_t index) const noexcept#
Get an object.
- Parameters:
index – [in] Index of the object.
- Returns:
Object.
-
inline std::size_t size() const noexcept#
Get the size.
- Returns:
Size.
-
using const_iterator = const_array_iterator#
-
template<typename Allocator = standard_allocator>
class mutable_array_ref# Class to access non-constant arrays.
Note
Instances of this class can be created from msgpack_light::object, msgpack_light::mutable_object_ref classes.
Warning
This class only holds pointers to data in msgpack_light::object class, do not call functions in this class without msgpack_light::object instances holding the data.
- Template Parameters:
Allocator – Type of the allocator.
Public Types
-
using const_iterator = const_array_iterator#
Type of iterators.
-
using const_object_ref_type = const_object_ref#
Type to access constant objects.
-
using iterator = mutable_array_iterator<Allocator>#
Type of iterators.
-
using mutable_object_ref_type = mutable_object_ref<Allocator>#
Type to access non-constant objects.
Public Functions
-
inline mutable_array_ref(details::array_data &data, details::allocator_wrapper<Allocator> &allocator)#
Constructor.
- Parameters:
data – [in] Data.
allocator – [in] Allocator.
-
inline const_array_iterator begin() const noexcept#
Get an iterator to the first element.
- Returns:
Iterator.
-
inline mutable_array_iterator<Allocator> begin() noexcept#
Get an iterator to the first element.
- Returns:
Iterator.
-
inline const_array_iterator end() const noexcept#
Get an iterator to the past-the-end element.
- Returns:
Iterator.
-
inline mutable_array_iterator<Allocator> end() noexcept#
Get an iterator to the past-the-end element.
- Returns:
Iterator.
-
inline const_object_ref_type operator[](std::size_t index) const noexcept#
Get an object.
- Parameters:
index – [in] Index of the object.
- Returns:
Object.
-
inline mutable_object_ref_type operator[](std::size_t index) noexcept#
Get an object.
- Parameters:
index – [in] Index of the object.
- Returns:
Object.
-
inline void resize(std::size_t size)#
Change the size.
- Parameters:
size – [in] Size.
-
inline std::size_t size() const noexcept#
Get the size.
- Returns:
Size.
-
class const_array_iterator#
Class of iterators of arrays to access constant objects.
Note
Instances of this class can be created from msgpack_light::const_array_ref, msgpack_light::mutable_array_ref classes.
Warning
This class only holds pointers to data in msgpack_light::object class, do not call functions in this class without msgpack_light::object instances holding the data.
Public Types
-
using difference_type = std::ptrdiff_t#
Type of differences.
-
using reference = const_object_ref#
Type of references.
-
using value_type = const_object_ref#
Type of values.
Public Functions
-
inline const_array_iterator() noexcept#
Constructor.
-
inline explicit const_array_iterator(const details::object_data *pointer) noexcept#
Constructor.
- Parameters:
pointer – [in] Pointer to the current data.
-
inline const_object_ref operator*() const noexcept#
Dereference this iterator.
- Returns:
Reference to the current object.
-
inline const_array_iterator &operator++() noexcept#
Increment this iterator.
- Returns:
This iterator.
-
inline const const_array_iterator operator++(int) noexcept#
Increment this iterator.
- Returns:
This iterator.
-
using difference_type = std::ptrdiff_t#
-
template<typename Allocator = standard_allocator>
class mutable_array_iterator# Class of iterators of arrays to access non-constant objects.
Note
Instances of this class can be created from msgpack_light::mutable_array_ref class.
Warning
This class only holds pointers to data in msgpack_light::object class, do not call functions in this class without msgpack_light::object instances holding the data.
- Template Parameters:
Allocator – Type of the allocator.
Public Types
-
using difference_type = std::ptrdiff_t#
Type of differences.
-
using reference = mutable_object_ref<Allocator>#
Type of references.
-
using value_type = mutable_object_ref<Allocator>#
Type of values.
Public Functions
-
inline mutable_array_iterator() noexcept#
Constructor.
-
inline mutable_array_iterator(details::object_data *pointer, details::allocator_wrapper<Allocator> *allocator) noexcept#
Constructor.
- Parameters:
pointer – [in] Pointer to the current data.
allocator – [in] Allocator.
-
inline mutable_object_ref<Allocator> operator*() const noexcept#
Dereference this iterator.
- Returns:
Reference to the current object.
-
inline mutable_array_iterator &operator++() noexcept#
Increment this iterator.
- Returns:
This iterator.
-
inline const mutable_array_iterator operator++(int) noexcept#
Increment this iterator.
- Returns:
This iterator.
-
class const_map_ref#
Class to access constant maps.
Note
Instances of this class can be created from msgpack_light::object, msgpack_light::const_object_ref, msgpack_light::mutable_object_ref classes.
Warning
This class only holds pointers to data in msgpack_light::object class, do not call functions in this class without msgpack_light::object instances holding the data.
Public Types
-
using const_iterator = const_map_iterator#
Type of iterators.
-
using const_object_ref_type = const_object_ref#
Type to access constant objects.
-
using iterator = const_map_iterator#
Type of iterators.
Public Functions
-
inline explicit const_map_ref(const details::map_data &data)#
Constructor.
- Parameters:
data – [in] Data.
-
inline const_map_iterator begin() const noexcept#
Get an iterator to the first key-value pair.
- Returns:
Iterator.
-
inline const_map_iterator end() const noexcept#
Get an iterator to the past-the-end key-value pair.
- Returns:
Iterator.
-
inline const_object_ref_type key(std::size_t index) const noexcept#
Get a key.
- Parameters:
index – [in] Index of the key-value pair.
- Returns:
Object of the key.
-
inline std::size_t size() const noexcept#
Get the size.
- Returns:
Size.
-
inline const_object_ref_type value(std::size_t index) const noexcept#
Get a value.
- Parameters:
index – [in] Index of the key-value pair.
- Returns:
Object of the value.
-
using const_iterator = const_map_iterator#
-
template<typename Allocator = standard_allocator>
class mutable_map_ref# Class to access non-constant maps.
Note
Instances of this class can be created from msgpack_light::object, msgpack_light::mutable_object_ref classes.
Warning
This class only holds pointers to data in msgpack_light::object class, do not call functions in this class without msgpack_light::object instances holding the data.
- Template Parameters:
Allocator – Type of the allocator.
Public Types
-
using const_iterator = const_map_iterator#
Type of iterators.
-
using const_object_ref_type = const_object_ref#
Type to access constant objects.
-
using iterator = mutable_map_iterator<Allocator>#
Type of iterators.
-
using mutable_object_ref_type = mutable_object_ref<Allocator>#
Type to access non-constant objects.
Public Functions
-
inline mutable_map_ref(details::map_data &data, details::allocator_wrapper<Allocator> &allocator)#
Constructor.
- Parameters:
data – [in] Data.
allocator – [in] Allocator.
-
inline const_map_iterator begin() const noexcept#
Get an iterator to the first key-value pair.
- Returns:
Iterator.
-
inline mutable_map_iterator<Allocator> begin() noexcept#
Get an iterator to the first key-value pair.
- Returns:
Iterator.
-
inline const_map_iterator end() const noexcept#
Get an iterator to the past-the-end key-value pair.
- Returns:
Iterator.
-
inline mutable_map_iterator<Allocator> end() noexcept#
Get an iterator to the past-the-end key-value pair.
- Returns:
Iterator.
-
inline const_object_ref_type key(std::size_t index) const noexcept#
Get a key.
- Parameters:
index – [in] Index of the key-value pair.
- Returns:
Object of the key.
-
inline mutable_object_ref_type key(std::size_t index) noexcept#
Get a key.
- Parameters:
index – [in] Index of the key-value pair.
- Returns:
Object of the key.
-
inline std::size_t size() const noexcept#
Get the size.
- Returns:
Size.
-
inline const_object_ref_type value(std::size_t index) const noexcept#
Get a value.
- Parameters:
index – [in] Index of the key-value pair.
- Returns:
Object of the value.
-
inline mutable_object_ref_type value(std::size_t index) noexcept#
Get a value.
- Parameters:
index – [in] Index of the key-value pair.
- Returns:
Object of the value.
-
class const_map_iterator#
Class of iterators of maps to access constant objects.
Note
Instances of this class can be created from msgpack_light::const_map_ref, msgpack_light::mutable_map_ref classes.
Warning
This class only holds pointers to data in msgpack_light::object class, do not call functions in this class without msgpack_light::object instances holding the data.
Public Types
-
using difference_type = std::ptrdiff_t#
Type of differences.
-
using reference = value_type#
Type of references.
-
using value_type = std::pair<const_object_ref, const_object_ref>#
Type of values.
Public Functions
-
inline const_map_iterator() noexcept#
Constructor.
-
inline explicit const_map_iterator(const details::key_value_pair_data *pointer) noexcept#
Constructor.
- Parameters:
pointer – [in] Pointer to the current data.
-
inline std::pair<const_object_ref, const_object_ref> operator*() const noexcept#
Dereference this iterator.
- Returns:
References to the current key and value.
-
inline const_map_iterator &operator++() noexcept#
Increment this iterator.
- Returns:
This iterator.
-
inline const const_map_iterator operator++(int) noexcept#
Increment this iterator.
- Returns:
This iterator.
-
using difference_type = std::ptrdiff_t#
-
template<typename Allocator = standard_allocator>
class mutable_map_iterator# Class of iterators of maps to access non-constant objects.
Note
Instances of this class can be created from msgpack_light::mutable_map_ref class.
Warning
This class only holds pointers to data in msgpack_light::object class, do not call functions in this class without msgpack_light::object instances holding the data.
- Template Parameters:
Allocator – Type of the allocator.
Public Types
-
using difference_type = std::ptrdiff_t#
Type of differences.
-
using reference = value_type#
Type of references.
-
using value_type = std::pair<mutable_object_ref<Allocator>, mutable_object_ref<Allocator>>#
Type of values.
Public Functions
-
inline mutable_map_iterator() noexcept#
Constructor.
-
inline mutable_map_iterator(details::key_value_pair_data *pointer, details::allocator_wrapper<Allocator> *allocator) noexcept#
Constructor.
- Parameters:
pointer – [in] Pointer to the current data.
allocator – [in] Allocator.
-
inline std::pair<mutable_object_ref<Allocator>, mutable_object_ref<Allocator>> operator*() const noexcept#
Dereference this iterator.
- Returns:
References to the current key and value.
-
inline mutable_map_iterator &operator++() noexcept#
Increment this iterator.
- Returns:
This iterator.
-
inline const mutable_map_iterator operator++(int) noexcept#
Increment this iterator.
- Returns:
This iterator.
-
class const_extension_ref#
Class to access constant extension value.
Note
Instances of this class can be created from msgpack_light::object, msgpack_light::const_object_ref, msgpack_light::mutable_object_ref classes.
Warning
This class only holds pointers to data in msgpack_light::object class, do not call functions in this class without msgpack_light::object instances holding the data.
Public Functions
-
inline explicit const_extension_ref(const details::extension_data &data)#
Constructor.
- Parameters:
data – [in] Data.
-
inline binary_view data() const noexcept#
Get the data of the value.
- Returns:
Data.
-
inline std::int8_t type() const#
Get the type.
- Returns:
Type.
-
inline explicit const_extension_ref(const details::extension_data &data)#