Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
elm::block::DynBlock Class Reference

#include <elm/block/DynBlock.h>

Public Member Functions

 DynBlock (int capacity=256, int increment=64)
 
 ~DynBlock (void)
 
void put (const char *block, int size)
 
void get (char *block, int size, int pos)
 
char * alloc (int size)
 
int size (void) const
 
int capacity (void) const
 
int increment (void) const
 
void setSize (int new_size)
 
void reset (void)
 
const char * base (void) const
 
char * detach (void)
 

Detailed Description

This class implements an exyensible block of memory.

Constructor & Destructor Documentation

elm::block::DynBlock::DynBlock ( int  capacity = 256,
int  increment = 64 
)

Build a new dynamic block.

Parameters
capacityInitial capacity of allocated buffer.
incrementIncrement for enlarging the buffer.
elm::block::DynBlock::~DynBlock ( void  )

Delete the buffer.

Member Function Documentation

char * elm::block::DynBlock::alloc ( int  size)

Allocate a block of memory that may be initialized by caller application.

Parameters
sizeSize of block to allocate.
Returns
Allocated block that may initialized by application.

References size().

const char * elm::block::DynBlock::base ( void  ) const

Get the buffer base of the block.

Returns
Block buffer base.

Referenced by elm::io::BlockOutStream::block(), and elm::io::BlockOutStream::toString().

int elm::block::DynBlock::capacity ( void  ) const

Get the capacity of the block.

Returns
Block capacity.
char * elm::block::DynBlock::detach ( void  )

Detach the block from this dynamic manager. The dynamic block must no more be used after this call.

Returns
Block buffer that must be fried using "delete []".

Referenced by elm::io::BlockOutStream::detach().

void elm::block::DynBlock::get ( char *  block,
int  size,
int  pos 
)

Get a part from the dynamic block. It is an error to pass a size too big, or a position out of range.

Parameters
blockBlock to put bytes in.
sizeSize of the block.
posPosition to get bytes from.
int elm::block::DynBlock::increment ( void  ) const

Get the incrementation value.

Returns
Incrementation value.
void elm::block::DynBlock::put ( const char *  block,
int  size 
)

Put a new data piece in the current block. Enlarge the block if required.

Parameters
blockBlock to put in.
sizeSize of the block.

References size().

Referenced by elm::io::BlockOutStream::write().

void elm::block::DynBlock::reset ( void  )

Reset the block to a size of 0.

Referenced by elm::io::BlockOutStream::clear().

void elm::block::DynBlock::setSize ( int  new_size)

Set the size of the block. Must be less or equal to the current block size.

Parameters
new_sizeNew size of the block.

Referenced by elm::io::BlockOutStream::setSize().

int elm::block::DynBlock::size ( void  ) const

Get the ize of the block.

Returns
Block size.

Referenced by alloc(), put(), elm::io::BlockOutStream::size(), and elm::io::BlockOutStream::toString().


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