unilink  0.4.3
A simple C++ library for unified async communication
unilink::memory::SafeDataBuffer Class Reference

Safe data buffer for type-safe data transfer. More...

#include <safe_data_buffer.hpp>

Public Member Functions

 SafeDataBuffer (const std::string &data)
 
 SafeDataBuffer (std::string_view data)
 
 SafeDataBuffer (std::vector< uint8_t > data)
 
 SafeDataBuffer (const uint8_t *data, size_t size)
 
 SafeDataBuffer (const char *data, size_t size)
 
 SafeDataBuffer (ConstByteSpan span)
 
 SafeDataBuffer (const SafeDataBuffer &)=default
 
SafeDataBufferoperator= (const SafeDataBuffer &)=default
 
 SafeDataBuffer (SafeDataBuffer &&)=default
 
SafeDataBufferoperator= (SafeDataBuffer &&)=default
 
 ~SafeDataBuffer ()=default
 
std::string as_string () const
 
ConstByteSpan as_span () const noexcept
 
const uint8_t * data () const noexcept
 
size_t size () const noexcept
 
bool empty () const noexcept
 
const uint8_t & operator[] (size_t index) const
 
const uint8_t & at (size_t index) const
 
bool operator== (const SafeDataBuffer &other) const noexcept
 
bool operator!= (const SafeDataBuffer &other) const noexcept
 
void clear () noexcept
 
void reserve (size_t capacity)
 
void resize (size_t new_size)
 
bool is_valid () const noexcept
 
void validate () const
 

Detailed Description

Safe data buffer for type-safe data transfer.

This class provides a safe wrapper around binary data that can be constructed from various sources and provides safe access methods.

Definition at line 40 of file safe_data_buffer.hpp.

Constructor & Destructor Documentation

◆ SafeDataBuffer() [1/8]

unilink::memory::SafeDataBuffer::SafeDataBuffer ( const std::string &  data)
explicit

Definition at line 26 of file safe_data_buffer.cc.

◆ SafeDataBuffer() [2/8]

unilink::memory::SafeDataBuffer::SafeDataBuffer ( std::string_view  data)
explicit

Definition at line 30 of file safe_data_buffer.cc.

◆ SafeDataBuffer() [3/8]

unilink::memory::SafeDataBuffer::SafeDataBuffer ( std::vector< uint8_t >  data)
explicit

Definition at line 34 of file safe_data_buffer.cc.

◆ SafeDataBuffer() [4/8]

unilink::memory::SafeDataBuffer::SafeDataBuffer ( const uint8_t *  data,
size_t  size 
)
explicit

Definition at line 38 of file safe_data_buffer.cc.

◆ SafeDataBuffer() [5/8]

unilink::memory::SafeDataBuffer::SafeDataBuffer ( const char *  data,
size_t  size 
)
explicit

Definition at line 45 of file safe_data_buffer.cc.

◆ SafeDataBuffer() [6/8]

unilink::memory::SafeDataBuffer::SafeDataBuffer ( ConstByteSpan  span)
explicit

Definition at line 52 of file safe_data_buffer.cc.

◆ SafeDataBuffer() [7/8]

unilink::memory::SafeDataBuffer::SafeDataBuffer ( const SafeDataBuffer )
default

◆ SafeDataBuffer() [8/8]

unilink::memory::SafeDataBuffer::SafeDataBuffer ( SafeDataBuffer &&  )
default

◆ ~SafeDataBuffer()

unilink::memory::SafeDataBuffer::~SafeDataBuffer ( )
default

Member Function Documentation

◆ as_span()

ConstByteSpan unilink::memory::SafeDataBuffer::as_span ( ) const
noexcept

Definition at line 62 of file safe_data_buffer.cc.

◆ as_string()

std::string unilink::memory::SafeDataBuffer::as_string ( ) const

Definition at line 60 of file safe_data_buffer.cc.

◆ at()

const uint8_t & unilink::memory::SafeDataBuffer::at ( size_t  index) const

Definition at line 76 of file safe_data_buffer.cc.

◆ clear()

void unilink::memory::SafeDataBuffer::clear ( )
noexcept

Definition at line 87 of file safe_data_buffer.cc.

◆ data()

const uint8_t * unilink::memory::SafeDataBuffer::data ( ) const
noexcept

Definition at line 64 of file safe_data_buffer.cc.

◆ empty()

bool unilink::memory::SafeDataBuffer::empty ( ) const
noexcept

Definition at line 68 of file safe_data_buffer.cc.

◆ is_valid()

bool unilink::memory::SafeDataBuffer::is_valid ( ) const
noexcept

Definition at line 94 of file safe_data_buffer.cc.

◆ operator!=()

bool unilink::memory::SafeDataBuffer::operator!= ( const SafeDataBuffer other) const
noexcept

Definition at line 84 of file safe_data_buffer.cc.

◆ operator=() [1/2]

SafeDataBuffer& unilink::memory::SafeDataBuffer::operator= ( const SafeDataBuffer )
default

◆ operator=() [2/2]

SafeDataBuffer& unilink::memory::SafeDataBuffer::operator= ( SafeDataBuffer &&  )
default

◆ operator==()

bool unilink::memory::SafeDataBuffer::operator== ( const SafeDataBuffer other) const
noexcept

Definition at line 82 of file safe_data_buffer.cc.

◆ operator[]()

const uint8_t & unilink::memory::SafeDataBuffer::operator[] ( size_t  index) const

Definition at line 71 of file safe_data_buffer.cc.

◆ reserve()

void unilink::memory::SafeDataBuffer::reserve ( size_t  capacity)

Definition at line 89 of file safe_data_buffer.cc.

◆ resize()

void unilink::memory::SafeDataBuffer::resize ( size_t  new_size)

Definition at line 91 of file safe_data_buffer.cc.

◆ size()

size_t unilink::memory::SafeDataBuffer::size ( ) const
noexcept

Definition at line 66 of file safe_data_buffer.cc.

◆ validate()

void unilink::memory::SafeDataBuffer::validate ( ) const

Definition at line 98 of file safe_data_buffer.cc.


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