Buffer Class Reference#include <Buffer.h>
List of all members.
Detailed Description
Buffer.
A buffer has three main properties: position, capacity and limit. Capacity is the real size of the underlying array. Position is the index of the current element in the buffer (used only by buffer filling operations at the moment). Limit is the virtual size of the buffer. Operations such as filling up the buffer, seeking and so on never go over the limit mark of the buffer.
0 <= position <= limit <= capacity.
Definition at line 15 of file Buffer.h.
|
Public Member Functions |
| Buffer (int size) |
| Constructs a new buffer of specified capacity and limit.
|
| Buffer (const Buffer &rhs) |
| Constructs a copy of the buffer.
|
Buffer & | operator= (const Buffer &rhs) |
| Makes this buffer a copy of the rhs buffer.
|
virtual | ~Buffer () |
const char * | GetData () const |
| Gets the pointer to the first element of the underlying array.
|
char * | GetData () |
| Gets the pointer to the first element of the underlying array.
|
int | GetCapacity () const |
| Gets the capacity of the buffer.
|
void | SetCapacity (int size) |
| Sets the capacity of the buffer. The underlying array grows and shrinks.
|
int | GetPosition () const |
| Gets the current position. position <= limit.
|
int | GetLimit () const |
| Gets the limit mark of the buffer. limit <= capacity.
|
void | SetPosition (int pos) |
| Sets the current position.
|
void | SetLimit (int lim) |
| Sets the limit mark. limit <= capacity.
|
bool | Fill (const char *&src, int &srcLen) |
| Tries to fill the buffer from current position up to the limit mark. Advances the position, src and srcLen. Returns true if the buffer has been filled.
|
bool | Fill (char *&src, int &srcLen) |
| Tries to fill the buffer from current position up to the limit mark. Advances the position, src and srcLen. Returns true if the buffer has been filled.
|
bool | IsFull () const |
| Checks whether the buffer is full, that is position == limit.
|
Static Private Member Functions |
static int | min (int a, int b) |
| returns the lesser of or
|
Private Attributes |
char * | data |
| the buffer itself
|
int | capacity |
| the the real size of the underlying array.
|
int | limit |
| Position is the index of the current element in the buffer (used only by buffer filling operations at the moment).
|
int | position |
| Limit is the virtual size of the buffer. Operations such as filling up the buffer, seeking and so on never go over the limit mark of the buffer.
|
Constructor & Destructor Documentation
Buffer::Buffer |
( |
int |
size |
) |
|
|
|
Constructs a new buffer of specified capacity and limit.
Definition at line 4 of file Buffer.cc. |
Buffer::Buffer |
( |
const Buffer & |
rhs |
) |
|
|
|
Constructs a copy of the buffer.
Definition at line 16 of file Buffer.cc. |
Buffer::~Buffer |
( |
|
) |
[virtual] |
|
Member Function Documentation
bool Buffer::Fill |
( |
char *& |
src, |
|
|
int & |
srcLen |
|
) |
[inline] |
|
|
Tries to fill the buffer from current position up to the limit mark. Advances the position, src and srcLen. Returns true if the buffer has been filled.
Definition at line 44 of file Buffer.h. |
bool Buffer::Fill |
( |
const char *& |
src, |
|
|
int & |
srcLen |
|
) |
|
|
int Buffer::GetCapacity |
( |
|
) |
const [inline] |
|
char* Buffer::GetData |
( |
|
) |
[inline] |
|
|
Gets the pointer to the first element of the underlying array.
Definition at line 28 of file Buffer.h. |
const char* Buffer::GetData |
( |
|
) |
const [inline] |
|
int Buffer::GetLimit |
( |
|
) |
const [inline] |
|
int Buffer::GetPosition |
( |
|
) |
const [inline] |
|
bool Buffer::IsFull |
( |
|
) |
const [inline] |
|
static int Buffer::min |
( |
int |
a, |
|
|
int |
b |
|
) |
[inline, static, private] |
|
|
Makes this buffer a copy of the rhs buffer.
Definition at line 26 of file Buffer.cc. |
void Buffer::SetCapacity |
( |
int |
size |
) |
|
|
void Buffer::SetLimit |
( |
int |
lim |
) |
|
|
void Buffer::SetPosition |
( |
int |
pos |
) |
|
|
Member Data Documentation
The documentation for this class was generated from the following files:
|