BinarySerializerObject Class Reference
|
CPP API
|
mio::BinarySerializerObject Class Reference
Stores a binary serialized object. More...
#include <binary_serializer.h>
Inheritance diagram for mio::BinarySerializerObject:
Collaboration diagram for mio::BinarySerializerObject:
Public Member Functions | |
| void | add_element (const std::string &name, const std::string &value) |
| Add string element to this object. More... | |
| template<class T > | |
| requires std::is_trivial_v< T > void | add_element (const std::string &name, const T &value) |
| Add element of basic type to this object. More... | |
| template<class Iter > | |
| void | add_list (const std::string &name, Iter b, Iter e) |
| Add a list of elements to this object. More... | |
| template<class T > | |
| void | add_optional (const std::string &name, const T *value) |
| Add optional element to this object. More... | |
| BinarySerializerObject (ByteStream &stream, std::shared_ptr< IOStatus > status, int flags) | |
| template<class T > | |
| requires(!std::is_trivial_v< T >) IOResult< T > expect_element(const std IOResult< std::string > | expect_element (const std::string &name, Tag< std::string > tag) |
| Get deserializable element from this object. More... | |
| template<class T > | |
| requires(!std::is_trivial_v< T >) void add_element(const std requires std::is_trivial_v< T > IOResult< T > | expect_element (const std::string &name, Tag< T > tag) |
| Add serializable value as an element to this object. More... | |
| template<class T > | |
| requires std::is_trivial_v< T > IOResult< T > | expect_element (const std::string &name, Tag< T >) |
| template<class T > | |
| IOResult< std::vector< T > > | expect_list (const std::string &name, Tag< T >) |
| Get a list of elements from this object. More... | |
| template<class T > | |
| IOResult< boost::optional< T > > | expect_optional (const std::string &name, Tag< T >) |
| Get optional element from this object. More... | |
Public Member Functions inherited from mio::SerializerBase | |
| int | flags () const |
| Flags that determine the behavior of serialization. More... | |
| SerializerBase (std::shared_ptr< IOStatus > status, int flags) | |
| Constructor that sets status and flags. More... | |
| void | set_error (const IOStatus &status) |
| Set the current status of serialization. More... | |
| void | set_flags (int f) |
| Set flags that determine the behavior of serialization. More... | |
| const IOStatus & | status () const |
| The current status of serialization. More... | |
Private Attributes | |
| ByteStream & | m_stream |
| Reference to a stream that stores the serialized bytes. More... | |
Additional Inherited Members | |
Protected Attributes inherited from mio::SerializerBase | |
| int | m_flags |
| std::shared_ptr< IOStatus > | m_status |
Detailed Description
Stores a binary serialized object.
See io.h for documentation of serialization.
Constructor & Destructor Documentation
◆ BinarySerializerObject()
|
inline |
Member Function Documentation
◆ add_element() [1/2]
|
inline |
Add string element to this object.
- Parameters
-
name Name of the element. value Value to be serialized.
◆ add_element() [2/2]
template<class T >
| requires std::is_trivial_v< T > void mio::BinarySerializerObject::add_element | ( | const std::string & | name, |
| const T & | value | ||
| ) |
Add element of basic type to this object.
As an optimization, also handles trivial structs, Enums, etc (everything that can be memcpy'd.)
- Parameters
-
name Name of the element. value Value to be serialized.
◆ add_list()
template<class Iter >
| void mio::BinarySerializerObject::add_list | ( | const std::string & | name, |
| Iter | b, | ||
| Iter | e | ||
| ) |
Add a list of elements to this object.
- Parameters
-
name Name of the list. b Iterator to beginning of the list. e Iterator to end of the list.
◆ add_optional()
template<class T >
| void mio::BinarySerializerObject::add_optional | ( | const std::string & | name, |
| const T * | value | ||
| ) |
Add optional element to this object.
- Parameters
-
name Name of the element. value Value to be serialized. Nullptr if empty.
◆ expect_element() [1/3]
template<class T >
| requires (!std::is_trivial_v<T>) IOResult<T> expect_element( const std IOResult<std::string> mio::BinarySerializerObject::expect_element | ( | const std::string & | name, |
| Tag< std::string > | tag | ||
| ) |
Get deserializable element from this object.
- Parameters
-
name Name of the element. tag Tag that determines the type of the element.
- Returns
- Deserialized value. Get serialized string element from this object.
- Parameters
-
name Name of the element. tag Tag that determines the type of the element.
- Returns
- Deserialized value.
◆ expect_element() [2/3]
template<class T >
| requires (!std::is_trivial_v<T>) void add_element( const std requires std::is_trivial_v<T> IOResult<T> mio::BinarySerializerObject::expect_element | ( | const std::string & | name, |
| Tag< T > | tag | ||
| ) |
Add serializable value as an element to this object.
- Parameters
-
name Name of the element. value Value to be serialized. Get element of basic type from this object. As an optimization, also handles trivial structs, Enums, etc (everything that can be memcpy'd.) name Name of the element. tag Tag that determines the type of the element.
- Returns
- Deserialized value.
◆ expect_element() [3/3]
template<class T >
| requires std::is_trivial_v<T> IOResult<T> mio::BinarySerializerObject::expect_element | ( | const std::string & | name, |
| Tag< T > | |||
| ) |
◆ expect_list()
template<class T >
| IOResult< std::vector< T > > mio::BinarySerializerObject::expect_list | ( | const std::string & | name, |
| Tag< T > | |||
| ) |
Get a list of elements from this object.
- Parameters
-
name Name of the list.
- Returns
- List of deserialized elements.
◆ expect_optional()
template<class T >
| IOResult< boost::optional< T > > mio::BinarySerializerObject::expect_optional | ( | const std::string & | name, |
| Tag< T > | |||
| ) |
Get optional element from this object.
- Parameters
-
name Name of the element.
- Returns
- Deserialized optional value.
Member Data Documentation
◆ m_stream
|
private |
Reference to a stream that stores the serialized bytes.
Generated by
Public Member Functions inherited from