The Sword Project: sword::SWBuf Class Reference |
#include <swbuf.h>
Public Member Functions | ||||
SWBuf () | ||||
SWBuf (const char *initVal, unsigned long initSize=0) | ||||
SWBuf Constructor - Creates an SWBuf initialized to a value from a const char *. | ||||
SWBuf (char initVal, unsigned long initSize=0) | ||||
SWBuf Constructor - Creates an SWBuf initialized to a value from a char. | ||||
SWBuf (const SWBuf &other, unsigned long initSize=0) | ||||
SWBuf Constructor - Creates an SWBuf initialized to a value from another SWBuf. | ||||
~SWBuf () | ||||
void | setFillByte (char ch) | |||
SWBuf::setFillByte - Set the fillByte character. | ||||
char | getFillByte () | |||
SWBuf::getFillByte - Get the fillByte character. | ||||
const char * | c_str () const | |||
| ||||
char & | charAt (unsigned long pos) | |||
| ||||
unsigned long | size () const | |||
| ||||
void | size (unsigned long newSize) | |||
set's the size of the buffer. | ||||
unsigned long | length () const | |||
| ||||
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 | set (const char *newVal) | |||
SWBuf::set - sets this buf to a new value. | ||||
void | setFormatted (const char *format,...) | |||
SWBuf::setFormatted - sets this buf to a formatted string. | ||||
void | setSize (unsigned long len) | |||
SWBuf::setSize - Size this buffer to a specific length. | ||||
void | resize (unsigned long len) | |||
SWBuf::resize - Resize this buffer to a specific length. | ||||
void | append (const char *str, long max=-1) | |||
SWBuf::append - appends a value to the current value of this SWBuf. | ||||
void | append (const SWBuf &str, long max=-1) | |||
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. | ||||
void | insert (unsigned long pos, const char *str, unsigned long start=0, signed long max=-1) | |||
SWBuf::insert - inserts the given string at position into this string. | ||||
void | insert (unsigned long pos, const SWBuf &str, unsigned long start=0, signed long max=-1) | |||
SWBuf::insert - inserts the given string at position into this string. | ||||
void | insert (unsigned long pos, char c) | |||
SWBuf::insert - inserts the given character at position into this string. | ||||
char * | getRawData () | |||
SWBuf::getRawData. | ||||
operator const char * () const | ||||
char & | operator[] (unsigned long pos) | |||
char & | operator[] (long pos) | |||
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 long len) | |||
SWBuf & | operator-- (int) | |||
SWBuf & | operator<< (unsigned long n) | |||
SWBuf & | operator>> (unsigned long n) | |||
SWBuf | operator+ (const SWBuf &other) const | |||
SWBuf | operator+ (char ch) const | |||
SWBuf & | trimStart () | |||
SWBuf & | trimEnd () | |||
SWBuf & | trim () | |||
SWBuf & | replaceBytes (const char *targets, char newByte) | |||
bool | startsWith (const SWBuf &prefix) const | |||
bool | endsWith (const SWBuf &postfix) const | |||
int | compare (const SWBuf &other) const | |||
bool | operator== (const SWBuf &other) const | |||
bool | operator!= (const SWBuf &other) const | |||
bool | operator> (const SWBuf &other) const | |||
bool | operator< (const SWBuf &other) const | |||
bool | operator<= (const SWBuf &other) const | |||
bool | operator>= (const SWBuf &other) const | |||
bool | startsWith (const char *prefix) const | |||
bool | endsWith (const char *postfix) const | |||
int | compare (const char *other) const | |||
bool | operator== (const char *other) const | |||
bool | operator!= (const char *other) const | |||
bool | operator> (const char *other) const | |||
bool | operator< (const char *other) const | |||
bool | operator<= (const char *other) const | |||
bool | operator>= (const char *other) const | |||
Private Member Functions | ||||
void | assureMore (size_t pastEnd) | |||
void | assureSize (size_t checkSize) | |||
void | init (size_t initSize) | |||
Private Attributes | ||||
char * | buf | |||
char * | end | |||
char * | endAlloc | |||
char | fillByte | |||
unsigned long | allocSize | |||
Static Private Attributes | ||||
static char * | nullStr | |||
static char | junkBuf [8191] |
Definition at line 44 of file swbuf.h.
void sword::SWBuf::setFillByte | ( | char | ch | ) | [inline] |
char sword::SWBuf::getFillByte | ( | ) | [inline] |
SWBuf::getFillByte - Get the fillByte character.
char& sword::SWBuf::charAt | ( | unsigned long | pos | ) | [inline] |
unsigned long sword::SWBuf::size | ( | ) | const [inline] |
Add one for the following null and one for each char to be appended!
Definition at line 152 of file swbuf.h.
Referenced by endsWith(), and startsWith().
void sword::SWBuf::size | ( | unsigned long | newSize | ) | [inline] |
void sword::SWBuf::set | ( | const SWBuf & | newVal | ) | [inline] |
SWBuf::set - sets this buf to a new value If the allocated memory is bigger than the new string, it will NOT be resized.
newVal | the value to set this buffer to. |
void sword::SWBuf::set | ( | const char * | newVal | ) | [inline] |
SWBuf::set - sets this buf to a new value.
If the allocated memory is bigger than the new string, it will NOT be resized.
newVal | the value to set this buffer to. |
void sword::SWBuf::setFormatted | ( | const char * | format, | |
... | ||||
) |
SWBuf::setFormatted - sets this buf to a formatted string.
If the allocated memory is bigger than the new string, it will NOT be resized.
This function is not very fast. For loops with many iterations you might consider replacing it by other calls. Example:
should be replaced by: This will produce much faster results.format | The format string. Same syntax as printf, for example. | |
... | Add all arguments here. |
void sword::SWBuf::setSize | ( | unsigned long | len | ) |
SWBuf::setSize - Size this buffer to a specific length.
len | The new size of the buffer. One byte for the null will be added. |
void sword::SWBuf::resize | ( | unsigned long | len | ) | [inline] |
SWBuf::resize - Resize this buffer to a specific length.
len | The new size of the buffer. One byte for the null will be added. |
void sword::SWBuf::append | ( | const char * | str, | |
long | max = -1 | |||
) |
SWBuf::append - appends a value to the current value of this SWBuf.
If the allocated memory is not enough, it will be resized accordingly.
str | Append this. | |
max | Append only max chars. |
void sword::SWBuf::append | ( | const SWBuf & | str, | |
long | max = -1 | |||
) | [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.
str | Append this. | |
max | Append only max chars. |
Definition at line 243 of file swbuf.h.
References c_str().
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.
ch | Append this. |
void sword::SWBuf::appendFormatted | ( | const char * | format, | |
... | ||||
) |
SWBuf::appendFormatted - appends formatted strings to the current value of this SWBuf.
This function is not very fast. For loops with many iterations you might consider replacing it by other calls. Example:
should be replaced by: This will produce much faster results.format | The format string. Same syntax as printf, for example. | |
... | Add all arguments here. |
void sword::SWBuf::insert | ( | unsigned long | pos, | |
const char * | str, | |||
unsigned long | start = 0 , |
|||
signed long | max = -1 | |||
) |
SWBuf::insert - inserts the given string at position into this string.
pos | The position where to insert. pos=0 inserts at the beginning, pos=1 after the first char, etc. Using pos=length() is the same as calling append(s) | |
str | string to be inserted | |
start | start from this position in the string to be inserted | |
max | Insert only max chars. |
void sword::SWBuf::insert | ( | unsigned long | pos, | |
const SWBuf & | str, | |||
unsigned long | start = 0 , |
|||
signed long | max = -1 | |||
) | [inline] |
SWBuf::insert - inserts the given string at position into this string.
pos | The position where to insert. pos=0 inserts at the beginning, pos=1 after the first char, etc. Using pos=length() is the same as calling append(s) | |
str | string to be inserted | |
start | start from this position in the string to be inserted | |
max | Insert only max chars. |
Definition at line 290 of file swbuf.h.
References c_str().
void sword::SWBuf::insert | ( | unsigned long | pos, | |
char | c | |||
) | [inline] |
SWBuf::insert - inserts the given character at position into this string.
pos | The position where to insert. pos=0 inserts at the beginning, pos=1 after the first char, etc. Using pos=length() is the same as calling append(s) | |
c | Insert this. |
char* sword::SWBuf::getRawData | ( | ) | [inline] |
The SWORD Project; P. O. Box 2528; Tempe, AZ 85280-2528 USA |