![]() |
Public API Reference |
#include <csstring.h>
Public Methods | |
void | SetCapacity (size_t NewSize) |
Advise the string that it should allocate enough space to hold up to NewSize characters. More... | |
size_t | GetCapacity () const |
Return the current capacity. More... | |
void | SetGrowsBy (size_t) |
Advise the string that it should grow by approximately this many bytes when more space is required. More... | |
size_t | GetGrowsBy () const |
Return the number of bytes by which the string grows. More... | |
void | SetGrowsExponentially (bool b) |
Tell the string to re-size its buffer exponentially as needed. More... | |
bool | GetGrowsExponentially () const |
Returns true if exponential growth is enabled. More... | |
void | Free () |
Free the memory allocated for the string. More... | |
csString & | Truncate (size_t iLen) |
Truncate the string to length iLen. More... | |
csString & | Reclaim () |
Set string buffer capacity to exactly hold the current content. More... | |
csString & | Clear () |
Clear the string (so that it contains only a null terminator). More... | |
char * | GetData () const |
Get a pointer to ASCIIZ string - warning: this is a non constpointer, so use this function with care! More... | |
size_t | Length () const |
Query string length. Length does not include null terminator. More... | |
bool | IsEmpty () const |
Check if string is empty. More... | |
char & | operator[] (size_t n) |
Get a reference to n'th character. More... | |
char | operator[] (size_t n) const |
Get n'th character. More... | |
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. More... | |
csString & | DeleteAt (size_t iPos, size_t iCount=1) |
Delete iCount characters at starting iPos. More... | |
csString & | Insert (size_t iPos, const csString &) |
Insert another string into this one at position iPos. More... | |
csString & | Insert (size_t iPos, const char) |
Insert a char into this string at position iPos. More... | |
csString & | Overwrite (size_t iPos, const csString &) |
Overlay another string onto a part of this string. More... | |
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. More... | |
csString & | Append (unsigned char c) |
Append an unsigned character to this string. More... | |
void | SubString (csString &sub, size_t start, size_t len) |
SubString another string out of this one. More... | |
size_t | FindFirst (const char c, size_t p=(size_t)-1) |
Find first character 'c' from position 'p'. More... | |
size_t | FindLast (const char c, size_t p=(size_t)-1) |
Find first character 'c', counting backwards from position 'p'. More... | |
csString & | Append (bool b) |
Append a boolean (as a number -- 1 or 0) to this string. More... | |
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... | |
bool | Compare (const csString &iStr) const |
Check if two strings are equal. More... | |
bool | Compare (const char *iStr) const |
Check if an ASCIIZ string is equal to this string. More... | |
bool | CompareNoCase (const csString &iStr) const |
Compare two strings ignoring case. More... | |
bool | CompareNoCase (const char *iStr) const |
Compare ignoring case with an ASCIIZ string. More... | |
csString () | |
Create an empty csString object. More... | |
csString (size_t iLength) | |
Create an csString object and reserve space for iLength characters. More... | |
csString (const csString ©) | |
Copy constructor from existing csString. More... | |
csString (const char *copy) | |
Copy constructor from ASCIIZ string. More... | |
csString (char c) | |
Copy constructor from a character. More... | |
csString (unsigned char c) | |
Copy constructor from a character (unsigned). More... | |
virtual | ~csString () |
Destroy a csString object. More... | |
csString | Clone () const |
Get a copy of this string. More... | |
csString & | LTrim () |
Trim leading whitespace. More... | |
csString & | RTrim () |
Trim trailing whitespace. More... | |
csString & | Trim () |
Trim leading and trailing whitespace. More... | |
csString & | Collapse () |
Trims leading and trailing whitespace, and collapses all internal whitespace to a single space. More... | |
csString & | Format (const char *format,...) |
Format this string using sprintf() formatting directives. More... | |
csString & | FormatV (const char *format, va_list args) |
Format this string using sprintf() formatting directives in a va_list. More... | |
csString & | PadLeft (size_t iNewSize, char iChar='') |
Pad to specified size with leading characters (default: space). More... | |
csString | AsPadLeft (size_t iNewSize, char iChar='') |
Return a new string formatted with PadLeft(). More... | |
csString & | PadRight (size_t iNewSize, char iChar='') |
Pad to specified size with trailing characters (default: space). More... | |
csString | AsPadRight (size_t iNewSize, char iChar='') |
Return a new string formatted with PadRight(). More... | |
csString & | PadCenter (size_t iNewSize, char iChar='') |
Pad to specified size between characters (any remainder is appended). More... | |
csString | AsPadCenter (size_t iNewSize, char iChar='') |
Return a copy of this string formatted with PadCenter(). More... | |
const csString & | operator+ (const csString &iStr) const |
Add another string to this one and return the result as a new string. More... | |
operator const char * () const | |
Return a const reference to this string in ASCIIZ format. More... | |
bool | operator== (const csString &iStr) const |
Check if two strings are equal. More... | |
char * | Detach () |
Detach the low-level null-terminated string buffer from the csString object. More... |
Definition at line 30 of file csstring.h.
|
Create an empty csString object.
Definition at line 292 of file csstring.h. Referenced by Clone. |
|
Create an csString object and reserve space for iLength characters.
Definition at line 296 of file csstring.h. References SetCapacity. |
|
Copy constructor from existing csString.
Definition at line 301 of file csstring.h. References Append. |
|
Copy constructor from ASCIIZ string.
Definition at line 306 of file csstring.h. References Append. |
|
Copy constructor from a character.
Definition at line 311 of file csstring.h. References Append. |
|
Copy constructor from a character (unsigned).
Definition at line 316 of file csstring.h. References Append. |
|
Destroy a csString object.
|
|
Append a boolean (as a number -- 1 or 0) to this string.
Definition at line 215 of file csstring.h. References Append. |
|
Append an unsigned character to this string.
Definition at line 179 of file csstring.h. References Append. |
|
Append a character to this string.
Definition at line 176 of file csstring.h. References Append. |
|
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. |
|
Return a copy of this string formatted with PadCenter().
|
|
Return a new string formatted with PadLeft().
|
|
Return a new string formatted with PadRight().
|
|
Clear the string (so that it contains only a null terminator).
Definition at line 101 of file csstring.h. References Truncate. |
|
Get a copy of this string.
Definition at line 324 of file csstring.h. References csString. Referenced by operator+. |
|
Trims leading and trailing whitespace, and collapses all internal whitespace to a single space.
|
|
Check if an ASCIIZ string is equal to this string.
Definition at line 271 of file csstring.h. |
|
Check if two strings are equal.
Definition at line 258 of file csstring.h. References GetData, and Length. Referenced by operator==. |
|
Compare ignoring case with an ASCIIZ string.
Definition at line 288 of file csstring.h. |
|
Compare two strings ignoring case.
Definition at line 275 of file csstring.h. |
|
Delete iCount characters at starting iPos.
|
|
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 0 if no buffer had been allocated for this string. Definition at line 526 of file csstring.h. |
|
Find first character 'c' from position 'p'. If the character cannot be found, this function returns (size_t)-1 |
|
Find first character 'c', counting backwards from position 'p'. Default position is the end of the string. If the character cannot be found, this function returns (size_t)-1 |
|
Format this string using sprintf() formatting directives. Automatically allocates sufficient memory to hold result. Newly formatted string overwrites previous string value. |
|
Format this string using sprintf() formatting directives in a va_list. Automatically allocates sufficient memory to hold result. Newly formatted string overwrites previous string value. |
|
Free the memory allocated for the string.
|
|
Get character at n'th position.
Definition at line 144 of file csstring.h. |
|
Return the current capacity.
Definition at line 64 of file csstring.h. |
|
Get a pointer to ASCIIZ string - warning: this is a non constpointer, so use this function with care!
Definition at line 108 of file csstring.h. Referenced by Compare, and CompareNoCase. |
|
Return the number of bytes by which the string grows.
Definition at line 77 of file csstring.h. |
|
Returns true if exponential growth is enabled.
Definition at line 88 of file csstring.h. |
|
Insert a char into this string at position iPos.
|
|
Insert another string into this one at position iPos.
|
|
Check if string is empty.
Definition at line 116 of file csstring.h. |
|
Query string length. Length does not include null terminator.
Definition at line 112 of file csstring.h. Referenced by Compare, and CompareNoCase. |
|
Trim leading whitespace.
|
|
Return a const reference to this string in ASCIIZ format.
Definition at line 506 of file csstring.h. |
|
Add another string to this one and return the result as a new string.
Definition at line 502 of file csstring.h. |
|
Check if two strings are equal.
Definition at line 510 of file csstring.h. References Compare. |
|
Get n'th character.
Definition at line 127 of file csstring.h. |
|
Get a reference to n'th character.
Definition at line 120 of file csstring.h. |
|
Overlay another string onto a part of this string.
|
|
Pad to specified size between characters (any remainder is appended).
|
|
Pad to specified size with leading characters (default: space).
|
|
Pad to specified size with trailing characters (default: space).
|
|
Set string buffer capacity to exactly hold the current content.
|
|
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. Definition at line 234 of file csstring.h. References Append. |
|
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. Definition at line 223 of file csstring.h. References Append. |
|
Trim trailing whitespace.
|
|
Set character at position `n'. Does not expand string if `n' is greater than length of string. Definition at line 137 of file csstring.h. |
|
Advise the string that it should allocate enough space to hold up to NewSize characters. After calling this method, the string's capacity will be at least NewSize + 1 (one for the implicit null terminator). Never shrinks capacity. If you need to actually reclaim memory, then use Free() or Reclaim(). Referenced by csString. |
|
Advise the string that it should grow by approximately this many bytes when more space is required. This value is only a suggestion. The actual value by which it grows may be rounded up or down to an implementation-dependent allocation multiple. This method turns off exponential growth. |
|
Tell the string to re-size its buffer exponentially as needed. If set to true, the GetGrowsBy() setting is ignored. Definition at line 84 of file csstring.h. |
|
SubString another string out of this one. The result is placed in 'sub'. The substring is from 'start', of length 'len'. |
|
Trim leading and trailing whitespace.
|
|
Truncate the string to length iLen.
Referenced by Clear. |