OpenCBDC Transaction Processor
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
cbdc::buffer_serializer Class Referencefinal

Serializer implementation for buffer. More...

#include <buffer_serializer.hpp>

Inheritance diagram for cbdc::buffer_serializer:
Collaboration diagram for cbdc::buffer_serializer:

Public Member Functions

 buffer_serializer (cbdc::buffer &pkt)
 Constructor.
 
 operator bool () const final
 Indicates whether the last serialization operation succeeded.
 
void advance_cursor (size_t len) final
 Moves the cursor 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
 Indicates whether the cursor is at or beyond the end of the buffer.
 
auto write (const void *data, size_t len) -> bool final
 Write the given bytes into the buffer from the current cursor position.
 
auto read (void *data, size_t len) -> bool final
 Read the given number of bytes from the buffer from the current cursor position into the given memory location.
 
- 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

Serializer implementation for buffer.

Definition at line 14 of file buffer_serializer.hpp.

Constructor & Destructor Documentation

◆ buffer_serializer()

cbdc::buffer_serializer::buffer_serializer ( cbdc::buffer & pkt)
explicit

Constructor.

Parameters
pktbuffer to serialize into or out of.

Definition at line 11 of file buffer_serializer.cpp.

Member Function Documentation

◆ advance_cursor()

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

Moves the cursor forward by the given number of bytes.

Parameters
lennumber of bytes by which to move the cursor forward.

Implements cbdc::serializer.

Definition at line 17 of file buffer_serializer.cpp.

◆ end_of_buffer()

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

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.

Implements cbdc::serializer.

Definition at line 26 of file buffer_serializer.cpp.

References cbdc::buffer::size().

Here is the call graph for this function:

◆ operator bool()

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

Indicates whether the last serialization operation succeeded.

Returns
true if the last serialization operation succeeded.

Implements cbdc::serializer.

Definition at line 13 of file buffer_serializer.cpp.

◆ read()

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

Read the given number of bytes from the buffer from the current cursor position into the given memory location.

Parameters
datapointer to the destination of the read data.
lennumber of bytes to read from the buffer.
Returns
true if the serializer read the requested number of bytes from the buffer.

Implements cbdc::serializer.

Definition at line 39 of file buffer_serializer.cpp.

◆ reset()

void cbdc::buffer_serializer::reset ( )
finalvirtual

Resets the cursor to the start of the buffer.

Implements cbdc::serializer.

Definition at line 21 of file buffer_serializer.cpp.

◆ write()

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

Write the given bytes into the buffer from the current cursor position.

If the data extends beyond the end of the buffer, expands the buffer size to fit the new data.

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

Implements cbdc::serializer.

Definition at line 30 of file buffer_serializer.cpp.


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