Serialization data sink backed by a pre-allocated memory block. More...
#include <eagine/serialize/block_sink.hpp>
Public Member Functions | |
constexpr | block_data_sink () noexcept=default |
Default constructor. More... | |
block_data_sink (memory::block dst) noexcept | |
Constructor setting the backing block. | |
void | reset (memory::block dst) |
Resets the backing block. More... | |
auto | done () const noexcept -> memory::block |
Returns the part of the backing block already written to. More... | |
auto | free () const noexcept -> memory::block |
Returns the free part of the backing block. More... | |
auto | remaining_size () -> span_size_t final |
Returns the size of the free part of the backing block. More... | |
auto | write (memory::const_block blk) -> serialization_errors final |
Writes a block of data into this sink. | |
auto | replace_with (memory::const_block blk) -> serialization_errors |
Replaces the content of the backing block with the content of the argument. More... | |
auto | begin_work () -> transaction_handle final |
Begins a write transaction on this data sink. More... | |
void | commit (transaction_handle th) final |
Commits writes done as a part of transaction identified by argument. More... | |
void | rollback (transaction_handle th) final |
Rolls-back writes done as a part of transaction identified by argument. More... | |
auto | finalize () -> serialization_errors override |
Does additional finalization, like compression after serialization operation. | |
virtual auto | write (memory::const_block data) -> result=0 |
Writes a block of data into this sink. | |
auto | write (char chr) -> result |
Writes a single string character into this sink. | |
auto | write (string_view str) -> result |
Writes a string view into this sink. | |
![]() | |
auto | write (char chr) -> result |
Writes a single string character into this sink. | |
auto | write (string_view str) -> result |
Writes a string view into this sink. | |
auto | write_some (memory::const_split_block data) -> serialization_result< memory::const_split_block > |
Writes as much as possible from a split data block. | |
Additional Inherited Members | |
![]() | |
using | result = serialization_errors |
Alias for the operation result type. | |
using | transaction_handle = std::uintptr_t |
Alias for type indentifying sink transaction that can be rolled back. | |
![]() | |
constexpr | abstract () noexcept=default |
Default constructible by derived. | |
constexpr | abstract (abstract &&) noexcept=default |
Move constructible by derived. | |
constexpr | abstract (const abstract &) noexcept=default |
Copy constructible by derived. | |
auto | operator= (abstract &&) noexcept -> abstract &=default |
Move assignable by derived. | |
auto | operator= (const abstract &) noexcept -> abstract &=default |
Copy assignable by derived. | |
Serialization data sink backed by a pre-allocated memory block.
|
constexprdefaultnoexcept |
Default constructor.
|
inlinefinalvirtual |
Begins a write transaction on this data sink.
Implements eagine::serializer_data_sink.
|
inlinefinalvirtual |
Commits writes done as a part of transaction identified by argument.
Implements eagine::serializer_data_sink.
|
inlinenoexcept |
Returns the part of the backing block already written to.
Referenced by eagine::msgbus::default_serialize(), eagine::msgbus::default_serialize_packed(), eagine::packed_block_data_sink::finalize(), and eagine::msgbus::posix_mqueue_connection::send().
|
inlinenoexcept |
Returns the free part of the backing block.
Referenced by remaining_size(), and write().
|
inlinefinalvirtual |
Returns the size of the free part of the backing block.
Implements eagine::serializer_data_sink.
|
inline |
Replaces the content of the backing block with the content of the argument.
Referenced by eagine::packed_block_data_sink::finalize().
|
inline |
Resets the backing block.
|
inlinefinalvirtual |
Rolls-back writes done as a part of transaction identified by argument.
Implements eagine::serializer_data_sink.