#include <Buffer.h++>


Public Member Functions | |
| Buffer (size_t size) | |
| Construct a new Buffer with the given size. | |
| virtual | ~Buffer () throw () |
| Destructor. | |
| virtual void | clear () throw () |
| Clear the buffer. | |
| void | flip () throw () |
| Flip the buffer. | |
| void | rewind () throw () |
| Rewind the buffer. | |
| void | setLimit (size_t limit) throw () |
| Set the limit. | |
| void | setPosition (size_t pos) throw () |
| Set the position. | |
| size_t | bump (size_t delta) throw () |
| Bump (advance) the position by the given number of elements, or to the limit, whichever occurs first. | |
| size_t | skip (size_t delta) throw () |
| Advance the position by the given number of elements, or to the limit, whichever occurs first, filling the "skipped" elements with zeroes. | |
| bool | put (const T &item) throw () |
| Copy an item into the buffer at the current position and bump the position by 1. | |
| bool | get (T *item) throw () |
| Copy an item from the buffer at the current position and bump the position by 1. | |
| bool | put (const T *items, size_t count) throw () |
| Copy an array of items into the buffer starting at the current position, and bump the position by the number of items. | |
| void | fill (const T &item, size_t count=0) throw () |
| Fill the buffer with a given item. | |
| bool | get (T *items, size_t count) throw () |
| Copy an array of items from the buffer starting at the current position, and bump the position by the number of items. | |
| int | peek (const T &item) const throw () |
| Scan forward from the current position for an element equal to the given value. | |
| T * | getPointer () throw () |
| Get a pointer to the element at the current position. | |
| const T * | getPointer () const throw () |
| Get a pointer to the next element to be read or written. | |
| size_t | getLimit () const throw () |
| Get the limit. | |
| size_t | getRemaining () const throw () |
| Get the number of elements available to be read or written. | |
| bool | hasRemaining () const throw () |
| Test if there are any elements available to be read or written. | |
| size_t | getPosition () const throw () |
| Get the position of the next element to be read or written. | |
| T & | operator[] (int index) throw (OutOfBoundsException) |
| Get a reference to the element at the specified index. | |
| T | operator[] (int index) const throw (OutOfBoundsException) |
| Get a copy of the element at the specified index. | |
| virtual void | setSize (size_t newSize) |
| Resize the buffer. | |
| size_t | getSize () const throw () |
| Get the size of the buffer. | |
| T * | getBase () throw () |
| Get a pointer to the base of the buffer. | |
| const T * | getBase () const throw () |
| Get a pointer to the base of the buffer. | |
Protected Attributes | |
| size_t | _limit |
| The limit. | |
| size_t | _pos |
| The position. | |
| T * | _data |
| A pointer to the raw buffer. | |
| size_t | _size |
| The size of the buffer. | |
The buffer has a limit, which defines a subrange of the entire buffer that is available for reading or writing, and a position, which is the offset of the next element to be read or written.
| Buffer | ( | size_t | size | ) | [inline] |
Construct a new Buffer with the given size.
| size | The capacity of the buffer, in elements. |
| ~Buffer | ( | ) | throw () [inline, virtual] |
Destructor.
| size_t bump | ( | size_t | delta | ) | throw () [inline] |
Bump (advance) the position by the given number of elements, or to the limit, whichever occurs first.
| delta | The number of elements. |
| void clear | ( | ) | throw () [inline, virtual] |
Clear the buffer.
Sets the position to 0 and the limit to the end of the buffer.
Reimplemented from AbstractBuffer< T >.
| void fill | ( | const T & | item, | |
| size_t | count = 0 | |||
| ) | throw () [inline] |
Fill the buffer with a given item.
| item | The item to fill with. | |
| count | The number of elements to fill. If 0 or greater than the number of elements before the limit, the buffer is filled up to the limit. |
| void flip | ( | ) | throw () [inline] |
Flip the buffer.
Sets the limit to the current position, and the position to 0.
| bool get | ( | T * | items, | |
| size_t | count | |||
| ) | throw () [inline] |
Copy an array of items from the buffer starting at the current position, and bump the position by the number of items.
| items | The items to copy into. | |
| count | The number of items. |
| bool get | ( | T * | item | ) | throw () [inline] |
Copy an item from the buffer at the current position and bump the position by 1.
| item | The item. |
| const T * getBase | ( | ) | const throw () [inline, inherited] |
Get a pointer to the base of the buffer.
| T * getBase | ( | ) | throw () [inline, inherited] |
Get a pointer to the base of the buffer.
| size_t getLimit | ( | ) | const throw () [inline] |
Get the limit.
| const T* getPointer | ( | ) | const throw () [inline] |
Get a pointer to the next element to be read or written.
| T* getPointer | ( | ) | throw () [inline] |
Get a pointer to the element at the current position.
| size_t getPosition | ( | ) | const throw () [inline] |
Get the position of the next element to be read or written.
| size_t getRemaining | ( | ) | const throw () [inline, virtual] |
Get the number of elements available to be read or written.
Implements AbstractBuffer< T >.
| size_t getSize | ( | ) | const throw () [inline, inherited] |
Get the size of the buffer.
| bool hasRemaining | ( | ) | const throw () [inline, virtual] |
Test if there are any elements available to be read or written.
Reimplemented from AbstractBuffer< T >.
| T operator[] | ( | int | index | ) | const throw (OutOfBoundsException) [inline] |
Get a copy of the element at the specified index.
| index | The index of the element. |
| OutOfBoundsException | If the index is out of bounds. |
| T & operator[] | ( | int | index | ) | throw (OutOfBoundsException) [inline] |
Get a reference to the element at the specified index.
| index | The index of the element. |
| OutOfBoundsException | If the index is out of bounds. |
| int peek | ( | const T & | item | ) | const throw () [inline] |
Scan forward from the current position for an element equal to the given value.
| item | The item to scan for. |
| bool put | ( | const T * | items, | |
| size_t | count | |||
| ) | throw () [inline] |
Copy an array of items into the buffer starting at the current position, and bump the position by the number of items.
| items | The items to place in the buffer. | |
| count | The number of items. |
| bool put | ( | const T & | item | ) | throw () [inline] |
Copy an item into the buffer at the current position and bump the position by 1.
| item | The item. |
| void rewind | ( | ) | throw () [inline] |
Rewind the buffer.
Sets the position to 0.
| void setLimit | ( | size_t | limit | ) | throw () [inline] |
Set the limit.
| void setPosition | ( | size_t | pos | ) | throw () [inline] |
Set the position.
| virtual void setSize | ( | size_t | newSize | ) | [virtual, inherited] |
Resize the buffer.
| newSize | The new size, in elements. |
Reimplemented in CircularBuffer< T >, and JavaBuffer.
| size_t skip | ( | size_t | delta | ) | throw () [inline] |
Advance the position by the given number of elements, or to the limit, whichever occurs first, filling the "skipped" elements with zeroes.
| delta | The number of elements. |
T * _data [protected, inherited] |
A pointer to the raw buffer.
size_t _limit [protected] |
The limit.
size_t _pos [protected] |
The position.
size_t _size [protected, inherited] |
The size of the buffer.
1.5.9