Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#include <elm/alloc/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.
|
inline |
Build a new dynamic block.
capacity | Initial capacity of allocated buffer. |
increment | Increment for enlarging the buffer. |
char * alloc | ( | int | size | ) |
Allocate a block of memory that may be initialized by caller application.
size | Size of block to allocate. |
References DynBlock::size().
|
inline |
Get the buffer base of the block.
Referenced by BlockOutStream::block(), and BlockOutStream::toString().
|
inline |
Get the capacity of the block.
|
inline |
Detach the block from this dynamic manager. The dynamic block must no more be used after this call.
Referenced by BlockOutStream::detach().
void 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. |
References DynBlock::size().
|
inline |
Get the incrementation value.
void 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 DynBlock::size().
Referenced by BlockOutStream::write().
Reset the block to a size of 0.
Referenced by BlockOutStream::clear().
|
inline |
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 BlockOutStream::setSize().
|
inline |
Get the ize of the block.
Referenced by DynBlock::alloc(), DynBlock::get(), DynBlock::put(), BlockOutStream::size(), and BlockOutStream::toString().