code::Buffer Class Reference

List of all members.

Detailed Description

The class Buffer provides a convenient way to pass around data buffers without worrying about memory leaks.

Buffer is implemented as holding a smart pointer to a std::vector of characters.

Author:
: Lakshman
Version:
:
Id
code_Buffer.h,v 1.17 2009/06/02 20:17:39 lakshman Exp


Public Member Functions

std::vector< char > & data ()
 Returns a pointer to the internal array of bytes.
const std::vector< char > & data () const
 Returns a constant pointer to the internal array of bytes.
int getLength () const
 Returns current buffer length.
int size () const
 Identical to getLength().
bool empty () const
void assign (const char *buf, int buflen)
 Buffer (const char *buf, int buflen)
 Construct out of passed in buffer.
 Buffer (const std::vector< char > &buf)
 Construct out of passed in std::vector of char.
 Buffer (const Buffer &orig, int st_ind, int end_ind)
 Construct a buffer from another buffer between two indices.
 Buffer (int buflen)
 Construct a buffer of passed in length.
void append (const Buffer &s)
 Appends another buffer to this one.
 Buffer ()
 Creates empty buffer.
Buffer clone () const
 Makes a wholly separate copy.
char & operator[] (size_t n)
 operator [] allows you to use Buffer just like an array.
const char & operator[] (size_t n) const
 operator [] allows you to use Buffer just like an array.
const char * begin () const
 Returns a pointer to the beginning of the data location.
char * begin ()
 Returns a pointer to the beginning of the data location.

Protected Attributes

InitSmartPtr< std::vector<
char > > 
d_data


Constructor & Destructor Documentation

code::Buffer::Buffer ( const char *  buf,
int  buflen 
) [inline]

Construct out of passed in buffer.

Makes a copy of the buffer, so you can safely delete buf when you are done.

code::Buffer::Buffer ( const std::vector< char > &  buf  )  [inline]

Construct out of passed in std::vector of char.

code::Buffer::Buffer ( const Buffer orig,
int  st_ind,
int  end_ind 
) [inline]

Construct a buffer from another buffer between two indices.

code::Buffer::Buffer ( int  buflen  )  [inline]

Construct a buffer of passed in length.

Contents of buffer are uninitialized.

code::Buffer::Buffer (  )  [inline]

Creates empty buffer.


Member Function Documentation

void code::Buffer::append ( const Buffer s  )  [inline]

Appends another buffer to this one.

void code::Buffer::assign ( const char *  buf,
int  buflen 
) [inline]

char* code::Buffer::begin (  )  [inline]

Returns a pointer to the beginning of the data location.

const char* code::Buffer::begin (  )  const [inline]

Returns a pointer to the beginning of the data location.

Buffer code::Buffer::clone (  )  const [inline]

Makes a wholly separate copy.

const std::vector<char>& code::Buffer::data (  )  const [inline]

Returns a constant pointer to the internal array of bytes.

std::vector<char>& code::Buffer::data (  )  [inline]

Returns a pointer to the internal array of bytes.

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

int code::Buffer::getLength (  )  const [inline]

Returns current buffer length.

Returns zero if the buffer is empty.

const char& code::Buffer::operator[] ( size_t  n  )  const [inline]

operator [] allows you to use Buffer just like an array.

e.g: Buffer buf(...); char c = buf[3]; will get the 3rd char.

char& code::Buffer::operator[] ( size_t  n  )  [inline]

operator [] allows you to use Buffer just like an array.

e.g: Buffer buf(...); buf[3] = 'c'; will set the 3rd char.

int code::Buffer::size (  )  const [inline]

Identical to getLength().


Member Data Documentation

InitSmartPtr< std::vector<char> > code::Buffer::d_data [protected]


Generated on Fri May 4 13:40:12 2012 for WDSS-IIw2 by  doxygen 1.4.7