KString Class Reference

#include <kstring.h>

List of all members.


Detailed Description

Utility class to manipulate strings.

Definition at line 108 of file kstring.h.


Padding

enum   PaddingType {
   eRight,
   eLeft,
   eBoth
}
  Padding types. More...
KString  Pad (PaddingType pPadding, size_t pLen, char pCar=' ') const
  Add padding characters.
KString  UnPad (PaddingType pPadding) const
  Remove padding characters.

Constructors and Destructor

  KString ()
  Default constructor.
  KString (const KString &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)
  Integer constructor.
  KString (const float pValue)
  Float constructor.
  KString (const double pValue)
  Double constructor.
  ~KString ()
  Destructor.
void  Destroy ()
  Destroy an allocated version of the string.

Buffer Access and Validation

size_t  GetLen () const
  Get string length like "C" strlen().
bool  IsEmpty () const
  Return true if string length equal zero.
KString Empty ()
  Discard the content of the string.
char &  operator[] (int pIndex)
  Access by reference.
char  operator[] (int pIndex) const
  Access by copy.
char *  Buffer ()
  Non-const buffer access.
const char *  Buffer () const
  Const buffer access.

String Operations

const KString operator= (const KString &pStr)
  KString assignment operator.
const KString operator= (char pChar)
  Character assignment operator.
const KString operator= (const char *pStr)
  String assignment operator.
const KString operator= (int pValue)
  Int assignment operator.
const KString operator= (float pValue)
  Float assignment operator.
const KString operator= (double pValue)
  Double assignment operator.
const KString operator+= (const KString &pKStr)
  KString append.
const KString operator+= (char pChar)
  Character append.
const KString operator+= (const char *pStr)
  String append.
const KString operator+= (int pValue)
  Integer append.
const KString operator+= (float pValue)
  Float append.
const KString operator+= (double pValue)
  Double append.
bool  operator== (const KString &pStr) const
  Equality operator.
bool  operator!= (const KString &pStr) const
  Inequality operator.
bool  operator< (const KString &pStr) const
  Inferior to operator.
bool  operator<= (const KString &pStr) const
  Inferior or equal to operator.
bool  operator>= (const KString &pStr) const
  Superior or equal to operator.
bool  operator> (const KString &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.
  operator const char * () const
  Cast operator.
const KString Copy (const char *pStr, size_t pLength)
  String assignment function with maximum length.
const KString Append (const char *pStr, size_t pLength)
  Append as "C" strncat().
int  Compare (const char *pStr) const
  Compare as "C" strcmp().
int  CompareNoCase (const char *pStr) const
  Compare as "C" stricmp().
void  Swap (KString &pStr)
  Swap the contents of two strings.
KString  Upper () const
  Uppercase conversion.
KString  Lower () const
  Lowercase conversion.
KFBX_DLL KString  operator+ (const KString &pKStr1, const KString &pKStr2)
  KString concatenation.
KFBX_DLL KString  operator+ (const KString &pKStr, char pChar)
  Character concatenation.
KFBX_DLL KString  operator+ (const KString &pKStr, const char *pStr)
  String concatenation.
KFBX_DLL KString  operator+ (const KString &pKStr, int pValue)
  Integer concatenation.
KFBX_DLL KString  operator+ (const KString &pKStr, float pValue)
  Float concatenation.
KFBX_DLL KString  operator+ (const KString &pKStr, double pValue)
  Double concatenation.

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.

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 the last occurrence of character in string, 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 (const char *pFind, const char *pReplaceBy)
  Replace all occurrence of a substring.
bool  ReplaceAll (char pFind, char pReplaceBy)
  Replace all occurrence of character to find by replacement 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.

Member Enumeration Documentation

Padding types.

  • eRight
  • eLeft
  • eBoth
Enumerator:
eRight 
eLeft 
eBoth 

Definition at line 377 of file kstring.h.


Constructor & Destructor Documentation

KString (  ) 

Default constructor.

KString ( const KString pStr  ) 

Copy constructor.

Parameters:
pStr  The KString to be copied.

KString ( const char *  pStr  ) 

String constructor.

Parameters:
pStr  The string used to construct KString.

KString ( char  pChar,
size_t  pNbRepeat = 1  
)

Character constructor.

Parameters:
pChar  The character used to construct KString.
pNbRepeat  The number of times to repeat the character. Default value is 1

KString ( const char *  pCharPtr,
size_t  pLength  
)

String constructor with maximum length.

Parameters:
pCharPtr  The string used to construct KString.
pLength  Maximum length.

KString ( const int  pValue  ) 

Integer constructor.

Parameters:
pValue  The int value used to construct KString.

KString ( const float  pValue  ) 

Float constructor.

Parameters:
pValue  The float value used to construct KString.

KString ( const double  pValue  ) 

Double constructor.

Parameters:
pValue  The double value used to construct KString.

~KString (  ) 

Destructor.


Member Function Documentation

void Destroy (  ) 

Destroy an allocated version of the string.

size_t GetLen (  )  const

Get string length like "C" strlen().

Referenced by fbxCopy().

bool IsEmpty (  )  const

Return true if string length equal zero.

KString& Empty (  ) 

Discard the content of the string.

char& operator[] ( int  pIndex  ) 

Access by reference.

Parameters:
pIndex  The index.
Returns:
The reference of the char at pIndex.

char operator[] ( int  pIndex  )  const

Access by copy.

Parameters:
pIndex  The index.
Returns:
The char at pIndex.

char* Buffer (  ) 

Non-const buffer access.

Referenced by fbxCopy(), and KStringListTemplate< KStringListItem >::SetText().

const char* Buffer (  )  const

Const buffer access.

const KString& operator= ( const KString pStr  ) 

KString assignment operator.

Parameters:
pStr  The KString to be assigned.

const KString& operator= ( char  pChar  ) 

Character assignment operator.

Parameters:
pChar  The character to be assigned.

const KString& operator= ( const char *  pStr  ) 

String assignment operator.

Parameters:
pStr  The string to be assigned.

const KString& operator= ( int  pValue  ) 

Int assignment operator.

Parameters:
pValue  The int value to be assigned.

const KString& operator= ( float  pValue  ) 

Float assignment operator.

Parameters:
pValue  The float value to be assigned.

const KString& operator= ( double  pValue  ) 

Double assignment operator.

Parameters:
pValue  The double value to be assigned.

const KString& operator+= ( const KString pKStr  ) 

KString append.

Parameters:
pKStr  The KString to be appended.

const KString& operator+= ( char  pChar  ) 

Character append.

Parameters:
pChar  The character to be appended.

const KString& operator+= ( const char *  pStr  ) 

String append.

Parameters:
pStr  The string to be appended.

const KString& operator+= ( int  pValue  ) 

Integer append.

Parameters:
pValue  The int value to be appended.

const KString& operator+= ( float  pValue  ) 

Float append.

Parameters:
pValue  The float value to be appended.

const KString& operator+= ( double  pValue  ) 

Double append.

Parameters:
pValue  The double value to be appended.

bool operator== ( const KString pStr  )  const

Equality operator.

Parameters:
pStr  The KString to be compared.

bool operator!= ( const KString pStr  )  const

Inequality operator.

Parameters:
pStr  The KString to be compared.

bool operator< ( const KString pStr  )  const

Inferior to operator.

Parameters:
pStr  The KString to be compared.

bool operator<= ( const KString pStr  )  const

Inferior or equal to operator.

Parameters:
pStr  The KString to be compared.

bool operator>= ( const KString pStr  )  const

Superior or equal to operator.

Parameters:
pStr  The KString to be compared.

bool operator> ( const KString pStr  )  const

Superior to operator.

Parameters:
pStr  The KString to be compared.

bool operator== ( const char *  pStr  )  const

Equality operator.

Parameters:
pStr  The string to be compared.

bool operator!= ( const char *  pStr  )  const

Inequality operator.

Parameters:
pStr  The string to be compared.

bool operator< ( const char *  pStr  )  const

Inferior to operator.

Parameters:
pStr  The string to be compared.

bool operator<= ( const char *  pStr  )  const

Inferior or equal to operator.

Parameters:
pStr  The string to be compared.

bool operator>= ( const char *  pStr  )  const

Superior or equal to operator.

Parameters:
pStr  The string to be compared.

bool operator> ( const char *  pStr  )  const

Superior to operator.

Parameters:
pStr  The string to be compared.

operator const char * (  )  const

Cast operator.

const KString& Copy ( const char *  pStr,
size_t  pLength  
)

String assignment function with maximum length.

Parameters:
pStr  The string to be assigned.
pLength  The maximum length of string to be assigned.

const KString& Append ( const char *  pStr,
size_t  pLength  
)

Append as "C" strncat().

Parameters:
pStr  The string to be appended.
pLength  The length of chars to be appended.

int Compare ( const char *  pStr  )  const

Compare as "C" strcmp().

Parameters:
pStr  The string to be compared.

int CompareNoCase ( const char *  pStr  )  const

Compare as "C" stricmp().

Parameters:
pStr  The string to be compared.

void Swap ( KString pStr  ) 

Swap the contents of two strings.

Parameters:
pStr  The KString to be swapped.

KString Upper (  )  const

Uppercase conversion.

KString Lower (  )  const

Lowercase conversion.

KString Mid ( size_t  pFirst,
size_t  pCount  
) const

Extract middle string for a given length.

Parameters:
pFirst  The start index of KString to be extracted.
pCount  The length of sub-string to be extracted.

Referenced by RemoveChar().

KString Mid ( size_t  pFirst  )  const

Extract middle string up to the end.

Parameters:
pFirst  The start index of KString to be extracted.

KString Left ( size_t  pCount  )  const

Extract left string.

Parameters:
pCount  The length of sub-string to be extracted.

Referenced by RemoveChar().

KString Right ( size_t  pCount  )  const

Extract right string.

Parameters:
pCount  The length of sub-string to be extracted.

KString Pad ( PaddingType  pPadding,
size_t  pLen,
char  pCar = ' '  
) const

Add padding characters.

Parameters:
pPadding  The padding type.
pLen  The length limit of KString after padding.
pCar  The character to be padded.

KString UnPad ( PaddingType  pPadding  )  const

Remove padding characters.

Parameters:
pPadding  The padding type.

int Find ( char  pChar,
size_t  pStartPosition = 0  
) const

Look for a single character match, like "C" strchr().

Parameters:
pChar  The character to look for.
pStartPosition  Start position to look for.
Returns:
Index or -1 if not found.

int Find ( const char *  pStrSub,
size_t  pStartPosition = 0  
) const

Look for a substring match, like "C" strstr().

Parameters:
pStrSub  The substring to look for.
pStartPosition  Start position to look for.
Returns:
Starting index or -1 if not found.

int ReverseFind ( char  pChar  )  const

Look for the last occurrence of character in string, like "C" strrchr().

Parameters:
pChar  The character to look for.
Returns:
Index or -1 if not found.

Referenced by RemoveChar().

int FindOneOf ( const char *  pStrCharSet,
size_t  pStartPosition = 0  
) const

Look for a single character match, like "C" strpbrk().

Parameters:
pStrCharSet  The character set.
pStartPosition  The start position.
Returns:
Index or -1 if not found.

bool FindAndReplace ( const char *  pFind,
const char *  pReplaceBy,
size_t  pStartPosition = 0  
)

Replace a substring.

Parameters:
pFind  The substring to look for.
pReplaceBy  The string to replace by.
pStartPosition  The start position.
Returns:
true if substring found and replaced.

bool ReplaceAll ( const char *  pFind,
const char *  pReplaceBy  
)

Replace all occurrence of a substring.

Parameters:
pFind  The substring to look for.
pReplaceBy  The string to replace by.
Returns:
true if something got replaced.

bool ReplaceAll ( char  pFind,
char  pReplaceBy  
)

Replace all occurrence of character to find by replacement character.

Parameters:
pFind  The character to look for.
pReplaceBy  The character to replace by.
Returns:
true if character found and replaced.

int GetTokenCount ( const char *  pSpans  )  const

Get number of tokens.

Parameters:
pSpans  The span
Returns:
The number of tokens.

KString GetToken ( int  pTokenIndex,
const char *  pSpans  
) const

Get token at given index.

Parameters:
pTokenIndex  The token index.
pSpans  The span

Friends And Related Function Documentation

KFBX_DLL KString operator+ ( const KString pKStr1,
const KString pKStr2  
) [friend]

KString concatenation.

Parameters:
pKStr1  KString 1 to be concatenated to KString 2.
pKStr2  KString 2 to be concatenated to KString 1

KFBX_DLL KString operator+ ( const KString pKStr,
char  pChar  
) [friend]

Character concatenation.

Parameters:
pKStr  KString to be concatenated to Character.
pChar  Character to be concatenated to KString

KFBX_DLL KString operator+ ( const KString pKStr,
const char *  pStr  
) [friend]

String concatenation.

Parameters:
pKStr  KString to be concatenated to String.
pStr  String to be concatenated to KString

KFBX_DLL KString operator+ ( const KString pKStr,
int  pValue  
) [friend]

Integer concatenation.

Parameters:
pKStr  KString to be concatenated to Integer.
pValue  Integer to be concatenated to KString

KFBX_DLL KString operator+ ( const KString pKStr,
float  pValue  
) [friend]

Float concatenation.

Parameters:
pKStr  KString to be concatenated to Float.
pValue  Float to be concatenated to KString

KFBX_DLL KString operator+ ( const KString pKStr,
double  pValue  
) [friend]

Double concatenation.

Parameters:
pKStr  KString to be concatenated to Double.
pValue  Double to be concatenated to KString
KString KString KString KString KString KString KString KString KString KString
KString KString KString KString KString KString KString KString KString KString