OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::nuraft_serializer Class Referencefinal

Implements serializer for nuraft::buffer. More...

#include <serialization.hpp>

Inheritance diagram for cbdc::nuraft_serializer:
Collaboration diagram for cbdc::nuraft_serializer:

Public Member Functions

 nuraft_serializer (nuraft::buffer &buf)
 Constructor.
 
 operator bool () const final
 Bool operator for checking whether the last serialization operation completed successfully.
 
void advance_cursor (size_t len) final
 Moves the cursor inside the buffer forward by the given number of bytes.
 
void reset () final
 Resets the cursor to the start of the buffer.
 
auto end_of_buffer () const -> bool final
 Returns whether the cursor is currently at the end of the buffer.
 
auto write (const void *data, size_t len) -> bool final
 Writes the given raw bytes to the buffer from the current position of the cursor.
 
auto read (void *data, size_t len) -> bool final
 Reads the given number of bytes from the current cursor in the buffer into the given destination.
 
- Public Member Functions inherited from cbdc::serializer
virtual ~serializer ()=default
 
 serializer (const serializer &)=delete
 
auto operator= (const serializer &)=delete
 
 serializer (serializer &&)=delete
 
auto operator= (serializer &&)=delete
 

Additional Inherited Members

- Protected Member Functions inherited from cbdc::serializer
 serializer ()=default
 

Detailed Description

Implements serializer for nuraft::buffer.

NuRaft buffers contain a cursor which this class manipulates directly.

Definition at line 17 of file util/raft/serialization.hpp.

Constructor & Destructor Documentation

◆ nuraft_serializer()

cbdc::nuraft_serializer::nuraft_serializer ( nuraft::buffer & buf)
explicit

Constructor.

Resets the buffer's internal cursor.

Parameters
bufnuraft::buffer to serialize into and out of.

Definition at line 13 of file util/raft/serialization.cpp.

References reset().

Here is the call graph for this function:

Member Function Documentation

◆ advance_cursor()

void cbdc::nuraft_serializer::advance_cursor ( size_t len)
finalvirtual

Moves the cursor inside the buffer forward by the given number of bytes.

Does not change the size of the buffer.

Parameters
lennumber of bytes by which to advance the cursor.

Implements cbdc::serializer.

Definition at line 21 of file util/raft/serialization.cpp.

◆ end_of_buffer()

auto cbdc::nuraft_serializer::end_of_buffer ( ) const -> bool
nodiscardfinalvirtual

Returns whether the cursor is currently at the end of the buffer.

Returns
true if there are no more bytes to read or no more space to write to the buffer.

Implements cbdc::serializer.

Definition at line 30 of file util/raft/serialization.cpp.

◆ operator bool()

cbdc::nuraft_serializer::operator bool ( ) const
explicitfinalvirtual

Bool operator for checking whether the last serialization operation completed successfully.

Returns
false if the last serialization operation failed.

Implements cbdc::serializer.

Definition at line 17 of file util/raft/serialization.cpp.

◆ read()

auto cbdc::nuraft_serializer::read ( void * data,
size_t len ) -> bool
finalvirtual

Reads the given number of bytes from the current cursor in the buffer into the given destination.

Parameters
datapointer to the destination for the data.
lennumber of bytes to read from the buffer.
Returns
true if operation successfully copied the requested number of bytes from the buffer to the given destination.

Implements cbdc::serializer.

Definition at line 45 of file util/raft/serialization.cpp.

◆ reset()

void cbdc::nuraft_serializer::reset ( )
finalvirtual

Resets the cursor to the start of the buffer.

Implements cbdc::serializer.

Definition at line 25 of file util/raft/serialization.cpp.

Referenced by nuraft_serializer().

◆ write()

auto cbdc::nuraft_serializer::write ( const void * data,
size_t len ) -> bool
finalvirtual

Writes the given raw bytes to the buffer from the current position of the cursor.

Does not resize the buffer.

Parameters
datapointer to the start of the data to write.
lennumber of bytes to write.
Returns
true if the operation wrote the entirety of the data to the buffer.

Implements cbdc::serializer.

Definition at line 34 of file util/raft/serialization.cpp.


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