NewNet::Buffer Class Reference

A character buffer class. More...

#include <nnbuffer.h>

Inheritance diagram for NewNet::Buffer:

NewNet::Object List of all members.

Public Member Functions

 Buffer ()
 Create an empty buffer.
 Buffer (const Buffer &that)
 Copy an existing buffer.
Bufferoperator= (const Buffer &that)
 Copy an existing buffer.
 ~Buffer ()
 Destructor.
unsigned char * data ()
 Get a pointer to the start of the buffer.
const unsigned char * data () const
 Get a const pointer to the start of the buffer.
size_t count () const
 Get the number of bytes that are in the buffer.
bool empty () const
 Determine if the buffer is empty.
void seek (size_t n)
 Seek forward in the buffer.
void append (const unsigned char *data, size_t n)
 Append data to the buffer.

Detailed Description

This class provides a simple character buffer that is used by ClientSocket to buffer incoming and outgoing network data.

Definition at line 32 of file nnbuffer.h.


Constructor & Destructor Documentation

NewNet::Buffer::Buffer (  )  [inline]

Create an empty buffer.

Definition at line 37 of file nnbuffer.h.

NewNet::Buffer::Buffer ( const Buffer that  )  [inline]

Copy an existing buffer.

Definition at line 43 of file nnbuffer.h.

References append(), count(), and data().

NewNet::Buffer::~Buffer (  ) 

Frees all memory allocated by the buffer.

Definition at line 25 of file nnbuffer.cpp.


Member Function Documentation

Buffer& NewNet::Buffer::operator= ( const Buffer that  )  [inline]

Copy an exisiting buffer.

Definition at line 50 of file nnbuffer.h.

References append(), count(), and data().

unsigned char* NewNet::Buffer::data (  )  [inline]

Get a pointer to the start of the character buffer.

Definition at line 64 of file nnbuffer.h.

Referenced by Buffer(), operator=(), and NewNet::ClientSocket::process().

const unsigned char* NewNet::Buffer::data (  )  const [inline]

Get a const pointer to the start of the character buffer.

Definition at line 71 of file nnbuffer.h.

size_t NewNet::Buffer::count (  )  const [inline]

Get the number of bytes that are currently stored in the character buffer.

Definition at line 79 of file nnbuffer.h.

Referenced by Buffer(), operator=(), NewNet::ClientSocket::process(), and NewNet::ClientSocket::send().

bool NewNet::Buffer::empty (  )  const [inline]

Determine if the character buffer is currently empty.

Definition at line 86 of file nnbuffer.h.

void NewNet::Buffer::seek ( size_t  n  )  [inline]

Seek forward in the character buffer. Note: this asserts that there are enough bytes in the buffer for the seek operation. It will raise a signal if there's not. Note: calling this may move or reallocate the buffer. All earlier results of data() will be invalidated.

Definition at line 96 of file nnbuffer.h.

Referenced by NewNet::ClientSocket::process().

void NewNet::Buffer::append ( const unsigned char *  data,
size_t  n 
)

Append data to the character buffer. Note: calling this may move or reallocate the buffer. All earlier results of data() will be invalidated.

Definition at line 31 of file nnbuffer.cpp.

Referenced by Buffer(), operator=(), NewNet::ClientSocket::process(), and NewNet::ClientSocket::send().


The documentation for this class was generated from the following files:
Generated on Sun Jan 7 14:00:01 2007 for NewNet by  doxygen 1.5.1