- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Exponent::Basics::CString Class Reference

Inheritance diagram for Exponent::Basics::CString:

List of all members.

## Detailed Description

String handling class.

A string handling class. Takes care of most string handling duties, however, if you require path handling functions as well, please see

See also:
  CSystemString

Date:
  21/08/2004

Author:
  Paul Chana

Version:
  1.0.0 Initial version

  1.0.1 Fixed const correctness for operators

  1.0.2 Added equalsIgnoringCase functions

  1.0.3 Added replaceCharWithChar function

  1.0.4 Added setStringWithFormat function

  1.0.5 Added replaceCharWithString and replaceStringWithChar function

Note:
  All contents of this source code are copyright 2005 Exp Digital Uk.
  This source file is covered by the licence conditions of the Infinity API. You should have recieved a copy
  with the source code. If you didnt, please refer to http://www.expdigital.co.uk All content is the Intellectual property of Exp Digital Uk.
  Certain sections of this code may come from other sources. They are credited where applicable.
  If you have comments, suggestions or bug reports please visit http://support.expdigital.co.uk

Id
  CString.hpp,v 1.5 2007/02/08 21:06:44 paul Exp

Definition at line 52 of file CString.hpp.

## Public Member Functions

- virtual void appendString (const CString &string)
- virtual void appendString (const char *string)
- virtual void appendString (const char character)
- virtual char characterAt (const int index) const
- CString (const CString &string)
- CString (const char *string=" ")
- virtual bool equals (const CString &string) const
- virtual bool equals (const char *other) const
- virtual bool equalsIgnoringCase (const CString &string) const
- virtual bool equalsIgnoringCase (const char *other) const
- virtual long findBackwards (const char character)
- virtual long findForward (const char character)
- long findSubString (const CString &string)
- virtual long getNumberOfCharacters () const
- virtual void getObjectDescription (char *string, const long size) const
- virtual const char * getString () const
- virtual void getString (char *buffer) const
- virtual void getString (char *buffer, const long size) const
- virtual CPascalString getStringAsPascalString ()
- virtual CString getSubString (const long start, const long end) const
- virtual bool operator! () const
- virtual bool operator!= (const CString &string) const
- virtual bool operator!= (const char *string) const
- virtual CString & operator+= (const char *string)
- virtual CString & operator+= (const CString &string)
- virtual CString & operator= (const bool value)
- virtual CString & operator= (const int value)
- virtual CString & operator= (const long value)
- virtual CString & operator= (const float value)
- virtual CString & operator= (const char *string)
- virtual CString & operator= (CString &string)
- virtual CString & operator= (const CString &string)
- virtual bool operator== (const CString &string) const
- virtual bool operator== (const char *equals) const
- virtual char operator[] (const long index) const
- virtual void removeLastCharacter ()
- virtual void removeLeadingWhiteSpace ()
- virtual void removeTrailingAndLeadingWhiteSpace ()
- virtual void removeTrailingWhiteSpace ()
- virtual void replaceCharWithChar (const char characterToReplace, const char characterToReplaceWith)
- virtual void replaceCharWithString (const char characterToReplace, const CString &stringToReplaceWith)
- virtual void replaceStringWithChar (const char characterToReplaceWith, const CString &stringToReplace)
- virtual void setString (const CString &string)
- virtual void setString (const char *string)
- virtual void setStringWithFormat (const char *text,...)
- virtual void toLowerCase ()
- virtual void toUpperCase ()
- virtual ~CString ()

## Static Public Member Functions

- static CString emptyString ()
- static bool isWhiteSpace (const char letter)
- static CString * newEmptyString ()
- static double toDouble (const char *text)
- static float toFloat (const char *text)
- static int toInt (const char *text)
- static long toLong (const char *text)
- static char toLowerCase (const char letter)
- static char * toString (const long value)
- static char * toString (const int value)
- static char * toString (const float value)
- static char toUpperCase (const char letter)

## Static Public Attributes

- static const char CSTRING_EMPTY_STRING [3]
- static const long CSTRING_LONG_TEXT_LENGTH = 1024
- static const long CSTRING_MIDDLE_TEXT_LENGTH = 256
- static const char CSTRING_NULL_STRING []
- static const long CSTRING_SHORT_TEXT_LENGTH = 8

## Protected Attributes

- long m_numberOfCharacters
- char * m_string

## Constructor & Destructor Documentation

Exponent::Basics::CString::CString | ( | const char * | string = `" "` | ) |

Construction with a C-style string

Parameters:

  | string | The string you wish to store

Referenced by emptyString(), and newEmptyString().

Exponent::Basics::CString::CString | ( | const CString & | string | ) |

Copy construction

Parameters:

  | string | The string to copy

virtual Exponent::Basics::CString::~CString | ( |  | ) | `[virtual]`

Destruction

## Member Function Documentation

virtual void Exponent::Basics::CString::appendString | ( | const CString & | string | ) | `[virtual]`

Append a string to the end of this

Parameters:

  | string | The stirng to append

virtual void Exponent::Basics::CString::appendString | ( | const char * | string | ) | `[virtual]`

Append a string to the end of this

Parameters:

  | string | The stirng to append

virtual void Exponent::Basics::CString::appendString | ( | const char | character | ) | `[virtual]`

Append a single character to the end of this

Parameters:

  | character | The character to append

virtual char Exponent::Basics::CString::characterAt | ( | const int | index | ) | const`[virtual]`

Get the character at a specific index

Parameters:

  | index | The index of the character you want

Return values:

  | char | The character at the index you specified

static CString Exponent::Basics::CString::emptyString | ( |  | ) | `[inline, static]`

Get a new empty string

Return values:

  | CString | The empty string

Definition at line 265 of file CString.hpp.

References CString(), and CSTRING_NULL_STRING.

virtual bool Exponent::Basics::CString::equals | ( | const CString & | string | ) | const`[virtual]`

Do the strings match case important

Parameters:

  | string | The string to compare against

Return values:

  | bool | True if strings are equal, false otherwise

virtual bool Exponent::Basics::CString::equals | ( | const char * | other | ) | const`[virtual]`

Do the strings match case important

Parameters:

  | other | The string to compare against

Return values:

  | bool | True if strings are equal, false otherwise

virtual bool Exponent::Basics::CString::equalsIgnoringCase | ( | const CString & | string | ) | const`[virtual]`

Do the strings match ignoring case

Parameters:

  | string | The string to compare against

Return values:

  | bool | True if strings are equal, false otherwise

virtual bool Exponent::Basics::CString::equalsIgnoringCase | ( | const char * | other | ) | const`[virtual]`

Do the strings match ignoring case

Parameters:

  | other | The string to compare against

Return values:

  | bool | True if strings are equal, false otherwise

virtual long Exponent::Basics::CString::findBackwards | ( | const char | character | ) | `[virtual]`

Find the last occurance of a character

Parameters:

  | character | The character to search for

Return values:

  | long | -1 on failure, otherwise the index of last found

virtual long Exponent::Basics::CString::findForward | ( | const char | character | ) | `[virtual]`

Find the first occurance of a character

Parameters:

  | character | The character to search for

Return values:

  | long | -1 on failure, otherwise the index of first found

long Exponent::Basics::CString::findSubString | ( | const CString & | string | ) |

Find a sub string

Parameters:

  | string | The string to find

Return values:

  | long | starting index of the sub string or -1 on error

virtual long Exponent::Basics::CString::getNumberOfCharacters | ( |  | ) | const`[virtual]`

Get the number of characters in the string

Return values:

  | long | The number of characters in the string

virtual void Exponent::Basics::CString::getObjectDescription | ( | char * | string,
|  | const long | size |
| ) |  |  | const`[virtual]`

Get a description of the object

Parameters:

  | string | On return is filled with the description
  | size | The size of the stirng

Reimplemented from Exponent::Basics::CCountedObject.

virtual const char* Exponent::Basics::CString::getString | ( |  | ) | const`[virtual]`

Get a pointer to the string

Return values:

  | const | char* A pointer to the string

virtual void Exponent::Basics::CString::getString | ( | char * | buffer | ) | const`[virtual]`

Get a copy of the string

Parameters:

  | buffer | The buffer to fill (filled to CSTRING_SHORT_TEXT_LENGTH)

virtual void Exponent::Basics::CString::getString | ( | char * | buffer,
|  | const long | size |
| ) |  |  | const`[virtual]`

Get a copy of the string

Parameters:

  | buffer | The buffer to fill
  | size | The size of the buffer

virtual CPascalString Exponent::Basics::CString::getStringAsPascalString | ( |  | ) | `[virtual]`

Convert the string to a pascal string

Return values:

  | CPascalString* | The String as a pascal string. You are responsible for deleting the returned string

virtual CString Exponent::Basics::CString::getSubString | ( | const long | start,
|  | const long | end |
| ) |  |  | const`[virtual]`

Get a sub string from the main string

Parameters:

  | start | The starting index
  | end | The ending index (is included in sub string)

Return values:

  | CString | A new sub string

static bool Exponent::Basics::CString::isWhiteSpace | ( | const char | letter | ) | `[static]`

Check if the character is a white space

Parameters:

  | letter | The character to check

Return values:

  | bool | True if whitespace, false otherwise

static CString* Exponent::Basics::CString::newEmptyString | ( |  | ) | `[inline, static]`

Get a copy of the empty string

Return values:

  | CString* | The empty string. You are responsible for deleting memory on returned object

Definition at line 259 of file CString.hpp.

References CString(), and CSTRING_NULL_STRING.

virtual bool Exponent::Basics::CString::operator! | ( |  | ) | const`[virtual]`

Check if the string is empty

Return values:

  | bool | true if string is empty, false otherwise

virtual bool Exponent::Basics::CString::operator!= | ( | const CString & | string | ) | const`[virtual]`

Inequality operator

Parameters:

  | string | The string to compare against

Return values:

  | bool | True if strings are not equal, false otherwise

virtual bool Exponent::Basics::CString::operator!= | ( | const char * | string | ) | const`[virtual]`

Inequality operator

Parameters:

  | string | The string to compare against

Return values:

  | bool | True if strings are not equal, false otherwise

virtual CString& Exponent::Basics::CString::operator+= | ( | const char * | string | ) | `[virtual]`

Concatenate two strings

Parameters:

  | string | The string to append to the end of this

Return values:

  | CString& | A reference to this

Reimplemented in Exponent::Basics::CSystemString.

virtual CString& Exponent::Basics::CString::operator+= | ( | const CString & | string | ) | `[virtual]`

Concatenate two strings

Parameters:

  | string | The string to append to the end of this

Return values:

  | CString& | A reference to this

Reimplemented in Exponent::Basics::CSystemString.

virtual CString& Exponent::Basics::CString::operator= | ( | const bool | value | ) | `[virtual]`

Assignment operator Sets the string to "True" or "False"

Parameters:

  | value | The value to copy

Return values:

  | CString& | A reference to this

virtual CString& Exponent::Basics::CString::operator= | ( | const int | value | ) | `[virtual]`

Assignment operator

Parameters:

  | value | The value to copy

Return values:

  | CString& | A reference to this

virtual CString& Exponent::Basics::CString::operator= | ( | const long | value | ) | `[virtual]`

Assignment operator

Parameters:

  | value | The value to copy

Return values:

  | CString& | A reference to this

virtual CString& Exponent::Basics::CString::operator= | ( | const float | value | ) | `[virtual]`

Assignment operator

Parameters:

  | value | The value to copy

Return values:

  | CString& | A reference to this

virtual CString& Exponent::Basics::CString::operator= | ( | const char * | string | ) | `[virtual]`

Assignment operator

Parameters:

  | string | The string to copy

Return values:

  | CString& | A reference to this

Reimplemented in Exponent::Basics::CSystemString.

virtual CString& Exponent::Basics::CString::operator= | ( | CString & | string | ) | `[virtual]`

Assignment operator

Parameters:

  | string | The string to copy

Return values:

  | CString& | A reference to this

virtual CString& Exponent::Basics::CString::operator= | ( | const CString & | string | ) | `[virtual]`

Assignment operator

Parameters:

  | string | The string to copy

Return values:

  | CString& | A reference to this

virtual bool Exponent::Basics::CString::operator== | ( | const CString & | string | ) | const`[virtual]`

Equality operator

Parameters:

  | string | The string to compare against

Return values:

  | bool | True if strings are equal, false otherwise

virtual bool Exponent::Basics::CString::operator== | ( | const char * | equals | ) | const`[virtual]`

Equality operator

Parameters:

  | equals | The string to compare against

Return values:

  | bool | True if strings are equal, false otherwise

virtual char Exponent::Basics::CString::operator[] | ( | const long | index | ) | const`[virtual]`

Subscript operator

Parameters:

  | index | The index of the character you would like

Return values:

  | char | The character at the index

virtual void Exponent::Basics::CString::removeLastCharacter | ( |  | ) | `[virtual]`

Delete the last character

virtual void Exponent::Basics::CString::removeLeadingWhiteSpace | ( |  | ) | `[virtual]`

Remove leading white space

virtual void Exponent::Basics::CString::removeTrailingAndLeadingWhiteSpace | ( |  | ) | `[virtual]`

Remove trailing and leading white space

virtual void Exponent::Basics::CString::removeTrailingWhiteSpace | ( |  | ) | `[virtual]`

Remove trailing white space

virtual void Exponent::Basics::CString::replaceCharWithChar | ( | const char | characterToReplace,
|  | const char | characterToReplaceWith |
| ) |  |  | `[virtual]`

Replace a character with another character

Parameters:

  | characterToReplace | The character that will be replaced
  | characterToReplaceWith | The character that will be used in the replacement

virtual void Exponent::Basics::CString::replaceCharWithString | ( | const char | characterToReplace,
|  | const CString & | stringToReplaceWith |
| ) |  |  | `[virtual]`

Replace a character with a string

Parameters:

  | characterToReplace | The character that will be replaced
  | stringToReplaceWith | The string to replace with

virtual void Exponent::Basics::CString::replaceStringWithChar | ( | const char | characterToReplaceWith,
|  | const CString & | stringToReplace |
| ) |  |  | `[virtual]`

Replace a given sub string with a character

Parameters:

  | stringToReplace | The string that will be replaced
  | characterToReplaceWith | The character to replace with

virtual void Exponent::Basics::CString::setString | ( | const CString & | string | ) | `[virtual]`

Set the string

Parameters:

  | string | The string to store

virtual void Exponent::Basics::CString::setString | ( | const char * | string | ) | `[virtual]`

Set the string

Parameters:

  | string | The string to store

virtual void Exponent::Basics::CString::setStringWithFormat | ( | const char * | text,
|  |  | ... |
| ) |  |  | `[virtual]`

Format a text string - Used in an sprintf style

Parameters:

  | text | The text
  | ... | The variables

Referenced by Exponent::Midi::CMidi::getMidiNoteString().

static double Exponent::Basics::CString::toDouble | ( | const char * | text | ) | `[static]`

Convert the text string to a double

Parameters:

  | text | The string to be converted

Return values:

  | double | The string as a double, or 0 if failure

static float Exponent::Basics::CString::toFloat | ( | const char * | text | ) | `[static]`

Convert the text string to a float

Parameters:

  | text | The string to be converted

Return values:

  | float | The string as a float, or 0 if failure

static int Exponent::Basics::CString::toInt | ( | const char * | text | ) | `[static]`

Convert the text string to a int

Parameters:

  | text | The string to be converted

Return values:

  | int | The string as an int, or 0 if failure

static long Exponent::Basics::CString::toLong | ( | const char * | text | ) | `[static]`

Convert the text string to a long

Parameters:

  | text | The string to be converted

Return values:

  | long | The string as a long, or 0 if failure

static char Exponent::Basics::CString::toLowerCase | ( | const char | letter | ) | `[static]`

Change the case of a single character

Parameters:

  | letter | The letter to change the case of

Return values:

  | char | The character in lower case

virtual void Exponent::Basics::CString::toLowerCase | ( |  | ) | `[virtual]`

Converts the string to all lowercase

static char* Exponent::Basics::CString::toString | ( | const long | value | ) | `[static]`

Convert a long to a string

Parameters:

  | value | The value to be converted

Return values:

  | char* | The coverted string. You are responsible for deleting memory on returned object

static char* Exponent::Basics::CString::toString | ( | const int | value | ) | `[static]`

Convert an int to a string

Parameters:

  | value | The value to be converted

Return values:

  | char* | The coverted string. You are responsible for deleting memory on returned object

static char* Exponent::Basics::CString::toString | ( | const float | value | ) | `[static]`

Convert a float to a string

Parameters:

  | value | The value to be converted

Return values:

  | char* | The coverted string. You are responsible for deleting memory on returned object

static char Exponent::Basics::CString::toUpperCase | ( | const char | letter | ) | `[static]`

Change the case of a single character

Parameters:

  | letter | The letter to change the case of

Return values:

  | char | The character in upper case

virtual void Exponent::Basics::CString::toUpperCase | ( |  | ) | `[virtual]`

Converts the string to all uppercase

## Member Data Documentation

const char Exponent::Basics::CString::CSTRING_EMPTY_STRING[3]`[static]`

An empty string (set to " ")

Definition at line 67 of file CString.hpp.

const long Exponent::Basics::CString::CSTRING_LONG_TEXT_LENGTH = 1024`[static]`

A Long string

Definition at line 66 of file CString.hpp.

const long Exponent::Basics::CString::CSTRING_MIDDLE_TEXT_LENGTH = 256`[static]`

A Medium string

Definition at line 65 of file CString.hpp.

const char Exponent::Basics::CString::CSTRING_NULL_STRING[]`[static]`

A null string (set to "\0")

Definition at line 68 of file CString.hpp.

Referenced by emptyString(), and newEmptyString().

const long Exponent::Basics::CString::CSTRING_SHORT_TEXT_LENGTH = 8`[static]`

A Short string

Definition at line 64 of file CString.hpp.

long Exponent::Basics::CString::m_numberOfCharacters`[protected]`

The number of characters, not including terminator

Definition at line 516 of file CString.hpp.

char* Exponent::Basics::CString::m_string`[protected]`

The string

Definition at line 515 of file CString.hpp.