![]() |
Public API Reference |
![]() |
This is a string class with a range of useful operators and type-safe overloads. More...
#include <csutil/csstring.h>
Public Member Functions | |
csStringBase & | Append (const char *Str, size_t Count=(size_t)-1) |
Append a null-terminated C-string to this one. | |
csStringBase & | Append (const wchar_t *Str, size_t Count=(size_t)-1) |
Append a null-terminated wide string to this one. | |
csStringBase & | Append (const csStringBase &Str, size_t Count=(size_t)-1) |
Append a string to this one. | |
csStringBase & | Append (char c) |
Append a signed character to this string. | |
csStringBase & | Append (bool b) |
Append an unsigned character to this string. | |
csStringBase & | Clear () |
Clear the string (so that it contains only a null terminator). | |
csStringBase | Clone () const |
Get a copy of this string. | |
csStringBase & | Collapse () |
Trim leading and trailing whitespace, and collapse all internal whitespace to a single space. | |
bool | Compare (const csStringBase &iStr) const |
Check if another string is equal to this one. | |
bool | Compare (const char *iStr) const |
Check if a null-terminated C- string is equal to this string. | |
bool | CompareNoCase (const csStringBase &iStr) const |
Check if another string is equal to this one. | |
bool | CompareNoCase (const char *iStr) const |
Check if a null-terminated C- string is equal to this string. | |
csStringBase () | |
Create an empty csStringBase object. | |
csStringBase (size_t Length) | |
Create a csStringBase object and reserve space for at least Length characters. | |
csStringBase (const csStringBase ©) | |
Copy constructor. | |
csStringBase (const char *src) | |
Create a csStringBase object from a null-terminated C string. | |
csStringBase (const wchar_t *src) | |
Create a csStringBase object from a null-terminated wide string. | |
csStringBase (const char *src, size_t _length) | |
Create a csStringBase object from a C string, given the length. | |
csStringBase (const wchar_t *src, size_t _length) | |
Create a csStringBase object from a wide string, given the length. | |
csStringBase (char c) | |
Create a csStringBase object from a single signed character. | |
csStringBase (unsigned char c) | |
Create a csStringBase object from a single unsigned character. | |
csStringBase & | DeleteAt (size_t Pos, size_t Count=1) |
Delete a range of characters from the string. | |
virtual char * | Detach () |
Detach the low-level null-terminated C-string buffer from the csString object. | |
csStringBase & | Downcase (uint flags=csUcMapSimple) |
Convert this string to lower-case. | |
csStringBase & | Empty () |
Clear the string (so that it contains only a null terminator). | |
size_t | Find (const char *search, size_t pos=0) const |
Find the first occurrence of search in this string starting at pos . | |
size_t | FindFirst (char c, size_t pos=0) const |
Find the first occurrence of a character in the string. | |
size_t | FindFirst (const char *c, size_t pos=0) const |
Find the first occurrence of any of a set of characters in the string. | |
size_t | FindLast (char c, size_t pos=(size_t)-1) const |
Find the last occurrence of a character in the string. | |
size_t | FindLast (const char *c, size_t pos=(size_t)-1) const |
Find the last occurrence of any of a set of characters in the string. | |
void | FindReplace (const char *search, const char *replacement) |
Find all occurrences of search in this string and replace them with replacement . | |
size_t | FindStr (const char *search, size_t pos=0) const |
Find the first occurrence of search in this string starting at pos . | |
csStringBase & | Format (const char *format,...) |
Format this string using cs_snprintf()-style formatting directives. | |
csStringBase & | FormatV (const char *format, va_list args) |
Format this string using cs_snprintf() formatting directives in a va_list. | |
virtual void | Free () |
Free the memory allocated for the string. | |
char | GetAt (size_t n) const |
Get the n'th character. | |
virtual size_t | GetCapacity () const |
Return the current capacity, not including the space for the implicit null terminator. | |
virtual CS_VISIBILITY_DEFAULT char const * | GetData () const |
Get a pointer to the null-terminated character array. | |
char const * | GetDataSafe () const |
Get a pointer to the null-terminated character array. | |
size_t | GetGrowsBy () const |
Return the number of bytes by which the string grows. | |
uint | GetHash () const |
GetHash() as expected by the default csHashComputer<> implementation to allow use of csStrings as hash keys. | |
csStringBase & | Insert (size_t Pos, const csStringBase &Str) |
Insert another string into this one. | |
csStringBase & | Insert (size_t Pos, const char *Str) |
Insert another string into this one. | |
csStringBase & | Insert (size_t Pos, char C) |
Insert another string into this one. | |
bool | IsEmpty () const |
Check if string is empty. | |
size_t | Length () const |
Query string length. | |
csStringBase & | LTrim () |
Trim leading whitespace. | |
operator const char * () const | |
Get a pointer to the null-terminated character array. | |
bool | operator!= (const csStringBase &Str) const |
Check if another string is not equal to this one. | |
bool | operator!= (const char *Str) const |
Check if another string is not equal to this one. | |
csStringBase | operator+ (const csStringBase &iStr) const |
Add another string to this one and return the result as a new string. | |
template<typename T > | |
csStringBase & | operator+= (T const &s) |
Append a formatted value to this string. | |
bool | operator< (const csStringBase &Str) const |
Check if another string is less than this one. | |
bool | operator< (const char *Str) const |
Check if another string is less than this one. | |
template<typename T > | |
csStringBase & | operator<< (T const &v) |
Shift operator. | |
template<typename T > | |
const csStringBase & | operator= (T const &s) |
Assign a formatted value to this string. | |
const csStringBase & | operator= (const csStringBase ©) |
Assign another string to this one. | |
bool | operator== (const csStringBase &Str) const |
Check if another string is equal to this one. | |
bool | operator== (const char *Str) const |
Check if another string is equal to this one. | |
bool | operator> (const csStringBase &Str) const |
Check to see if a string is greater than this one. | |
bool | operator> (const char *Str) const |
Check to see if a string is greater than this one. | |
char & | operator[] (size_t n) |
Get a modifiable reference to n'th character. | |
char | operator[] (size_t n) const |
Get n'th character. | |
csStringBase & | Overwrite (size_t Pos, const csStringBase &Str) |
Overlay another string onto a part of this string. | |
csStringBase & | PadCenter (size_t NewSize, char PadChar= ' ') |
Pad to a specified size with leading and trailing characters so as to center the string. | |
csStringBase & | PadLeft (size_t NewSize, char PadChar= ' ') |
Pad to a specified size with leading characters. | |
csStringBase & | PadRight (size_t NewSize, char PadChar= ' ') |
Pad to a specified size with trailing characters. | |
csStringBase & | Reclaim () |
Set string buffer capacity to hold exactly the current content. | |
csStringBase & | Replace (const csStringBase &Str, size_t Count=(size_t)-1) |
Replace contents of this string with the contents of another. | |
csStringBase & | Replace (const char *Str, size_t Count=(size_t)-1) |
Replace contents of this string with the contents of another. | |
template<typename T > | |
csStringBase & | Replace (T const &val) |
Replace contents of this string with the value in formatted form. | |
csStringBase & | ReplaceAll (const char *search, const char *replacement) |
Find all occurrences of search in this string and replace them with replacement . | |
csStringBase & | RTrim () |
Trim trailing whitespace. | |
void | SetAt (size_t n, const char c) |
Set the n'th character. | |
void | SetCapacity (size_t NewSize) |
Ask the string to allocate enough space to hold NewSize characters. | |
void | SetGrowsBy (size_t) |
Advise the string that it should grow its allocated buffer by approximately this many bytes when more space is required. | |
virtual void | ShrinkBestFit () |
Set string buffer capacity to hold exactly the current content. | |
csStringBase | Slice (size_t start, size_t len=(size_t)-1) const |
Copy and return a portion of this string. | |
bool | StartsWith (const csStringBase &iStr, bool ignore_case=false) const |
Check if this string starts with another one. | |
bool | StartsWith (const char *iStr, bool ignore_case=false) const |
Check if this string starts with a null-terminated C- string. | |
void | SubString (csStringBase &sub, size_t start, size_t len=(size_t)-1) const |
Copy a portion of this string. | |
csStringBase & | Trim () |
Trim leading and trailing whitespace. | |
csStringBase & | Truncate (size_t Len) |
Truncate the string. | |
csStringBase & | Upcase (uint flags=csUcMapSimple) |
Convert this string to upper-case. | |
virtual | ~csStringBase () |
Destroy the csStringBase. | |
csStringBase & | AppendFmt (const char *format,...) |
Append a string formatted using cs_snprintf()-style formatting directives. | |
csStringBase & | AppendFmtV (const char *format, va_list args) |
Append a string formatted using cs_snprintf()-style formatting directives. | |
csStringBase & | Append (short v) |
Append the value, in formatted form, to this string. | |
csStringBase & | Append (unsigned short v) |
Append the value, in formatted form, to this string. | |
csStringBase & | Append (int v) |
Append the value, in formatted form, to this string. | |
csStringBase & | Append (unsigned int v) |
Append the value, in formatted form, to this string. | |
csStringBase & | Append (long v) |
Append the value, in formatted form, to this string. | |
csStringBase & | Append (unsigned long v) |
Append the value, in formatted form, to this string. | |
csStringBase & | Append (float v) |
Append the value, in formatted form, to this string. | |
csStringBase & | Append (double v) |
Append the value, in formatted form, to this string. | |
csStringBase & | Append (longlong v) |
Append the value, in formatted form, to this string. | |
csStringBase & | Append (ulonglong v) |
Append the value, in formatted form, to this string. | |
Protected Types | |
enum | |
Default number of bytes by which allocation should grow. More... | |
Protected Member Functions | |
size_t | ComputeNewSize (size_t NewSize) |
Compute a new buffer size. Takes GrowBy into consideration. | |
void | ExpandIfNeeded (size_t NewSize) |
If necessary, increase the buffer capacity enough to hold NewSize bytes. | |
virtual char * | GetDataMutable () |
Get a pointer to the null-terminated character array. | |
virtual void | SetCapacityInternal (size_t NewSize, bool soft) |
Set the buffer to hold NewSize bytes. | |
Protected Attributes | |
char * | Data |
String buffer. | |
size_t | GrowBy |
Size in bytes by which allocated buffer is increased when needed. | |
size_t | MaxSize |
Size in bytes of allocated string buffer. | |
size_t | Size |
Length of string; not including null terminator. |
This is a string class with a range of useful operators and type-safe overloads.
Strings may contain arbitary binary data, including null bytes. It also guarantees that a null-terminator always follows the last stored character, thus you can safely use the return value from GetData() and `operator char const*()' in calls to functions expecting C strings. The implicit null terminator is not included in the character count returned by Length().
Like a typical C character string pointer, csStringBase can also represent a null pointer. This allows a non-string to be distinguished from an empty (zero-length) string. The csStringBase will represent a null-pointer in the following cases:
Definition at line 52 of file csstring.h.
anonymous enum [protected] |
Default number of bytes by which allocation should grow.
*** IMPORTANT *** This must be a power of two (i.e. 8, 16, 32, 64, etc.).
Definition at line 59 of file csstring.h.
csStringBase::csStringBase | ( | ) | [inline] |
Create an empty csStringBase object.
Definition at line 193 of file csstring.h.
csStringBase::csStringBase | ( | size_t | Length | ) | [inline] |
Create a csStringBase object and reserve space for at least Length
characters.
Definition at line 202 of file csstring.h.
csStringBase::csStringBase | ( | const csStringBase & | copy | ) | [inline] |
Copy constructor.
Definition at line 211 of file csstring.h.
csStringBase::csStringBase | ( | const char * | src | ) | [inline] |
Create a csStringBase object from a null-terminated C string.
Definition at line 220 of file csstring.h.
csStringBase::csStringBase | ( | const wchar_t * | src | ) | [inline] |
Create a csStringBase object from a null-terminated wide string.
Definition at line 230 of file csstring.h.
csStringBase::csStringBase | ( | const char * | src, |
size_t | _length | ||
) | [inline] |
Create a csStringBase object from a C string, given the length.
Definition at line 239 of file csstring.h.
csStringBase::csStringBase | ( | const wchar_t * | src, |
size_t | _length | ||
) | [inline] |
Create a csStringBase object from a wide string, given the length.
Definition at line 249 of file csstring.h.
csStringBase::csStringBase | ( | char | c | ) | [inline] |
Create a csStringBase object from a single signed character.
Definition at line 254 of file csstring.h.
csStringBase::csStringBase | ( | unsigned char | c | ) | [inline] |
Create a csStringBase object from a single unsigned character.
Definition at line 259 of file csstring.h.
virtual csStringBase::~csStringBase | ( | ) | [virtual] |
Destroy the csStringBase.
csStringBase& csStringBase::Append | ( | const char * | Str, |
size_t | Count = (size_t)-1 |
||
) |
Append a null-terminated C-string to this one.
Str | String which will be appended. |
Count | Number of characters from Str to append; if -1 (the default), then all characters from Str will be appended. |
csStringBase& csStringBase::Append | ( | const wchar_t * | Str, |
size_t | Count = (size_t)-1 |
||
) |
Append a null-terminated wide string to this one.
Str | String which will be appended. |
Count | Number of characters from Str to append; if -1 (the default), then all characters from Str will be appended. |
csStringBase& csStringBase::Append | ( | const csStringBase & | Str, |
size_t | Count = (size_t)-1 |
||
) |
Append a string to this one.
Str | String which will be appended. |
Count | Number of characters from Str to append; if -1 (the default), then all characters from Str will be appended. |
csStringBase& csStringBase::Append | ( | char | c | ) |
Append a signed character to this string.
csStringBase& csStringBase::Append | ( | bool | b | ) | [inline] |
Append an unsigned character to this string.
Definition at line 162 of file csstring.h.
csStringBase& csStringBase::Append | ( | short | v | ) | [inline] |
Append the value, in formatted form, to this string.
Definition at line 175 of file csstring.h.
csStringBase& csStringBase::Append | ( | unsigned short | v | ) | [inline] |
Append the value, in formatted form, to this string.
Definition at line 176 of file csstring.h.
csStringBase& csStringBase::Append | ( | int | v | ) | [inline] |
Append the value, in formatted form, to this string.
Definition at line 177 of file csstring.h.
csStringBase& csStringBase::Append | ( | unsigned int | v | ) | [inline] |
Append the value, in formatted form, to this string.
Definition at line 178 of file csstring.h.
csStringBase& csStringBase::Append | ( | long | v | ) | [inline] |
Append the value, in formatted form, to this string.
Definition at line 179 of file csstring.h.
csStringBase& csStringBase::Append | ( | unsigned long | v | ) | [inline] |
Append the value, in formatted form, to this string.
Definition at line 180 of file csstring.h.
csStringBase& csStringBase::Append | ( | float | v | ) | [inline] |
Append the value, in formatted form, to this string.
Definition at line 181 of file csstring.h.
csStringBase& csStringBase::Append | ( | double | v | ) | [inline] |
Append the value, in formatted form, to this string.
Definition at line 182 of file csstring.h.
csStringBase& csStringBase::Append | ( | longlong | v | ) | [inline] |
Append the value, in formatted form, to this string.
Definition at line 184 of file csstring.h.
csStringBase& csStringBase::Append | ( | ulonglong | v | ) | [inline] |
Append the value, in formatted form, to this string.
Definition at line 185 of file csstring.h.
csStringBase& csStringBase::AppendFmt | ( | const char * | format, |
... | |||
) |
Append a string formatted using cs_snprintf()-style formatting directives.
csStringBase& csStringBase::AppendFmtV | ( | const char * | format, |
va_list | args | ||
) |
Append a string formatted using cs_snprintf()-style formatting directives.
csStringBase& csStringBase::Clear | ( | ) | [inline] |
Clear the string (so that it contains only a null terminator).
Definition at line 349 of file csstring.h.
csStringBase csStringBase::Clone | ( | ) | const [inline] |
Get a copy of this string.
Definition at line 707 of file csstring.h.
Trim leading and trailing whitespace, and collapse all internal whitespace to a single space.
bool csStringBase::Compare | ( | const csStringBase & | iStr | ) | const [inline] |
Check if another string is equal to this one.
iStr | Other string. |
Definition at line 608 of file csstring.h.
bool csStringBase::Compare | ( | const char * | iStr | ) | const [inline] |
Check if a null-terminated C- string is equal to this string.
iStr | Other string. |
Definition at line 626 of file csstring.h.
bool csStringBase::CompareNoCase | ( | const csStringBase & | iStr | ) | const [inline] |
Check if another string is equal to this one.
iStr | Other string. |
Definition at line 635 of file csstring.h.
bool csStringBase::CompareNoCase | ( | const char * | iStr | ) | const [inline] |
Check if a null-terminated C- string is equal to this string.
iStr | Other string. |
Definition at line 653 of file csstring.h.
size_t csStringBase::ComputeNewSize | ( | size_t | NewSize | ) | [protected] |
Compute a new buffer size. Takes GrowBy into consideration.
csStringBase& csStringBase::DeleteAt | ( | size_t | Pos, |
size_t | Count = 1 |
||
) |
Delete a range of characters from the string.
Pos | Beginning of range to be deleted (zero-based). |
Count | Number of characters to delete. |
virtual char* csStringBase::Detach | ( | ) | [inline, virtual] |
Detach the low-level null-terminated C-string buffer from the csString object.
Reimplemented in csStringFast< LEN >.
Definition at line 932 of file csstring.h.
csStringBase& csStringBase::Downcase | ( | uint | flags = csUcMapSimple | ) |
Convert this string to lower-case.
flags | Mapping options. Same as the flags parameter to csUnicodeTransform::MapToLower(). |
csStringBase& csStringBase::Empty | ( | ) | [inline] |
Clear the string (so that it contains only a null terminator).
Definition at line 319 of file csstring.h.
void csStringBase::ExpandIfNeeded | ( | size_t | NewSize | ) | [protected] |
If necessary, increase the buffer capacity enough to hold NewSize
bytes.
Buffer capacity is increased in GrowBy increments or exponentially depending upon configuration.
size_t csStringBase::Find | ( | const char * | search, |
size_t | pos = 0 |
||
) | const |
Find the first occurrence of search
in this string starting at pos
.
search | String to locate. |
pos | Start position of search (default 0). |
search
, or (size_t)-1 if not found. size_t csStringBase::FindFirst | ( | char | c, |
size_t | pos = 0 |
||
) | const |
Find the first occurrence of a character in the string.
c | Character to locate. |
pos | Start position of search (default 0). |
size_t csStringBase::FindFirst | ( | const char * | c, |
size_t | pos = 0 |
||
) | const |
Find the first occurrence of any of a set of characters in the string.
c | Characters to locate. |
pos | Start position of search (default 0). |
size_t csStringBase::FindLast | ( | char | c, |
size_t | pos = (size_t)-1 |
||
) | const |
Find the last occurrence of a character in the string.
c | Character to locate. |
pos | Start position of reverse search. Specify (size_t)-1 if you want the search to begin at the very end of string. |
size_t csStringBase::FindLast | ( | const char * | c, |
size_t | pos = (size_t)-1 |
||
) | const |
Find the last occurrence of any of a set of characters in the string.
c | Characters to locate. |
pos | Start position of reverse search. Specify (size_t)-1 if you want the search to begin at the very end of string. |
void csStringBase::FindReplace | ( | const char * | search, |
const char * | replacement | ||
) | [inline] |
Find all occurrences of search
in this string and replace them with replacement
.
Definition at line 552 of file csstring.h.
size_t csStringBase::FindStr | ( | const char * | search, |
size_t | pos = 0 |
||
) | const [inline] |
Find the first occurrence of search
in this string starting at pos
.
search | String to locate. |
pos | Start position of search (default 0). |
search
, or (size_t)-1 if not found. Definition at line 536 of file csstring.h.
csStringBase& csStringBase::Format | ( | const char * | format, |
... | |||
) |
Format this string using cs_snprintf()-style formatting directives.
csStringBase& csStringBase::FormatV | ( | const char * | format, |
va_list | args | ||
) |
Format this string using cs_snprintf() formatting directives in a va_list.
virtual void csStringBase::Free | ( | ) | [virtual] |
Free the memory allocated for the string.
Reimplemented in csStringFast< LEN >.
char csStringBase::GetAt | ( | size_t | n | ) | const [inline] |
Get the n'th character.
Definition at line 417 of file csstring.h.
virtual size_t csStringBase::GetCapacity | ( | ) | const [inline, virtual] |
Return the current capacity, not including the space for the implicit null terminator.
Reimplemented in csStringFast< LEN >.
Definition at line 117 of file csstring.h.
virtual CS_VISIBILITY_DEFAULT char const* csStringBase::GetData | ( | ) | const [inline, virtual] |
Get a pointer to the null-terminated character array.
Reimplemented in csStringFast< LEN >.
Definition at line 359 of file csstring.h.
virtual char* csStringBase::GetDataMutable | ( | ) | [inline, protected, virtual] |
Get a pointer to the null-terminated character array.
Reimplemented in csStringFast< LEN >.
Definition at line 100 of file csstring.h.
char const* csStringBase::GetDataSafe | ( | ) | const [inline] |
Get a pointer to the null-terminated character array.
Definition at line 371 of file csstring.h.
size_t csStringBase::GetGrowsBy | ( | ) | const [inline] |
Return the number of bytes by which the string grows.
Definition at line 285 of file csstring.h.
uint csStringBase::GetHash | ( | ) | const |
GetHash() as expected by the default csHashComputer<> implementation to allow use of csStrings as hash keys.
csStringBase& csStringBase::Insert | ( | size_t | Pos, |
const csStringBase & | Str | ||
) |
Insert another string into this one.
Pos | Position at which to insert the other string (zero-based). |
Str | String to insert. |
csStringBase& csStringBase::Insert | ( | size_t | Pos, |
const char * | Str | ||
) |
Insert another string into this one.
Pos | Position at which to insert the other string (zero-based). |
Str | String to insert. |
csStringBase& csStringBase::Insert | ( | size_t | Pos, |
char | C | ||
) |
Insert another string into this one.
Pos | Position at which to insert the other string (zero-based). |
C | Character to insert. |
bool csStringBase::IsEmpty | ( | ) | const [inline] |
Check if string is empty.
Definition at line 387 of file csstring.h.
size_t csStringBase::Length | ( | ) | const [inline] |
Query string length.
Definition at line 379 of file csstring.h.
Trim leading whitespace.
csStringBase::operator const char * | ( | ) | const [inline] |
Get a pointer to the null-terminated character array.
Definition at line 807 of file csstring.h.
bool csStringBase::operator!= | ( | const csStringBase & | Str | ) | const [inline] |
Check if another string is not equal to this one.
Str | Other string. |
Definition at line 872 of file csstring.h.
bool csStringBase::operator!= | ( | const char * | Str | ) | const [inline] |
Check if another string is not equal to this one.
Str | Other string. |
Definition at line 880 of file csstring.h.
csStringBase csStringBase::operator+ | ( | const csStringBase & | iStr | ) | const [inline] |
Add another string to this one and return the result as a new string.
Definition at line 797 of file csstring.h.
csStringBase& csStringBase::operator+= | ( | T const & | s | ) | [inline] |
Append a formatted value to this string.
Definition at line 789 of file csstring.h.
bool csStringBase::operator< | ( | const csStringBase & | Str | ) | const [inline] |
Check if another string is less than this one.
Str | Other string. |
Definition at line 832 of file csstring.h.
bool csStringBase::operator< | ( | const char * | Str | ) | const [inline] |
Check if another string is less than this one.
Str | Other string. |
Definition at line 842 of file csstring.h.
csStringBase& csStringBase::operator<< | ( | T const & | v | ) | [inline] |
Shift operator.
For example:
s << "Hi " << name << ", see " << foo;
Definition at line 891 of file csstring.h.
const csStringBase& csStringBase::operator= | ( | T const & | s | ) | [inline] |
Assign a formatted value to this string.
Reimplemented in csStringFast< LEN >.
Definition at line 779 of file csstring.h.
const csStringBase& csStringBase::operator= | ( | const csStringBase & | copy | ) | [inline] |
Assign another string to this one.
Reimplemented in csString, and csStringFast< LEN >.
Definition at line 782 of file csstring.h.
bool csStringBase::operator== | ( | const csStringBase & | Str | ) | const [inline] |
Check if another string is equal to this one.
Str | Other string. |
Definition at line 816 of file csstring.h.
bool csStringBase::operator== | ( | const char * | Str | ) | const [inline] |
Check if another string is equal to this one.
Str | Other string. |
Definition at line 824 of file csstring.h.
bool csStringBase::operator> | ( | const csStringBase & | Str | ) | const [inline] |
Check to see if a string is greater than this one.
Str | Other string. |
Definition at line 852 of file csstring.h.
bool csStringBase::operator> | ( | const char * | Str | ) | const [inline] |
Check to see if a string is greater than this one.
Str | Other string. |
Definition at line 862 of file csstring.h.
char& csStringBase::operator[] | ( | size_t | n | ) | [inline] |
Get a modifiable reference to n'th character.
Definition at line 391 of file csstring.h.
char csStringBase::operator[] | ( | size_t | n | ) | const [inline] |
Get n'th character.
Definition at line 398 of file csstring.h.
csStringBase& csStringBase::Overwrite | ( | size_t | Pos, |
const csStringBase & | Str | ||
) |
Overlay another string onto a part of this string.
Pos | Position at which to insert the other string (zero-based). |
Str | String which will be overlayed atop this string. |
csStringBase& csStringBase::PadCenter | ( | size_t | NewSize, |
char | PadChar = ' ' |
||
) |
Pad to a specified size with leading and trailing characters so as to center the string.
NewSize | Size to which the string should grow. |
PadChar | Character with which to pad the string (default is space). |
csStringBase& csStringBase::PadLeft | ( | size_t | NewSize, |
char | PadChar = ' ' |
||
) |
Pad to a specified size with leading characters.
NewSize | Size to which the string should grow. |
PadChar | Character with which to pad the string (default is space). |
csStringBase& csStringBase::PadRight | ( | size_t | NewSize, |
char | PadChar = ' ' |
||
) |
Pad to a specified size with trailing characters.
NewSize | Size to which the string should grow. |
PadChar | Character with which to pad the string (default is space). |
csStringBase& csStringBase::Reclaim | ( | ) | [inline] |
Set string buffer capacity to hold exactly the current content.
Definition at line 341 of file csstring.h.
csStringBase& csStringBase::Replace | ( | const csStringBase & | Str, |
size_t | Count = (size_t)-1 |
||
) |
Replace contents of this string with the contents of another.
Str | String from which new content of this string will be copied. |
Count | Number of characters to copy. If (size_t)-1 is specified, then all characters will be copied. |
csStringBase& csStringBase::Replace | ( | const char * | Str, |
size_t | Count = (size_t)-1 |
||
) |
Replace contents of this string with the contents of another.
Str | String from which new content of this string will be copied. |
Count | Number of characters to copy. If (size_t)-1 is specified, then all characters will be copied. |
csStringBase& csStringBase::Replace | ( | T const & | val | ) | [inline] |
Replace contents of this string with the value in formatted form.
Definition at line 600 of file csstring.h.
csStringBase& csStringBase::ReplaceAll | ( | const char * | search, |
const char * | replacement | ||
) |
Find all occurrences of search
in this string and replace them with replacement
.
Trim trailing whitespace.
void csStringBase::SetAt | ( | size_t | n, |
const char | c | ||
) | [inline] |
Set the n'th character.
Definition at line 410 of file csstring.h.
void csStringBase::SetCapacity | ( | size_t | NewSize | ) |
Ask the string to allocate enough space to hold NewSize
characters.
NewSize
+ 1 (one for the implicit null terminator). Never shrinks capacity. If you need to actually reclaim memory, then use Free() or ShrinkBestFit(). virtual void csStringBase::SetCapacityInternal | ( | size_t | NewSize, |
bool | soft | ||
) | [protected, virtual] |
Set the buffer to hold NewSize bytes.
If soft is true it means the buffer can be rounded up to reduce the number of allocations needed.
Reimplemented in csStringFast< LEN >.
void csStringBase::SetGrowsBy | ( | size_t | ) |
Advise the string that it should grow its allocated buffer by approximately this many bytes when more space is required.
This is an optimization to avoid excessive memory reallocation and heap management, which can be quite slow.
virtual void csStringBase::ShrinkBestFit | ( | ) | [virtual] |
Set string buffer capacity to hold exactly the current content.
Reimplemented in csStringFast< LEN >.
csStringBase csStringBase::Slice | ( | size_t | start, |
size_t | len = (size_t)-1 |
||
) | const |
Copy and return a portion of this string.
start | Start position of slice (zero-based). |
len | Number of characters in slice. |
bool csStringBase::StartsWith | ( | const csStringBase & | iStr, |
bool | ignore_case = false |
||
) | const [inline] |
Check if this string starts with another one.
iStr | Other string. |
ignore_case | Causes the comparison to be case insensitive if true. |
Definition at line 662 of file csstring.h.
bool csStringBase::StartsWith | ( | const char * | iStr, |
bool | ignore_case = false |
||
) | const [inline] |
Check if this string starts with a null-terminated C- string.
iStr | Other string. |
ignore_case | Causes the comparison to be case insensitive if true. |
Definition at line 685 of file csstring.h.
void csStringBase::SubString | ( | csStringBase & | sub, |
size_t | start, | ||
size_t | len = (size_t)-1 |
||
) | const |
Copy a portion of this string.
sub | String which will receive the indicated substring copy. |
start | Start position of slice (zero-based). |
len | Number of characters in slice. |
csStringBase& csStringBase::Truncate | ( | size_t | Len | ) |
Truncate the string.
Len | The number of characters to which the string should be truncated (possibly 0). |
csStringBase& csStringBase::Upcase | ( | uint | flags = csUcMapSimple | ) |
Convert this string to upper-case.
flags | Mapping options. Same as the flags parameter to csUnicodeTransform::MapToUpper(). |
char* csStringBase::Data [protected] |
String buffer.
Definition at line 62 of file csstring.h.
size_t csStringBase::GrowBy [protected] |
Size in bytes by which allocated buffer is increased when needed.
If this value is zero, then growth occurs exponentially by doubling the size.
Definition at line 71 of file csstring.h.
size_t csStringBase::MaxSize [protected] |
Size in bytes of allocated string buffer.
Definition at line 66 of file csstring.h.
size_t csStringBase::Size [protected] |
Length of string; not including null terminator.
Definition at line 64 of file csstring.h.