#include <buffer.h>
Inheritance diagram for sockets::Buffer:
Public Types | |
typedef char | value_type |
Value type. | |
typedef char & | reference |
Reference type. | |
typedef char const & | const_reference |
Const reference type. | |
typedef char * | pointer |
Pointer type. | |
typedef char const * | const_pointer |
Const pointer type. | |
typedef size_t | size_type |
Size type. | |
typedef ptrdiff_t | difference_type |
Difference type. | |
typedef Iterator | iterator |
Normal iterator type. | |
typedef iterator | const_iterator |
Const iterator type. | |
typedef std::reverse_iterator< iterator > | reverse_iterator |
Reverse iterator. | |
typedef std::reverse_iterator< const_iterator > | const_reverse_iterator |
Const reverse iterator. | |
Public Member Functions | |
virtual | ~Buffer () |
Destructor. | |
virtual bool | read (size_t max, char const **data, size_t *len) const =0 |
Reads data from the buffer. | |
virtual bool | write (char const *data, size_t len)=0 |
Writes data in the buffer. | |
virtual bool | erase (size_t len)=0 |
Erases a portion of the data in the buffer. | |
virtual bool | erase (iterator end) |
Same as erase(size_t) but with an iterator to mark the first character that is not erased. | |
virtual bool | clear ()=0 |
Clears all data in the buffer. | |
iterator | begin () |
Returns an iterator for the beginning of the buffer. | |
iterator | end () |
Returns an iterator to the end of the buffer. | |
const_iterator | begin () const |
Returns a const iterator for the beginning of the buffer. | |
const_iterator | end () const |
Returns a const iterator to the end of the buffer. | |
reverse_iterator | rbegin () |
Returns a reverse iterator to the beginning of the buffer. | |
reverse_iterator | rend () |
Returns a reverse iterator to the end of the buffer. | |
const_reverse_iterator | rbegin () const |
Returns a const reverse iterator to the beginning of the buffer. | |
const_reverse_iterator | rend () const |
Returns a const reverse iterator to the end of the buffer. | |
virtual bool | empty () const =0 |
Returns whether the buffer is empty. | |
virtual size_type | size () const =0 |
Returns the number of bytes stored in the buffer. | |
virtual size_type | max_size () const =0 |
Returns the maximum number of bytes that can be stored in the buffer. | |
virtual size_type | remaining () const |
Returns the number of bytes that can still be written to the buffer. | |
Protected Member Functions | |
virtual bool | read_byte (size_type pos, char *ch) const =0 |
Reads a specific character in the buffer. | |
Friends | |
class | Iterator |
Classes | |
class | Iterator |
|
Clears all data in the buffer.
Implemented in sockets::DBuffer, and sockets::SBuffer. |
|
Erases a portion of the data in the buffer. This portion always starts at the first byte stored in the buffer and spans the given number of bytes. The first byte of hte buffer (as returned by the read() function) will then be the byte immediately after the last character erased, if any.
Implemented in sockets::DBuffer, and sockets::SBuffer. |
|
Reads data from the buffer. This function does not copy data from the buffer; instead, it returns a pointer to the memory chunk the buffer uses to store its data. This function does NOT erase data stored in the buffer, and consecutives calls to read() will return the same sequence of bytes. See erase() to discard data.
Implemented in sockets::DBuffer, and sockets::SBuffer. |
|
Reads a specific character in the buffer.
|
|
Writes data in the buffer. How the data is stored internally is up to the implementer.
Implemented in sockets::DBuffer, and sockets::SBuffer. |