binary_serializer.h Source File
|
CPP API
|
binary_serializer.h
Go to the documentation of this file.
341 inline void BinarySerializerObject::add_element(const std::string& name, const std::string& value)
364 IOStatus(mio::StatusCode::UnknownError, "Unexpected EOF reading " + name + " from binary stream.");
382 inline IOResult<std::string> BinarySerializerObject::expect_element(const std::string& name, Tag<std::string>)
393 *m_status = IOStatus(StatusCode::UnknownError, "Unexpected EOF reading " + name + " from binary stream.");
433 IOResult<boost::optional<T>> BinarySerializerObject::expect_optional(const std::string& name, Tag<T>)
BinarySerializerContext(ByteStream &stream, std::shared_ptr< IOStatus > status, int flags)
Definition: binary_serializer.h:248
requires std::is_trivial_v< T > friend void serialize_internal(BinarySerializerContext &ctxt, const T &t)
Serialize "naked" ints, etc.
Definition: binary_serializer.h:295
ByteStream & m_stream
Reference to a stream that stores the serialized bytes.
Definition: binary_serializer.h:320
BinarySerializerObject create_object(const std::string &type)
Begin serialization of a new object.
Definition: binary_serializer.h:258
requires std::is_trivial_v< T > friend IOResult< T > deserialize_internal(BinarySerializerContext &ctxt, Tag< T > tag)
Deserialize "naked" ints, etc.
Definition: binary_serializer.h:311
BinarySerializerObject expect_object(const std::string &type)
Begin deserialization of an object.
Definition: binary_serializer.h:271
requires std::is_trivial_v< T > void add_element(const std::string &name, const T &value)
Add element of basic type to this object.
Definition: binary_serializer.h:325
IOResult< boost::optional< T > > expect_optional(const std::string &name, Tag< T >)
Get optional element from this object.
Definition: binary_serializer.h:433
void add_optional(const std::string &name, const T *value)
Add optional element to this object.
Definition: binary_serializer.h:423
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.
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.
BinarySerializerObject(ByteStream &stream, std::shared_ptr< IOStatus > status, int flags)
Definition: binary_serializer.h:141
void add_list(const std::string &name, Iter b, Iter e)
Add a list of elements to this object.
Definition: binary_serializer.h:399
IOResult< std::vector< T > > expect_list(const std::string &name, Tag< T >)
Get a list of elements from this object.
Definition: binary_serializer.h:409
ByteStream & m_stream
Reference to a stream that stores the serialized bytes.
Definition: binary_serializer.h:238
ByteStream(size_t n)
Create stream with n readable bytes initialized to 0.
Definition: binary_serializer.h:47
bool read(unsigned char *p, size_t s)
Read bytes from the stream.
Definition: binary_serializer.h:77
void reset(size_t n)
Reset the stream to n readable bytes of value 0.
Definition: binary_serializer.h:93
std::vector< unsigned char > m_buf
store of written/readable bytes
Definition: binary_serializer.h:130
void write(const unsigned char *const p, size_t s)
Write bytes to the stream.
Definition: binary_serializer.h:66
unsigned char * data()
Get the pointer to the buffer of the stream.
Definition: binary_serializer.h:115
const unsigned char * data() const
Get the pointer to the buffer of the stream.
Definition: binary_serializer.h:111
size_t m_read_head
index in the buffer where next byte is read/written
Definition: binary_serializer.h:131
size_t data_size() const
Get the size of the buffer of the stream.
Definition: binary_serializer.h:124
Base class for implementations of serialization framework concepts.
Definition: serializer_base.h:35
const IOStatus & status() const
The current status of serialization.
Definition: serializer_base.h:69
int flags() const
Flags that determine the behavior of serialization.
Definition: serializer_base.h:51
int size(Comm comm)
Return the size of the given communicator.
Definition: miompi.cpp:75
A collection of classes to simplify handling of matrix shapes in meta programming.
Definition: models/abm/analyze_result.h:30
IOResult< T > deserialize(IOContext &io, Tag< T > tag)
Restores an object from the data stored in an IO context.
Definition: io.h:860
auto failure(const IOStatus &s)
Create an object that is implicitly convertible to an error IOResult<T>.
Definition: io.h:380
@ UnknownError
@ InvalidType
void serialize(IOContext &io, const T &t)
Save data that describes an object in a format determined by the given context.
Definition: io.h:836
boost::outcome_v2::in_place_type_t< T > Tag
Type that is used for overload resolution.
Definition: io.h:407
IOResult< T > deserialize_binary(ByteStream &stream, Tag< T >, int flags=0)
Deserialize an object from binary format.
Definition: binary_serializer.h:468
requires(!std::is_trivial_v< T >) void BinarySerializerObject
Definition: binary_serializer.h:333
auto success()
Create an object that is implicitly convertible to a succesful IOResult<void>.
Definition: io.h:359
ByteStream serialize_binary(const T &t, int flags=0)
Serialize an object into binary format.
Definition: binary_serializer.h:452
void unused(T &&...)
Does nothing, can be used to mark variables as not used.
Definition: compiler_diagnostics.h:30
@ IOF_IncludeTypeInfo
Include type info in the serialization.
Definition: io.h:88
boost::outcome_v2::unchecked< T, IOStatus > IOResult
Value-or-error type for operations that return a value but can fail.
Definition: io.h:353
Generated by