Elm
1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#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) |
This class implements an exyensible block of memory.
elm::block::DynBlock::DynBlock | ( | int | capacity = 256 , |
int | increment = 64 |
||
) |
Build a new dynamic block.
capacity | Initial capacity of allocated buffer. |
increment | Increment for enlarging the buffer. |
elm::block::DynBlock::~DynBlock | ( | void | ) |
Delete the buffer.
char * elm::block::DynBlock::alloc | ( | int | size | ) |
Allocate a block of memory that may be initialized by caller application.
size | Size of block to allocate. |
References size().
const char * elm::block::DynBlock::base | ( | void | ) | const |
Get the buffer base of the block.
Referenced by elm::io::BlockOutStream::block(), and elm::io::BlockOutStream::toString().
int elm::block::DynBlock::capacity | ( | void | ) | const |
Get the capacity of the block.
char * elm::block::DynBlock::detach | ( | void | ) |
Detach the block from this dynamic manager. The dynamic block must no more be used after this call.
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.
block | Block to put bytes in. |
size | Size of the block. |
pos | Position to get bytes from. |
int elm::block::DynBlock::increment | ( | void | ) | const |
Get the 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.
block | Block to put in. |
size | Size 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.
new_size | New size of the block. |
Referenced by elm::io::BlockOutStream::setSize().
int elm::block::DynBlock::size | ( | void | ) | const |
Get the ize of the block.
Referenced by alloc(), put(), elm::io::BlockOutStream::size(), and elm::io::BlockOutStream::toString().