Very Simple Cross-Platform Library
Public Member Functions | Private Attributes | List of all members
hu::varadiistvan::scpl::io::Buffer Class Reference

#include <Buffer.h>

Inheritance diagram for hu::varadiistvan::scpl::io::Buffer:
hu::varadiistvan::scpl::io::ReadingBuffer hu::varadiistvan::scpl::io::WritingBuffer

Public Member Functions

 Buffer (size_t capacity)
 
 ~Buffer ()
 
size_t getCapacity () const
 
const unsigned char * getData () const
 
unsigned char * getData ()
 
size_t getLength () const
 
bool isEmpty () const
 
size_t getAvailable () const
 
void reset ()
 
size_t addLength (size_t n)
 
size_t append (const void *src, size_t size)
 
size_t extract (void *dest, size_t size, size_t offset=0) const
 

Private Attributes

unsigned char * data
 
size_t capacity
 
size_t length
 

Detailed Description

Base class for buffers. It maintains a memory area of a certain capacity and the length of the data in the buffer.

Definition at line 48 of file Buffer.h.

Constructor & Destructor Documentation

◆ Buffer()

hu::varadiistvan::scpl::io::Buffer::Buffer ( size_t  capacity)
inline

Construct the buffer with the given capacity.

Definition at line 139 of file Buffer.h.

◆ ~Buffer()

hu::varadiistvan::scpl::io::Buffer::~Buffer ( )
inline

Destroy the buffer.

Definition at line 148 of file Buffer.h.

Member Function Documentation

◆ addLength()

size_t hu::varadiistvan::scpl::io::Buffer::addLength ( size_t  n)
inline

Add the given amount to the length. Should not exceed the capacity!

Returns
the actual amount added.

Definition at line 204 of file Buffer.h.

◆ append()

size_t hu::varadiistvan::scpl::io::Buffer::append ( const void *  src,
size_t  size 
)
inline

Append the given data to the contents of the given buffer.

Returns
the number of bytes actually appended

Definition at line 213 of file Buffer.h.

◆ extract()

size_t hu::varadiistvan::scpl::io::Buffer::extract ( void *  dest,
size_t  size,
size_t  offset = 0 
) const
inline

Extract data into the given buffer from the given offset.

Returns
the number of bytes actually extracted.

Definition at line 223 of file Buffer.h.

◆ getAvailable()

size_t hu::varadiistvan::scpl::io::Buffer::getAvailable ( ) const
inline

Get the available capacity in the buffer.

Definition at line 190 of file Buffer.h.

◆ getCapacity()

size_t hu::varadiistvan::scpl::io::Buffer::getCapacity ( ) const
inline

Get the capacity of the buffer.

Definition at line 155 of file Buffer.h.

◆ getData() [1/2]

unsigned char * hu::varadiistvan::scpl::io::Buffer::getData ( )
inline

Get the pointer to the data for modification.

Definition at line 169 of file Buffer.h.

◆ getData() [2/2]

const unsigned char * hu::varadiistvan::scpl::io::Buffer::getData ( ) const
inline

Get the pointer to the data.

Definition at line 162 of file Buffer.h.

◆ getLength()

size_t hu::varadiistvan::scpl::io::Buffer::getLength ( ) const
inline

Get the length of the data.

Definition at line 176 of file Buffer.h.

◆ isEmpty()

bool hu::varadiistvan::scpl::io::Buffer::isEmpty ( ) const
inline

Get whether the buffer is empty or not.

Definition at line 183 of file Buffer.h.

◆ reset()

void hu::varadiistvan::scpl::io::Buffer::reset ( )
inline

Reset the buffer.

Definition at line 197 of file Buffer.h.

Member Data Documentation

◆ capacity

size_t hu::varadiistvan::scpl::io::Buffer::capacity
private

The capacity of the buffer.

Definition at line 59 of file Buffer.h.

◆ data

unsigned char* hu::varadiistvan::scpl::io::Buffer::data
private

The data itself.

Definition at line 54 of file Buffer.h.

◆ length

size_t hu::varadiistvan::scpl::io::Buffer::length
private

The amount of data in the buffer.

Definition at line 64 of file Buffer.h.


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