OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::serializer Class Referenceabstract

Interface for serializing objects into and out of raw bytes representations. More...

#include <serializer.hpp>

Inheritance diagram for cbdc::serializer:

Public Member Functions

virtual ~serializer ()=default
 
 serializer (const serializer &)=delete
 
auto operator= (const serializer &)=delete
 
 serializer (serializer &&)=delete
 
auto operator= (serializer &&)=delete
 
virtual operator bool () const =0
 Indicates whether the last serialization operation succeeded.
 
virtual void advance_cursor (size_t len)=0
 Moves the serialization cursor forward by the given number of bytes.
 
virtual void reset ()=0
 Resets the cursor to the start of the buffer.
 
virtual auto end_of_buffer () const -> bool=0
 Indicates whether the cursor is at or beyond the end of the buffer.
 
virtual auto write (const void *data, size_t len) -> bool=0
 Attempts to write the given raw data into the buffer starting at the current cursor position.
 
virtual auto read (void *data, size_t len) -> bool=0
 Attempts to read the requested number of bytes from the current cursor position into the given memory location.
 

Protected Member Functions

 serializer ()=default
 

Detailed Description

Interface for serializing objects into and out of raw bytes representations.

Definition at line 14 of file serializer.hpp.

Constructor & Destructor Documentation

◆ ~serializer()

virtual cbdc::serializer::~serializer ( )
virtualdefault

◆ serializer() [1/3]

cbdc::serializer::serializer ( const serializer & )
delete

◆ serializer() [2/3]

cbdc::serializer::serializer ( serializer && )
delete

◆ serializer() [3/3]

cbdc::serializer::serializer ( )
protecteddefault

Member Function Documentation

◆ advance_cursor()

virtual void cbdc::serializer::advance_cursor ( size_t len)
pure virtual

Moves the serialization cursor forward by the given number of bytes.

Parameters
lennumber of bytes to advance the cursor by.

Implemented in cbdc::buffer_serializer, cbdc::istream_serializer, cbdc::nuraft_serializer, cbdc::ostream_serializer, and cbdc::size_serializer.

◆ end_of_buffer()

virtual auto cbdc::serializer::end_of_buffer ( ) const -> bool
nodiscardpure virtual

Indicates whether the cursor is at or beyond the end of the buffer.

Returns
true if the cursor is at or beyond the end of the buffer.

Implemented in cbdc::buffer_serializer, cbdc::istream_serializer, cbdc::nuraft_serializer, cbdc::ostream_serializer, and cbdc::size_serializer.

◆ operator bool()

virtual cbdc::serializer::operator bool ( ) const
explicitpure virtual

Indicates whether the last serialization operation succeeded.

Returns
true if the last serialization succeeded.

Implemented in cbdc::buffer_serializer, cbdc::nuraft_serializer, cbdc::size_serializer, and cbdc::stream_serializer.

◆ operator=() [1/2]

auto cbdc::serializer::operator= ( const serializer & )
delete

◆ operator=() [2/2]

auto cbdc::serializer::operator= ( serializer && )
delete

◆ read()

virtual auto cbdc::serializer::read ( void * data,
size_t len ) -> bool
pure virtual

Attempts to read the requested number of bytes from the current cursor position into the given memory location.

Parameters
datamemory destination into which to copy the data from the buffer.
lennumber of bytes to read from the buffer.
Returns
true if the serializer read the requested number of bytes from the buffer into the destination.

Implemented in cbdc::buffer_serializer, cbdc::istream_serializer, cbdc::nuraft_serializer, cbdc::ostream_serializer, and cbdc::size_serializer.

Referenced by cbdc::rlp_value::read_from().

◆ reset()

virtual void cbdc::serializer::reset ( )
pure virtual

◆ write()

virtual auto cbdc::serializer::write ( const void * data,
size_t len ) -> bool
pure virtual

Attempts to write the given raw data into the buffer starting at the current cursor position.

Parameters
datapointer to the start of the data to write.
lennumber of bytes of the data to write.
Returns
true if the serializer wrote the requested number of bytes to the buffer.

Implemented in cbdc::buffer_serializer, cbdc::istream_serializer, cbdc::nuraft_serializer, cbdc::ostream_serializer, and cbdc::size_serializer.


The documentation for this class was generated from the following file: