Public Types | |
typedef T | value_type |
typedef T * | iterator |
typedef const T * | const_iterator |
Public Member Functions | |
constexpr | BaseString () |
BaseString (const BaseString &str) | |
BaseString (BaseString &&str) | |
BaseString (const value_type *str) | |
BaseString (const value_type *str, uint32 len) | |
BaseString (const value_type *beginP, const value_type *endP) | |
bool | operator== (const BaseString &x) const |
bool | operator== (const value_type *x) const |
bool | operator!= (const BaseString &x) const |
bool | operator!= (const value_type *x) const |
bool | operator< (const BaseString &x) const |
bool | operator< (const value_type *x) const |
bool | operator<= (const BaseString &x) const |
bool | operator<= (const value_type *x) const |
bool | operator> (const BaseString &x) const |
bool | operator> (const value_type *x) const |
bool | operator>= (const BaseString &x) const |
bool | operator>= (const value_type *x) const |
bool | equals (const BaseString &x) const |
bool | equals (const value_type *x) const |
bool | equalsC (const char *x) const |
int | compareTo (const BaseString &x) const |
int | compareTo (const value_type *x) const |
int | compareToC (const char *x) const |
void | setChar (value_type c, uint32 p) |
void | deleteChar (uint32 p) |
void | deleteLastChar () |
void | erase (uint32 p, uint32 len=npos) |
iterator | erase (iterator it) |
void | chop (uint32 len=1) |
void | clear () |
iterator | begin () |
iterator | end () |
const_iterator | begin () const |
const_iterator | end () const |
const value_type * | c_str () const |
uint | size () const |
bool | empty () const |
value_type | firstChar () const |
value_type | lastChar () const |
value_type | operator[] (int idx) const |
bool | contains (const BaseString &otherString) const |
bool | contains (value_type x) const |
void | insertChar (value_type c, uint32 p) |
void | insertString (const value_type *s, uint32 p) |
void | insertString (const BaseString &s, uint32 p) |
uint32 | find (value_type x, uint32 pos=0) const |
size_t | find (const value_type *s, uint32 pos=0) const |
uint32 | find (const BaseString &str, uint32 pos=0) const |
size_t | rfind (const value_type *s) const |
size_t | rfind (const BaseString &s) const |
size_t | rfind (value_type c, size_t pos=npos) const |
size_t | findFirstOf (value_type c, size_t pos=0) const |
size_t | findFirstOf (const value_type *chars, size_t pos=0) const |
size_t | findFirstOf (const BaseString &chars, size_t pos=0) const |
size_t | findLastOf (value_type c, size_t pos=npos) const |
size_t | findLastOf (const value_type *chars, size_t pos=npos) const |
size_t | findLastOf (const BaseString &chars, size_t pos=npos) const |
size_t | findFirstNotOf (value_type c, size_t pos=0) const |
size_t | findFirstNotOf (const value_type *chars, size_t pos=0) const |
size_t | findFirstNotOf (const BaseString &chars, size_t pos=0) const |
size_t | findLastNotOf (value_type c) const |
size_t | findLastNotOf (const value_type *chars) const |
size_t | findLastNotOf (const BaseString &chars) const |
void | replace (value_type from, value_type to) |
void | append (const value_type *begin, const value_type *end) |
void | wordWrap (const uint32 maxLength) |
uint64 | asUint64 () const |
uint64 | asUint64Ext () const |
void | toLowercase () |
void | toUppercase () |
void | trim () |
uint | hash () const |
void | replace (uint32 pos, uint32 count, const BaseString &str) |
void | replace (uint32 pos, uint32 count, const value_type *str) |
void | replace (iterator begin, iterator end, const BaseString &str) |
void | replace (iterator begin, iterator end, const value_type *str) |
void | replace (uint32 posOri, uint32 countOri, const BaseString &str, uint32 posDest, uint32 countDest) |
void | replace (uint32 posOri, uint32 countOri, const value_type *str, uint32 posDest, uint32 countDest) |
Static Public Member Functions | |
static void | releaseMemoryPoolMutex () |
Static Public Attributes | |
static const uint32 | npos = 0xFFFFFFFF |
Protected Member Functions | |
bool | isStorageIntern () const |
void | makeUnique () |
void | ensureCapacity (uint32 new_size, bool keep_old) |
void | incRefCount () const |
void | decRefCount (int *oldRefCount) |
void | initWithValueTypeStr (const value_type *str, uint32 len) |
void | assignInsert (const value_type *str, uint32 p) |
void | assignInsert (value_type c, uint32 p) |
void | assignInsert (const BaseString &str, uint32 p) |
void | assignAppend (const value_type *str) |
void | assignAppend (value_type c) |
void | assignAppend (const BaseString &str) |
void | assign (const BaseString &str) |
void | assign (BaseString &&str) |
void | assign (value_type c) |
void | assign (const value_type *str) |
bool | pointerInOwnBuffer (const value_type *str) const |
uint | getUnsignedValue (uint pos) const |
void | toCase (int(*caseChangeFunc)(int)) |
Protected Attributes | |
uint32 | _size |
value_type * | _str |
union { | |
value_type _storage [_builtinCapacity] | |
struct { | |
int * _refCount | |
uint32 _capacity | |
} _extern | |
}; | |
Static Protected Attributes | |
static const uint32 | _builtinCapacity = 32 - (sizeof(uint32) + sizeof(char *)) / sizeof(value_type) |
|
inline |
Construct a new empty string.
Common::BaseString< T >::BaseString | ( | const BaseString< T > & | str | ) |
Construct a copy of the given string.
Common::BaseString< T >::BaseString | ( | BaseString< T > && | str | ) |
Construct a string by moving an existing string.
|
explicit |
Construct a new string from the given NULL-terminated C string.
Common::BaseString< T >::BaseString | ( | const value_type * | str, |
uint32 | len | ||
) |
Construct a new string containing exactly len characters read from address str.
Common::BaseString< T >::BaseString | ( | const value_type * | beginP, |
const value_type * | endP | ||
) |
Construct a new string containing the characters between beginP (including) and endP (excluding).
bool Common::BaseString< T >::equals | ( | const BaseString< T > & | x | ) | const |
Compares whether two BaseString are the same based on memory comparison. This does not do comparison based on canonical equivalence.
void Common::BaseString< T >::setChar | ( | value_type | c, |
uint32 | p | ||
) |
Set character c at position p, replacing the previous character there.
void Common::BaseString< T >::deleteChar | ( | uint32 | p | ) |
Removes the value at position p from the string. Using this on decomposed characters will not remove the whole character!
|
inline |
Remove the last character from the string.
void Common::BaseString< T >::erase | ( | uint32 | p, |
uint32 | len = npos |
||
) |
Remove all characters from position p to the p + len. If len = String::npos, removes all characters to the end
iterator Common::BaseString< T >::erase | ( | iterator | it | ) |
Erases the character at the given iterator location
void Common::BaseString< T >::chop | ( | uint32 | len = 1 | ) |
Removes characters from the end of the string
void Common::BaseString< T >::clear | ( | ) |
Clears the string, making it empty.
bool Common::BaseString< T >::contains | ( | const BaseString< T > & | otherString | ) | const |
Checks if a given string is present in the internal string or not.
void Common::BaseString< T >::insertChar | ( | value_type | c, |
uint32 | p | ||
) |
Insert character c before position p.
uint32 Common::BaseString< T >::find | ( | value_type | x, |
uint32 | pos = 0 |
||
) | const |
Finds the index of a character in the string
size_t Common::BaseString< T >::find | ( | const value_type * | s, |
uint32 | pos = 0 |
||
) | const |
Does a find for the passed string
size_t Common::BaseString< T >::rfind | ( | const value_type * | s | ) | const |
Does a reverse find for the passed string
size_t Common::BaseString< T >::rfind | ( | value_type | c, |
size_t | pos = npos |
||
) | const |
Does a reverse find for a passed character
size_t Common::BaseString< T >::findFirstOf | ( | value_type | c, |
size_t | pos = 0 |
||
) | const |
Find first character in the string matching the passed character
size_t Common::BaseString< T >::findFirstOf | ( | const value_type * | chars, |
size_t | pos = 0 |
||
) | const |
Find first character in the string that's any character of the passed string
size_t Common::BaseString< T >::findLastOf | ( | value_type | c, |
size_t | pos = npos |
||
) | const |
Find the last character in the string that's the specified character
size_t Common::BaseString< T >::findLastOf | ( | const value_type * | chars, |
size_t | pos = npos |
||
) | const |
Find the last character in the string that's in any of the passed characters
size_t Common::BaseString< T >::findFirstNotOf | ( | value_type | c, |
size_t | pos = 0 |
||
) | const |
Find first character in the string that's not the specified character
size_t Common::BaseString< T >::findFirstNotOf | ( | const value_type * | chars, |
size_t | pos = 0 |
||
) | const |
Find first character in the string that's not any character of the passed string
size_t Common::BaseString< T >::findLastNotOf | ( | value_type | c | ) | const |
Find the last character in the string that's not the specified character
size_t Common::BaseString< T >::findLastNotOf | ( | const value_type * | chars | ) | const |
Find the last character in the string that's not in any of the passed characters
void Common::BaseString< T >::replace | ( | uint32 | pos, |
uint32 | count, | ||
const BaseString< T > & | str | ||
) |
Functions to replace some amount of chars with chars from some other string.
pos | Starting position for the replace in the original string. |
count | Number of chars to replace from the original string. |
str | Source of the new chars. |
posOri | Same as pos |
countOri | Same as count |
posDest | Initial position to read str from. |
countDest | Number of chars to read from str. npos by default. |
void Common::BaseString< T >::replace | ( | value_type | from, |
value_type | to | ||
) |
Replace all from characters in object by to character
from | the character to look for |
to | The replacement character |
void Common::BaseString< T >::append | ( | const value_type * | begin, |
const value_type * | end | ||
) |
Appends a string containing the characters between beginP (including) and endP (excluding).
void Common::BaseString< T >::wordWrap | ( | const uint32 | maxLength | ) |
Wraps the text in the string to the given line maximum. Lines will be broken at any whitespace character. New lines are assumed to be represented using '
'.
This is a very basic line wrap which does not perform tab stop calculation, consecutive whitespace collapsing, auto-hyphenation, or line balancing.
uint64 Common::BaseString< T >::asUint64 | ( | ) | const |
Return uint64 corrensponding to String's contents.
uint64 Common::BaseString< T >::asUint64Ext | ( | ) | const |
Return uint64 corrensponding to String's contents. This variant recognizes 0 (oct) and 0x (hex) prefixes.
void Common::BaseString< T >::toLowercase | ( | ) |
Convert all characters in the string to lowercase.
Be aware that this only affects the case of ASCII characters. All other characters will not be touched at all.
void Common::BaseString< T >::toUppercase | ( | ) |
Convert all characters in the string to uppercase.
Be aware that this only affects the case of ASCII characters. All other characters will not be touched at all.
void Common::BaseString< T >::trim | ( | ) |
Removes trailing and leading whitespaces. Uses isspace() to decide what is whitespace and what not.
|
staticprotected |
The size of the internal storage. Increasing this means less heap allocations are needed, at the cost of more stack memory usage, and of course lots of wasted memory.
|
protected |
Length of the string. Stored to avoid having to call strlen a lot. Yes, we limit ourselves to strings shorter than 4GB – on purpose :-).
|
protected |
Pointer to the actual string storage. Either points to _storage, or to a block allocated on the heap via malloc.
value_type Common::BaseString< T >::_storage[_builtinCapacity] |
Internal string storage.
struct { ... } Common::BaseString< T >::_extern |
External string storage data – the refcounter, and the capacity of the string _str points to.