Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   Related Pages  

sword::SWBuf Class Reference

This class is used as a transport and utility for data buffers. More...

#include <swbuf.h>

List of all members.

Public Member Functions

 SWBuf (const char *initVal=0)
 SWBuf Constructor - Creates an empty SWBuf object or an SWBuf initialized to a value from a const char *.

 SWBuf (char initVal)
 SWBuf Constructor - Creates an SWBuf initialized to a value from a char.

 SWBuf (const SWBuf &other)
 SWBuf Constructor - Creates an SWBuf initialized to a value from another SWBuf.

void setFillByte (char ch)
char getFillByte ()
virtual ~SWBuf ()
 SWBuf Destructor - Cleans up instance of SWBuf.

const char * c_str () const
char & charAt (unsigned int pos)
unsigned int size () const
 size() and length() return only the number of characters of the string.

unsigned int length () const
 size() and length() return only the number of characters of the string.

void set (const char *newVal)
 SWBuf::set - sets this buf to a new value.

void set (const SWBuf &newVal)
 SWBuf::set - sets this buf to a new value If the allocated memory is bigger than the new string, it will NOT be resized.

void setSize (unsigned int len)
 SWBuf::setSize - Size this buffer to a specific length.

void append (const char *str)
 SWBuf::append - appends a value to the current value of this SWBuf.

void append (const SWBuf &str)
 SWBuf::append - appends a value to the current value of this SWBuf If the allocated memory is not enough, it will be resized accordingly.

void append (char ch)
 SWBuf::append - appends a value to the current value of this SWBuf If the allocated memory is not enough, it will be resized accordingly.

void appendFormatted (const char *format,...)
 SWBuf::appendFormatted - appends formatted strings to the current value of this SWBuf WARNING: This function can only write at most JUNKBUFSIZE to the string per call.

char * getRawData ()
 operator const char * () const
char & operator[] (unsigned int pos)
char & operator[] (int pos)
SWBuf & operator= (const char *newVal)
SWBuf & operator= (const SWBuf &other)
SWBuf & operator+= (const char *str)
SWBuf & operator+= (char ch)
SWBuf & operator-= (unsigned int len)
SWBuf & operator-- (int)
SWBuf operator+ (const SWBuf &other) const
SWBuf operator+ (char ch) const

Private Member Functions

void assureSize (unsigned int newsize)
void init ()

Private Attributes

char * buf
char * end
char fillByte
unsigned int allocSize

Static Private Attributes

char * nullStr = ""
char junkBuf [8191]


Detailed Description

This class is used as a transport and utility for data buffers.


Constructor & Destructor Documentation

sword::SWBuf::SWBuf const char *    initVal = 0
 

SWBuf Constructor - Creates an empty SWBuf object or an SWBuf initialized to a value from a const char *.

sword::SWBuf::SWBuf char    initVal
 

SWBuf Constructor - Creates an SWBuf initialized to a value from a char.

sword::SWBuf::SWBuf const SWBuf &    other
 

SWBuf Constructor - Creates an SWBuf initialized to a value from another SWBuf.


Member Function Documentation

void sword::SWBuf::append char    ch [inline]
 

SWBuf::append - appends a value to the current value of this SWBuf If the allocated memory is not enough, it will be resized accordingly.

Parameters:
ch Append this.

void sword::SWBuf::append const SWBuf &    str
 

SWBuf::append - appends a value to the current value of this SWBuf If the allocated memory is not enough, it will be resized accordingly.

Parameters:
str Append this.

void sword::SWBuf::append const char *    str
 

SWBuf::append - appends a value to the current value of this SWBuf.

If the allocated memory is not enough, it will be resized accordingly.

Parameters:
str Append this.

void sword::SWBuf::appendFormatted const char *    format,
...   
 

SWBuf::appendFormatted - appends formatted strings to the current value of this SWBuf WARNING: This function can only write at most JUNKBUFSIZE to the string per call.

Parameters:
format The format string. Same syntax as printf, for example.
... Add all arguments here.

const char* sword::SWBuf::c_str   const [inline]
 

Returns:
a pointer to the buffer content (null-terminated string)

char& sword::SWBuf::charAt unsigned int    pos [inline]
 

Parameters:
pos The position of the requested character.
Returns:
The character at the specified position

unsigned int sword::SWBuf::length   const [inline]
 

size() and length() return only the number of characters of the string.

Add one for the following null and one for each char to be appended!

void sword::SWBuf::set const SWBuf &    newVal
 

SWBuf::set - sets this buf to a new value If the allocated memory is bigger than the new string, it will NOT be resized.

Parameters:
newVal the value to set this buffer to.

void sword::SWBuf::set const char *    newVal
 

SWBuf::set - sets this buf to a new value.

If the allocated memory is bigger than the new string, it will NOT be resized.

Parameters:
newVal the value to set this buffer to.

void sword::SWBuf::setSize unsigned int    len
 

SWBuf::setSize - Size this buffer to a specific length.

Parameters:
len The new size of the buffer. One byte for the null will be added.

unsigned int sword::SWBuf::size   const [inline]
 

size() and length() return only the number of characters of the string.

Add one for the following null and one for each char to be appended!


The documentation for this class was generated from the following files:
Generated on Fri Feb 28 22:01:42 2003 for The Sword Project by doxygen1.3-rc3