10Duke Enterprise C++ SDK
Loading...
Searching...
No Matches
tenduke::utl::SimpleBuffer Class Reference

#include <SimpleBuffer.h>

Detailed Description

Simple extensible binary buffer.

The buffer grows geometrically. If an append fails (std::bad_alloc or std::length_error), the buffer is left unchanged. The memory is wiped (overwritten with zeros) before it is freed, both when the buffer grows and when it is destroyed, as the data may be plaintext or a key.

Inheritance diagram for tenduke::utl::SimpleBuffer:
tenduke::utl::BinaryData tenduke::utl::DataSink tenduke::utl::MutableDataSpan tenduke::utl::DataSpan

Public Member Functions

 SimpleBuffer (const SimpleBuffer &)=delete
SimpleBuffer & operator= (const SimpleBuffer &)=delete
void append (const std::uint8_t *newData, size_t newDataLength) override
 Appends data to the buffer.
void append (const ::tenduke::utl::DataSpan &data) override
 Appends data to the buffer.
void append (std::uint8_t byte) override
 Appends a single byte to the sink.
unsigned char * getData () const override
 Returns the data.
std::size_t getLength () const override
 Returns the length of data in bytes.
Public Member Functions inherited from tenduke::utl::BinaryData
unsigned char * data () override
 Returns a mutable view of the underlying data.
const unsigned char * data () const override
 Returns a pointer to the beginning of the underlying sequence.
std::size_t size_bytes () const override
 Returns the size of the span in bytes.
Public Member Functions inherited from tenduke::utl::MutableDataSpan
virtual const unsigned char * data () const=0
 Returns a pointer to the beginning of the underlying sequence.
Public Member Functions inherited from tenduke::utl::DataSink
virtual void append (const std::uint8_t *data, std::size_t size)=0
 Appends binary data to the sink.

Member Function Documentation

◆ append() [1/3]

void tenduke::utl::SimpleBuffer::append ( const ::tenduke::utl::DataSpan & data)
overridevirtual

Appends data to the buffer.

Parameters
datadata to append

Implements tenduke::utl::DataSink.

◆ append() [2/3]

void tenduke::utl::SimpleBuffer::append ( const std::uint8_t * newData,
size_t newDataLength )
override

Appends data to the buffer.

Parameters
newDatadata to append, may be nullptr if newDataLength is 0
newDataLengthlength of the data to append in bytes.
Exceptions
std::length_errorif the new length would overflow std::size_t
std::bad_allocif allocating memory fails

◆ append() [3/3]

void tenduke::utl::SimpleBuffer::append ( std::uint8_t byte)
overridevirtual

Appends a single byte to the sink.

Parameters
bytebyte to append

Implements tenduke::utl::DataSink.

◆ getData()

unsigned char * tenduke::utl::SimpleBuffer::getData ( ) const
inlineoverridevirtual

Returns the data.

DO NOT free() or delete() this: The class maintains the data. The data is mutable.

Implements tenduke::utl::BinaryData.

◆ getLength()

std::size_t tenduke::utl::SimpleBuffer::getLength ( ) const
inlineoverridevirtual

Returns the length of data in bytes.

Implements tenduke::utl::BinaryData.


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