Utility class to manipulate strings.
|
Padding |
enum | PaddingType |
| Padding types.More...
|
KString | Pad(PaddingTypepPadding, size_t pLen, char pCar= ' ') const |
| Add padding characters.
|
KString | UnPad(PaddingTypepPadding) const |
| Remove padding characters.
|
Constructors and Destructor |
staticKString* | Create() |
| Create an instance.
|
staticKString* | Create(KString*pString) |
| Create an instance if not already allocated ( is null ).
|
staticKString* | DestroyIfEmpty(KString*pString) |
| Destroy the allocated space if empty.
|
staticKString* | StringOrEmpty(KString*pString) |
| Destroy the allocated space if empty.
|
void | Destroy() |
| Destroy an allocated version of the string.
|
Memory Pool Management |
static KMemoryAllocator * | AllocatorGet() |
static void | AllocatorPurge() |
static void | AllocatorRelease() |
Constructors and Destructor |
| KString() |
| Default constructor.
|
| KString(constKString&pStr) |
| Copy constructor.
|
| KString(const char *pStr) |
| String constructor.
|
| KString(char pChar, size_t pNbRepeat=1) |
| Character constructor.
|
| KString(const char *pCharPtr, size_t pLength) |
| String constructor with maximum length.
|
| KString(const int pValue) |
| Int constructor.
|
| KString(const float pValue) |
| Float constructor.
|
| KString(const double pValue) |
| Double constructor.
|
| ~KString() |
| Destructor.
|
Instance Validation. |
bool | IsOK() const |
| Returntrue if string is valid.
|
KString& | Invalidate() |
| Invalidate string.
|
size_t | GetLen() const |
| Get string length like "C" strlen().
|
bool | IsEmpty() const |
| Returntrue if string is of length 0.
|
KString& | Empty() |
| Discard the content of the object.
|
Buffer Access |
char& | operator[](int pIndex) |
| Access by reference.
|
char | operator[](int pIndex) const |
| Access by copy.
|
| operator const char *() const |
| Cast operator.
|
char * | Buffer() |
| Non-const buffer access.
|
const char * | Buffer() const |
| const buffer access.
|
Assignment Operators |
constKString& | operator=(constKString&pStr) |
| KStringassignment operator.
|
constKString& | operator=(char pChar) |
| Character assignment operator.
|
constKString& | operator=(const char *pStr) |
| String assignment operator.
|
constKString& | operator=(int pValue) |
| Int assignment operator.
|
constKString& | operator=(float pValue) |
| Float assignment operator.
|
constKString& | operator=(double pValue) |
| Double assignment operator.
|
constKString& | Copy(size_t pLen, const char *pStr) |
| String assignment function.
|
void | Swap(KString&) |
| KStringassignment operator.
|
Append and Concatenation |
constKString& | Append(const char *pStr) |
| Append as "C" strcat().
|
constKString& | AppendN(const char *pStr, size_t pLength) |
| Append as "C" strncat().
|
constKString& | operator+=(constKString&pKStr) |
| KStringappend.
|
constKString& | operator+=(char pChar) |
| Character append.
|
constKString& | operator+=(const char *pStr) |
| String append.
|
constKString& | operator+=(int pValue) |
| Int append.
|
constKString& | operator+=(float pValue) |
| Float append.
|
KBASELIB_DLLKString | operator+(constKString&pKStr1, constKString&pKStr2) |
| KStringconcatenation.
|
KBASELIB_DLLKString | operator+(constKString&pKStr, char pChar) |
| Character concatenation.
|
KBASELIB_DLLKString | operator+(constKString&pKStr, const char *pStr) |
| String concatenation.
|
KBASELIB_DLLKString | operator+(constKString&pKStr, int pValue) |
| Int concatenation.
|
KBASELIB_DLLKString | operator+(constKString&pKStr, float pValue) |
| Float concatenation.
|
String Comparison |
int | Compare(const char *pStr) const |
| Compare as "C" strcmp().
|
int | CompareNoCase(const char *pStr) const |
| Compare as "C" stricmp().
|
bool | operator==(constKString&pStr) const |
| Equality operator.
|
bool | operator!=(constKString&pStr) const |
| Inequality operator.
|
bool | operator<(constKString&pStr) const |
| Inferior to operator.
|
bool | operator<=(constKString&pStr) const |
| Inferior or equal to operator.
|
bool | operator>=(constKString&pStr) const |
| Superior or equal to operator.
|
bool | operator>(constKString&pStr) const |
| Superior to operator.
|
bool | operator==(const char *pStr) const |
| Equality operator.
|
bool | operator!=(const char *pStr) const |
| Inequality operator.
|
bool | operator<(const char *pStr) const |
| Inferior to operator.
|
bool | operator<=(const char *pStr) const |
| Inferior or equal to operator.
|
bool | operator>=(const char *pStr) const |
| Superior or equal to operator.
|
bool | operator>(const char *pStr) const |
| Superior to operator.
|
Substring Extraction |
KString | Mid(size_t pFirst, size_t pCount) const |
| Extract middle string for a given length.
|
KString | Mid(size_t pFirst) const |
| Extract middle string up to the end.
|
KString | Left(size_t pCount) const |
| Extract left string.
|
KString | Right(size_t pCount) const |
| Extract right string.
|
Conversion |
KString | Upper() const |
| Uppercase conversion.
|
KString | Lower() const |
| Lowercase conversion.
|
KString | Reverse() const |
| Reverse conversion.
|
KString | ConvertToUnix() const |
| Convert to Unix, changes \r\n characters for a single \n.
|
KString | ConvertToWindows() const |
| Convert to Windows, changes \n character for both \r\n.
|
Search |
int | Find(char pChar, size_t pStartPosition=0) const |
| Look for a single character match, like "C" strchr().
|
int | Find(const char *pStrSub, size_t pStartPosition=0) const |
| Look for a substring match, like "C" strstr().
|
int | ReverseFind(char pChar) const |
| Look for a single character match, like "C" strrchr().
|
int | FindOneOf(const char *pStrCharSet, size_t pStartPosition=0) const |
| Look for a single character match, like "C" strpbrk().
|
bool | FindAndReplace(const char *pFind, const char *pReplaceBy, size_t pStartPosition=0) |
| Replace a substring.
|
bool | ReplaceAll(char pFind, char pReplaceBy) |
| Replace a character.
|
Token Extraction |
int | GetTokenCount(const char *pSpans) const |
| Get number of tokens.
|
KString | GetToken(int pTokenIndex, const char *pSpans) const |
| Get token at given index.
|