NetLink Sockets C++  1.0.0
Networking C++ Library
 All Classes Namespaces Files Functions Enumerations Enumerator Pages
Public Member Functions | List of all members
NL::SmartBuffer Class Reference

#include <netlink/smart_buffer.h>

Public Member Functions

 SmartBuffer (size_t allocSize=DEFAULT_SMARTBUFFER_SIZE, double reallocRatio=DEFAULT_SMARTBUFFER_REALLOC_RATIO)
 
 SmartBuffer (SmartBuffer &s)
 
 ~SmartBuffer ()
 
const void * operator* () const
 
const char * operator[] (size_t index) const
 
const void * buffer () const
 
size_t size () const
 
void read (Socket *socket)
 
void clear ()
 
SmartBufferoperator= (SmartBuffer &s)
 

Detailed Description

Smart Buffer Class

Buffer class to retrieve data of unknown size easily from a Socket

Examples:
webGet.cc.

Constructor & Destructor Documentation

SmartBuffer::SmartBuffer ( size_t  allocSize = DEFAULT_SMARTBUFFER_SIZE,
double  reallocRatio = DEFAULT_SMARTBUFFER_REALLOC_RATIO 
)

SmartBuffer Constructor

Parameters
allocSizeSize in bytes of the initial reserved memory.
reallocRatioGrowing ratio for memory reallocs. For example 1.5 means that each time the buffer is out of memory it reserves the previous size 1.5 times (150%).
Exceptions
ExceptionERROR_ALLOC
SmartBuffer::SmartBuffer ( SmartBuffer s)

SmartBuffer Copy Constructor

Parameters
sSmartBuffer source of data.
Exceptions
ExceptionERROR_ALLOC
SmartBuffer::~SmartBuffer ( )

SmartBuffer Destructor

Member Function Documentation

const void * NL::SmartBuffer::buffer ( ) const
inline

Returns the buffer data address. Same of operator*()

Returns
A pointer to data
void NL::SmartBuffer::clear ( )
inline

Clears the buffer.

Resets the buffer erasing all its content.

const void * NL::SmartBuffer::operator* ( ) const
inline

Returns the buffer data address. Same of buffer().

Returns
A pointer to data
SmartBuffer & SmartBuffer::operator= ( SmartBuffer s)

Copy Operator.

Parameters
sSmartBuffer source of data.
Exceptions
ExceptionERROR_ALLOC
const char * NL::SmartBuffer::operator[] ( size_t  index) const
inline

Returns the byte in position index of the buffer

Parameters
indexPosition of the buffer we want to retrieve
Returns
Char with the content of the given position
Exceptions
ExceptionOUT_OF_RANGE
void SmartBuffer::read ( Socket socket)

Inserts the data read from a socket in the buffer

Parameters
socketSocket to be used as source
Exceptions
ExceptionERROR_ALLOC, ERROR_READ*
size_t NL::SmartBuffer::size ( ) const
inline

Returns the amount of bytes of data stored in the buffer

Returns
Size of buffer data
Examples:
webGet.cc.

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