Main Page   Class Hierarchy   Compound List   File List   Compound Members  

csString Class Reference

This is a "string" class with a range of useful operators and typesafe overloads. More...

#include <csstring.h>

List of all members.

Public Methods

void SetCapacity (size_t NewSize)
 Set string capacity to NewSize characters (plus one for ending NULL).

void Free ()
 Free the memory allocated for the string.

csString& Truncate (size_t iPos)
 Truncate the string.

csString& Reclaim ()
 Set string maximal capacity to current string length.

csString& Clear ()
 Clear the string (so that it contains only ending NULL character).

char* GetData () const
 Get a pointer to ASCIIZ string.

size_t Length () const
 Query string length.

bool IsEmpty () const
 Check if string is empty.

char& operator[] (size_t iPos)
 Get a reference to iPos'th character.

void SetAt (size_t iPos, const char iChar)
 Set characetr number iPos to iChar.

char GetAt (size_t iPos) const
 Get character at position iPos.

csString& DeleteAt (size_t iPos, size_t iCount=1)
 Delete iCount characters at iPos.

csString& Insert (size_t iPos, const csString &iStr)
 Insert another string into this one at position iPos.

csString& Insert (size_t iPos, const char iChar)
 Insert a char into this string at position iPos.

csString& Overwrite (size_t iPos, const csString &iStr)
 Overlay another string onto a part of this string.

csString& Append (const char *iStr, size_t iCount=(size_t)-1)
 Append an ASCIIZ string to this one (possibly iCount characters from the string).

csString& Append (const csString &iStr, size_t iCount=(size_t)-1)
 Append a string to this one (possibly iCount characters from the string).

csString& Append (char c)
 Append a character to this string.

csString& Append (unsigned char c)
 STR_APPEND (short,%hd, 32) STR_APPEND(unsigned short,%hu, 32) STR_APPEND(int,%d, 32) STR_APPEND(unsigned int,%u, 32) STR_APPEND(long,%ld, 32) STR_APPEND(unsigned long,%lu, 32) STR_APPEND(float,%g, 64) STR_APPEND(double,%g, 64) csString &Append(bool b)
 Append a boolean (as a number -- 1 or 0) to this string.

csString& Replace (const csString &iStr, size_t iCount=(size_t)-1)
 Replace contents of this string with the contents of another.

bool Compare (const csString &iStr) const
 Check if two strings are equal.

bool Compare (const char *iStr) const
 Same but compare with an ASCIIZ string.

bool CompareNoCase (const csString &iStr) const
 Compare two strings ignoring case.

bool CompareNoCase (const char *iStr) const
 Compare ignoring case with an ASCIIZ string.

 csString ()
 Create an empty csString object.

 csString (size_t iLength)
 Create an csString object and reserve space for iLength characters.

 csString (const csString &copy)
 Copy constructor from existing csString.

 csString (const char *copy)
 Copy constructor from ASCIIZ string.

 csString (char c)
 Copy constructor from a character.

virtual ~csString ()
 Destroy a csString object.

csString Clone () const
 Get a copy of this string.

csString& LTrim ()
 Trim all of the white space off of the left side of the string.

csString& RTrim ()
 Trim all of the white space off of the right side of the string.

csString& Trim ()
 Does both LTrim() and RTrim().

csString& Collapse ()
 Calls Trim() and collapses internal whitespace to a single space.

csString& Format (const char *format,...)
 STR_FORMAT (short,%hd, 32) STR_FORMAT(unsigned short,%hu, 32) STR_FORMAT(int,%d, 32) STR_FORMAT(unsigned int,%u, 32) STR_FORMAT(long,%ld, 32) STR_FORMAT(unsigned long,%lu, 32) STR_FORMAT(float,%g, 64) STR_FORMAT(double,%g, 64)#define STR_FORMAT_INT(TYPE, FMT) STR_FORMAT_INT(short, hd) STR_FORMAT_INT(unsigned short, hu) STR_FORMAT_INT(int, d) STR_FORMAT_INT(unsigned int, u) STR_FORMAT_INT(long, ld) STR_FORMAT_INT(unsigned long, lu)#define STR_FORMAT_FLOAT(TYPE) STR_FORMAT_FLOAT(float) STR_FORMAT_FLOAT(double) csString &PadLeft(size_t iNewSize, char iChar='')
 Pad to specified size with leading chars.

csString AsPadLeft (size_t iNewSize, char iChar='')
 Return a new string formatted with PadLeft.

 STR_PADLEFT (const csString &) STR_PADLEFT(const char *) STR_PADLEFT(char) STR_PADLEFT(unsigned char) STR_PADLEFT(short) STR_PADLEFT(unsigned short) STR_PADLEFT(int) STR_PADLEFT(unsigned int) STR_PADLEFT(long) STR_PADLEFT(unsigned long) STR_PADLEFT(float) STR_PADLEFT(double) STR_PADLEFT(bool) csString &PadRight(size_t iNewSize, char iChar='')
 Pad to specified size with trailing chars.

csString AsPadRight (size_t iNewSize, char iChar='')
 Return a new string formatted with PadRight.

 STR_PADRIGHT (const csString &) STR_PADRIGHT(const char *) STR_PADRIGHT(char) STR_PADRIGHT(unsigned char) STR_PADRIGHT(short) STR_PADRIGHT(unsigned short) STR_PADRIGHT(int) STR_PADRIGHT(unsigned int) STR_PADRIGHT(long) STR_PADRIGHT(unsigned long) STR_PADRIGHT(float) STR_PADRIGHT(double) STR_PADRIGHT(bool) csString &PadCenter(size_t iNewSize, char iChar='')
 Pad to specified size between chars (any remainder is prepended).

csString AsPadCenter (size_t iNewSize, char iChar='')
 Return a copy of this string formatted with PadCenter.

 STR_PADCENTER (const csString &) STR_PADCENTER(const char *) STR_PADCENTER(char) STR_PADCENTER(unsigned char) STR_PADCENTER(short) STR_PADCENTER(unsigned short) STR_PADCENTER(int) STR_PADCENTER(unsigned int) STR_PADCENTER(long) STR_PADCENTER(unsigned long) STR_PADCENTER(float) STR_PADCENTER(double) STR_PADCENTER(bool) csString &operator=(const csString &iStr)
 Assign a string to another.

 STR_APPEND (const csString &) STR_APPEND(const char *) STR_APPEND(char) STR_APPEND(unsigned char) STR_APPEND(short) STR_APPEND(unsigned short) STR_APPEND(int) STR_APPEND(unsigned int) STR_APPEND(long)
 STR_APPEND (unsigned long) STR_APPEND(float) STR_APPEND(double) STR_APPEND(bool) csString operator+(const csString &iStr) const
 Concatenate two strings and return a third one.

 operator const char * () const
 Return a const reference to this string in ASCIIZ format.

bool operator== (const csString &iStr) const
 Check if two strings are equal.

char* Detach ()
 Detach the contents from the csString.


Detailed Description

This is a "string" class with a range of useful operators and typesafe overloads.


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000