sockets::Buffer Class Reference

Base class for buffers. More...

#include <buffer.h>

Inheritance diagram for sockets::Buffer:

sockets::DBuffer sockets::SBuffer List of all members.

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

Detailed Description

Base class for buffers. Buffers are used by sockets to store and retrieve bytes read from the socket or bytes that need to be written to the socket.


Member Function Documentation

virtual bool sockets::Buffer::clear  )  [pure virtual]
 

Clears all data in the buffer.

Returns:
true if successful, false otherwise.

Implemented in sockets::DBuffer, and sockets::SBuffer.

virtual bool sockets::Buffer::erase size_t  len  )  [pure virtual]
 

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.

Parameters:
[in] len The number of bytes to erase. That can't be more than the size of the buffer (as returned by the size() function).
Returns:
true if successful, false otherwise.

Implemented in sockets::DBuffer, and sockets::SBuffer.

virtual bool sockets::Buffer::read size_t  max,
char const **  data,
size_t *  len
const [pure virtual]
 

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.

Parameters:
[in] max The maximum length of data, in bytes, that need to be retrieved, or zero if no limit is wanted.
[out] data A pointer to the pointer that will be set to the beginning of the data stored in the buffer.
[out] len A pointer to an integer that will be set to the length of the data that has been returned. Please note that this may be less than max and less than the actual number of bytes stored in the buffer as returned by the size() function.
Returns:
true if successful, false otherwise. Possible reasons of failure include an empty buffer.

Implemented in sockets::DBuffer, and sockets::SBuffer.

virtual bool sockets::Buffer::read_byte size_type  pos,
char *  ch
const [protected, pure virtual]
 

Reads a specific character in the buffer.

Parameters:
[in] pos The position of the character to read (0 is the position of the first character).
[out] ch On return, this will be set to the character that was requested.
Returns:
true if successful, false otherwise.

virtual bool sockets::Buffer::write char const *  data,
size_t  len
[pure virtual]
 

Writes data in the buffer. How the data is stored internally is up to the implementer.

Parameters:
[in] data The data to write. This does NOT have to be a NULL-terminated string.
[in] len The length of the data, in bytes. The data is guaranteed to be written entirely to the buffer; if there's no more room available in the buffer, the function fails.
Returns:
true if successful, false otherwise.

Implemented in sockets::DBuffer, and sockets::SBuffer.


The documentation for this class was generated from the following file:
Generated on Sun May 20 21:32:22 2007 for Epona API by  doxygen 1.4.6