Buffer Class Reference
Buffer.
More...
#include <Buffer.h>
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.
List of all members.
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 () |
| destructor, deletes data
|
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 a or b
|
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 | |
|
) |
| | |
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 45 of file Buffer.h.
Referenced by Fill().
bool Buffer::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.
Definition at line 84 of file Buffer.cc.
int Buffer::GetCapacity |
( |
|
) |
const |
char* Buffer::GetData |
( |
|
) |
|
Gets the pointer to the first element of the underlying array.
Definition at line 29 of file Buffer.h.
const char* Buffer::GetData |
( |
|
) |
const |
Gets the pointer to the first element of the underlying array.
Definition at line 27 of file Buffer.h.
Referenced by operator=().
int Buffer::GetLimit |
( |
|
) |
const |
Gets the limit mark of the buffer. limit <= capacity.
Definition at line 37 of file Buffer.h.
Referenced by operator=().
int Buffer::GetPosition |
( |
|
) |
const |
Gets the current position. position <= limit.
Definition at line 35 of file Buffer.h.
Referenced by operator=().
bool Buffer::IsFull |
( |
|
) |
const |
Checks whether the buffer is full, that is position == limit.
Definition at line 47 of file Buffer.h.
Referenced by Fill().
static int Buffer::min |
( |
int |
a, |
|
|
int |
b | |
|
) |
| | [static, private] |
Makes this buffer a copy of the rhs buffer.
Definition at line 26 of file Buffer.cc.
void Buffer::SetCapacity |
( |
int |
size |
) |
|
Sets the capacity of the buffer. The underlying array grows and shrinks.
Definition at line 63 of file Buffer.cc.
void Buffer::SetLimit |
( |
int |
lim |
) |
|
Sets the limit mark. limit <= capacity.
Definition at line 54 of file Buffer.cc.
void Buffer::SetPosition |
( |
int |
pos |
) |
|
Sets the current position.
Definition at line 46 of file Buffer.cc.
Member Data Documentation
The documentation for this class was generated from the following files:
|