YAMI4 Core Library 2.0.0
Messaging Solution for Distributed Systems
|
Serializable wrapper for the raw binary data. More...
#include <raw_buffer_data_source.h>
Public Member Functions | |
raw_buffer_data_source (const char **buffers, const std::size_t *buffer_sizes, std::size_t num_of_buffers) | |
Constructor. More... | |
raw_buffer_data_source (const char *buffer, std::size_t buffer_size) | |
Constructor. More... | |
virtual result | get_serialize_buffer_size (std::size_t &size) const |
Finds the total size of serialization buffer. More... | |
virtual result | serialize (char **target_buffers, const std::size_t *target_buffer_sizes, std::size_t num_of_target_buffers) const |
Serializes current content into given buffer(s). More... | |
virtual result | get_serialize_buffer_size (std::size_t &size) const =0 |
Finds the total size of serialization buffer. More... | |
virtual result | serialize (char **buffers, const std::size_t *buffer_sizes, std::size_t num_of_buffers) const =0 |
Serializes current content into given buffer(s). More... | |
Serializable wrapper for the raw binary data.
Serializable wrapper for the raw binary data allows to use already serialized content for message sending. The two major use cases for this class are efficient message forwarding (when the message is received and its content is used for another message) and support for custom data models and serializers.
yami::core::raw_buffer_data_source::raw_buffer_data_source | ( | const char ** | buffers, |
const std::size_t * | buffer_sizes, | ||
std::size_t | num_of_buffers | ||
) |
Constructor.
Constructs the buffer wrapper for the given set of buffers. The data buffer does not have to be contiguous and any number of buffer segments is allowed, provided that the size of each buffer segment is a multiple of 4 (32 bits).
The wrapper gathers the binary data from subsequent buffers as they are serialized - serialization of the wrapper copies the data from source set of buffers to the target set, which is possibly structured in a different way.
The buffers are provided as array of buffer pointers and their sizes.
buffers | Pointer to the array of buffer pointers (each of type const char * ). |
buffer_sizes | Pointer to the array of buffer sizes. |
num_of_buffers | Number of buffers described by the array. |
yami::core::raw_buffer_data_source::raw_buffer_data_source | ( | const char * | buffer, |
std::size_t | buffer_size | ||
) |
Constructor.
Constructs the buffer wrapper for the single contiguous source buffer.
buffer | Pointer to the source buffer. |
buffer_size | Source buffer size. |
|
virtual |
Finds the total size of serialization buffer.
Computes the total size of serialization buffer(s) for the current content of this object.
size | The computed size of buffer. |
ok
if operation was successfulnesting_too_deep
if the level of nesting in this object is deeper than the limit Implements yami::core::serializable.
|
virtual |
Serializes current content into given buffer(s).
Serializes the current content of this object into the given buffer(s). The serialization buffer does not have to be contiguous and any number of buffer segments is allowed, provided that the size of each buffer segment is a multiple of 4 (32 bits).
The function scatters the serialized data into subsequent buffers as they become filled.
The buffers are provided as array of buffer pointers and their sizes.
target_buffers | Pointer to the array of target buffer pointers (each of type char * ). |
target_buffer_sizes | Pointer to the array of target buffer sizes. |
num_of_target_buffers | Number of target buffers described by the array. |
ok
if operation was successfulnot_enough_space
if the buffers are not big enough for all the data Implements yami::core::serializable.