#include <csstring.h>
Public Methods | |
void | SetCapacity (size_t NewSize) |
Set string capacity to at least NewSize characters (plus one for null terminator). More... | |
void | Free () |
Free the memory allocated for the string. | |
csString& | Truncate (size_t iLen) |
Truncate the string to length iLen. | |
csString& | Reclaim () |
Set string buffer capacity to exactly hold the current content. | |
csString& | Clear () |
Clear the string (so that it contains only a null terminator). | |
char* | GetData () const |
Get a pointer to ASCIIZ string - warning: this is a non constpointer ,so use this function with care! | |
size_t | Length () const |
Query string length. Length does not include null terminator. | |
bool | IsEmpty () const |
Check if string is empty. | |
char& | operator[] (size_t n) |
Get a reference to n'th character. | |
char | operator[] (size_t n) const |
get n'th character. | |
void | SetAt (size_t n, const char c) |
Set character at position `n'. More... | |
char | GetAt (size_t n) const |
Get character at n'th position. | |
csString& | DeleteAt (size_t iPos, size_t iCount=1) |
Delete iCount characters at starting iPos. | |
csString& | Insert (size_t iPos, const csString &) |
Insert another string into this one at position iPos. | |
csString& | Insert (size_t iPos, const char) |
Insert a char into this string at position iPos. | |
csString& | Overwrite (size_t iPos, const csString &) |
Overlay another string onto a part of this string. | |
csString& | Append (const char *, size_t iCount=(size_t)-1) |
Append an ASCIIZ string to this one. More... | |
csString& | Append (const csString &iStr, size_t iCount=(size_t)-1) |
Append a string to this one. More... | |
csString& | Append (char c) |
Append a character to this string. | |
csString& | Append (unsigned char c) |
Append an unsigned character to this string. | |
STR_APPEND (short,%hd, 32) STR_APPEND(unsigned short,%hu, 32) STR_APPEND(int,%d, 32) STR_APPEND(unsigned int,%u, 32) STR_APPEND(long,%ld, 32) STR_APPEND(unsigned long,%lu, 32) STR_APPEND(float,%g, 64) STR_APPEND(double,%g, 64) csString &Append(bool b) | |
Append a boolean (as a number -- 1 or 0) to this string. | |
csString& | Replace (const csString &iStr, size_t iCount=(size_t)-1) |
Replace contents of this string with the contents of another. More... | |
csString& | Replace (const char *iStr, size_t iCount=(size_t)-1) |
Replace contents of this string with the contents of another. More... | |
STR_REPLACE (char) STR_REPLACE(unsigned char) STR_REPLACE(short) STR_REPLACE(unsigned short) STR_REPLACE(int) STR_REPLACE(unsigned int) STR_REPLACE(long) STR_REPLACE(unsigned long) STR_REPLACE(float) STR_REPLACE(double) STR_REPLACE(bool) bool Compare(const csString &iStr) const | |
Check if two strings are equal. | |
bool | Compare (const char *iStr) const |
Check if an ASCIIZ string is equal to this string. | |
bool | CompareNoCase (const csString &iStr) const |
Compare two strings ignoring case. | |
bool | CompareNoCase (const char *iStr) const |
Compare ignoring case with an ASCIIZ string. | |
csString () | |
Create an empty csString object. | |
csString (size_t iLength) | |
Create an csString object and reserve space for iLength characters. | |
csString (const csString ©) | |
Copy constructor from existing csString. | |
csString (const char *copy) | |
Copy constructor from ASCIIZ string. | |
csString (char c) | |
Copy constructor from a character. | |
csString (unsigned char c) | |
Copy constructor from a character (unsigned). | |
virtual | ~csString () |
Destroy a csString object. | |
csString | Clone () const |
Get a copy of this string. | |
csString& | LTrim () |
Trim leading whitespace. | |
csString& | RTrim () |
Trim trailing whitespace. | |
csString& | Trim () |
Trim leading and trailing whitespace. | |
csString& | Collapse () |
Trims leading and trailing whitespace, and collapses all internal whitespace to a single space. | |
csString& | Format (const char *format,...) |
Format this string using sprintf() formatting directives. More... | |
STR_FORMAT (short,%hd, 32) STR_FORMAT(unsigned short,%hu, 32) STR_FORMAT(int,%d, 32) STR_FORMAT(unsigned int,%u, 32) STR_FORMAT(long,%ld, 32) STR_FORMAT(unsigned long,%lu, 32) STR_FORMAT(float,%g, 64) STR_FORMAT(double,%g, 64)#define STR_FORMAT_INT(TYPE, FMT) STR_FORMAT_INT(short, hd) STR_FORMAT_INT(unsigned short, hu) STR_FORMAT_INT(int, d) STR_FORMAT_INT(unsigned int, u) STR_FORMAT_INT(long, ld) STR_FORMAT_INT(unsigned long, lu)#define STR_FORMAT_FLOAT(TYPE) STR_FORMAT_FLOAT(float) STR_FORMAT_FLOAT(double) csString &PadLeft(size_t iNewSize, char iChar='') | |
Pad to specified size with leading characters (default: space). | |
csString | AsPadLeft (size_t iNewSize, char iChar='') |
Return a new string formatted with PadLeft(). | |
STR_PADLEFT (const csString &) STR_PADLEFT(const char *) STR_PADLEFT(char) STR_PADLEFT(unsigned char) STR_PADLEFT(short) STR_PADLEFT(unsigned short) STR_PADLEFT(int) STR_PADLEFT(unsigned int) STR_PADLEFT(long) STR_PADLEFT(unsigned long) STR_PADLEFT(float) STR_PADLEFT(double) STR_PADLEFT(bool) csString &PadRight(size_t iNewSize, char iChar='') | |
Pad to specified size with trailing characters (default: space). | |
csString | AsPadRight (size_t iNewSize, char iChar='') |
Return a new string formatted with PadRight(). | |
STR_PADRIGHT (const csString &) STR_PADRIGHT(const char *) STR_PADRIGHT(char) STR_PADRIGHT(unsigned char) STR_PADRIGHT(short) STR_PADRIGHT(unsigned short) STR_PADRIGHT(int) STR_PADRIGHT(unsigned int) STR_PADRIGHT(long) STR_PADRIGHT(unsigned long) STR_PADRIGHT(float) STR_PADRIGHT(double) STR_PADRIGHT(bool) csString &PadCenter(size_t iNewSize, char iChar='') | |
Pad to specified size between characters (any remainder is appended). | |
csString | AsPadCenter (size_t iNewSize, char iChar='') |
Return a copy of this string formatted with PadCenter(). | |
STR_PADCENTER (const csString &) STR_PADCENTER(const char *) STR_PADCENTER(char) STR_PADCENTER(unsigned char) STR_PADCENTER(short) STR_PADCENTER(unsigned short) STR_PADCENTER(int) STR_PADCENTER(unsigned int) STR_PADCENTER(long) STR_PADCENTER(unsigned long) STR_PADCENTER(float) STR_PADCENTER(double) STR_PADCENTER(bool)#define STR_ASSIGN(TYPE) STR_ASSIGN(const csString &) STR_ASSIGN(const char *) STR_ASSIGN(char) STR_ASSIGN(unsigned char) STR_ASSIGN(short) STR_ASSIGN(unsigned short) STR_ASSIGN(int) STR_ASSIGN(unsigned int) STR_ASSIGN(long) STR_ASSIGN(unsigned long) STR_ASSIGN(float) STR_ASSIGN(double) STR_ASSIGN(bool)#define STR_APPEND(TYPE) STR_APPEND(const csString &) STR_APPEND(const char *) STR_APPEND(char) STR_APPEND(unsigned char) STR_APPEND(short) STR_APPEND(unsigned short) STR_APPEND(int) STR_APPEND(unsigned int) STR_APPEND(long) | |
Assign a string to another. | |
STR_APPEND (unsigned long) STR_APPEND(float) STR_APPEND(double) STR_APPEND(bool) const csString &operator+(const csString &iStr) const | |
Add another string to this one and return the result as a new string. | |
operator const char * () const | |
Return a const reference to this string in ASCIIZ format. | |
bool | operator== (const csString &iStr) const |
Check if two strings are equal. | |
bool | operator== (const char *iStr) const |
bool | operator!= (const csString &iStr) const |
bool | operator!= (const char *iStr) const |
char* | Detach () |
Detach the low-level null-terminated string buffer from the csString object. More... | |
Protected Attributes | |
char* | Data |
String buffer. | |
size_t | Size |
Length of string; not including null terminator. | |
size_t | MaxSize |
Size in bytes of allocated string buffer. |
|
Append a string to this one. If iCount is -1, then the entire string is appended. Otherwise, only iCount characters from the string are appended. |
|
Append an ASCIIZ string to this one. If iCount is -1, then the entire string is appended. Otherwise, only iCount characters from the string are appended. |
|
Detach the low-level null-terminated string buffer from the csString object. The caller of this function becomes the owner of the returned string buffer and is responsible for destroying it via `delete[]' when no longer needed. The returned value may be NULL if no buffer had been allocated for this string. |
|
Format this string using sprintf() formatting directives. Automatically allocates sufficient memory to hold result. Newly formatted string overwrites previous string value. |
|
Replace contents of this string with the contents of another. If iCount is -1, then use the entire replacement string. Otherwise, use iCount characters from the replacement string. |
|
Replace contents of this string with the contents of another. If iCount is -1, then use the entire replacement string. Otherwise, use iCount characters from the replacement string. |
|
Set character at position `n'. Does not expand string if `n' is greater than length of string. |
|
Set string capacity to at least NewSize characters (plus one for null terminator). Never shrinks capacity. If you need to actually reclaim memory, then use Free() or Reclaim(). |