Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

wkgl::String Class Reference

An implementation of a unicode string class. More...

#include <String.h>

List of all members.

Public Methods

 String ()
 Creates an empty string.

 String (const String &string)
 Copy constructor.

 String (const char *string)
 Creates a string from a char*.

 String (const WCHAR *string)
 Create a string from a WCHAR*.

 String (const char *string, long sindex, long count)
 Creates a string from a substring of a char*.

 String (const WCHAR *string, long sindex, long count)
 Creates a string from a substring of a WCHAR*.

 ~String ()
 Destructor.

virtual void toUpper ()
 Converts this string to all upper case letters.

virtual void toLower ()
 Converts this string to all lower case letters.

virtual void trim ()
 Removes leading and trailing whitespace.

virtual void replace (char old_char, char new_char)
 Replaces all occurences of a character with another.

virtual void replace (WCHAR old_char, WCHAR new_char)
 Replaces all occurences of a character with another.

virtual String substring (long sindex)
 Returns the substring from sindex to the end of the string.

virtual String substring (long sindex, long count)
 Return sthe substring from sindex to count.

virtual String concat (const String &string)
 Returns the concatenation of this string and another.

virtual String concat (const char *string)
 Returns the concatenation of this string and another.

virtual String concat (const WCHAR *string)
 Returns the concatenation of this string and another.

virtual void setString (const String &string)
 Copies the given string into this one.

virtual void setString (const char *string)
 Copies the given string into this one.

virtual void setString (const WCHAR *string)
 Copies the given string into this one.

virtual void insert (const String &string, int bindex)
 Inserts the given string into the this one.

virtual void insert (const char *string, int bindex)
 Inserts the given string into the this one.

virtual void insert (const WCHAR *string, int bindex)
 Inserts the given string into the this one.

virtual char charAt (long index)
 Returns the char at the given index.

virtual WCHAR wcharAt (long index)
 Returns the WCHAR at the given index.

virtual void setCharAt (char c, long index)
 Sets the char at the given index.

virtual void setWCharAt (WCHAR c, long index)
 Sets the WCHAR at the given index.

virtual long length ()
 Returns the length of this string.

virtual long indexOf (char c)
 Returns the index of the first occurence of c.

virtual long indexOf (WCHAR c)
 Returns the index of the first occurence of c.

virtual long indexOf (char c, long fromindex)
 Returns the index of the first occurence of c starting at fromindex.

virtual long indexOf (WCHAR c, long fromindex)
 Returns the index of the first occurence of c starting at fromindex.

virtual long lastIndexOf (char c)
 Returns the index of the last occurence of c.

virtual long lastIndexOf (WCHAR c)
 Returns the index of the last occurence of c.

virtual long lastIndexOf (char c, long fromindex)
 Returns the index of the last occurence of c starting at fromindex.

virtual long lastIndexOf (WCHAR c, long fromindex)
 Returns the index of the last occurence of c starting at fromindex.

virtual int compareTo (const String &string)
 Compares this string to another.

virtual int compareTo (const char *string)
 Compares this string to another.

virtual int compareTo (const WCHAR *string)
 Compares this string to another.

virtual int compareToIgnoreCase (const String &string)
 Compares this string to another, ignoring case.

virtual int compareToIgnoreCase (const char *string)
 Compares this string to another, ignoring case.

virtual int compareToIgnoreCase (const WCHAR *string)
 Compares this string to another, ignoring case.

virtual BOOL equals (const String &string)
 Returns whether this string and another are equal.

virtual BOOL equals (const char *string)
 Returns whether this string and another are equal.

virtual BOOL equals (const WCHAR *string)
 Returns whether this string and another are equal.

virtual BOOL equalsIgnoreCase (const String &string)
 Returns whether this string and another are equal, ignoring case.

virtual BOOL equalsIgnoreCase (const char *string)
 Returns whether this string and another are equal, ignoring case.

virtual BOOL equalsIgnoreCase (const WCHAR *string)
 Returns whether this string and another are equal, ignoring case.

virtual void operator= (const String &string)
 Gives this string the same value as another.

virtual void operator= (const char *string)
 Gives this string the same value as another.

virtual void operator= (const WCHAR *string)
 Gives this string the same value as another.

virtual BOOL operator== (const String &string)
 Returns whether this string and another are equal.

virtual BOOL operator== (const char *string)
 Returns whether this string and another are equal.

virtual BOOL operator== (const WCHAR *string)
 Returns whether this string and another are equal.

virtual BOOL operator!= (const String &string)
 Returns whether this string and another are not equal.

virtual BOOL operator!= (const char *string)
 Returns whether this string and another are not equal.

virtual BOOL operator!= (const WCHAR *string)
 Returns whether this string and another are not equal.

virtual String operator+ (const String &string)
 Concatenates this string and another.

virtual String operator+ (const char *string)
 Concatenates this string and another.

virtual String operator+ (const WCHAR *string)
 Concatenates this string and another.

virtual operator char * ()
 Returns this string as a new char*.

virtual operator WCHAR * ()
 Returns this string as a new WCHAR*.

virtual operator LPARAM ()
 Returns this string as a new LPARAM.

virtual operator String * ()
 Returns a pointer to this class.


Static Public Methods

String valueOf (long i)
 Returns the string value of the given integer value.

String valueOf (char c)
 Returns the string value of the given character value.

String valueOf (const char *string)
 Returns the string value of the given string.

String valueOf (WCHAR wc)
 Returns the string value of the given wide character.

String valueOf (const WCHAR *string)
 Returns the string value of the given wide character string.

String valueOf (bool b)
 Returns the string value of the given boolean value.

String valueOf (double d)
 Returns the string value of the given double value.


Protected Attributes

WCHAR * chars
 The actual string in memory.

long clen
 The length of the string.


Detailed Description

An implementation of a unicode string class.

Author:
Micheal Nooner
This class uses two-bytes to represent a character. The characters are represented in unicode. You should be able to use this class just like a normal char* with two exceptions. First you cannot use array indexs, instead use String::charAt(). Second you may have to do some explicit casting to clear up any ambiguities.

The casting operator overloads return pointers to new arrays that are copies of this string. So you should delete any you make. You should also be aware that any alterations made to these copies will not affect the object. To make the object reflect your alterations you should use the String::setString() method.


Constructor & Destructor Documentation

String::String  
 

Creates an empty string.

String::String const String &    string
 

Copy constructor.

Parameters:
string  The string to construct this string from.

String::String const char *    string
 

Creates a string from a char*.

Parameters:
string  The string to construct this string from.

String::String const WCHAR *    string
 

Create a string from a WCHAR*.

Parameters:
string  The string to construct this string from.

String::String const char *    string,
long    sindex,
long    count
 

Creates a string from a substring of a char*.

Parameters:
string  The string to construct this string from.
sindex  The index of the initial offset.
count  The length.

String::String const WCHAR *    string,
long    sindex,
long    count
 

Creates a string from a substring of a WCHAR*.

Parameters:
string  The string to construct this string from.
sindex  The index of the initial offset.
count  The length.

String::~String  
 

Destructor.


Member Function Documentation

char String::charAt long    index [virtual]
 

Returns the char at the given index.

Parameters:
index  The index of character to retrieve.
Returns:
The character at the given index.

int String::compareTo const WCHAR *    string [virtual]
 

Compares this string to another.

Parameters:
string  The string to compare this one to.
Returns:
Either less than zero if string is less than this string, greater than zero if string greater than this object, or zero if the two strings are equal.

int String::compareTo const char *    string [virtual]
 

Compares this string to another.

Parameters:
string  The string to compare this one to.
Returns:
Either less than zero if string is less than this string, greater than zero if string greater than this object, or zero if the two strings are equal.

int String::compareTo const String &    string [virtual]
 

Compares this string to another.

Parameters:
string  The string to compare this one to.
Returns:
Either less than zero if string is less than this string, greater than zero if string greater than this object, or zero if the two strings are equal.

int String::compareToIgnoreCase const WCHAR *    string [virtual]
 

Compares this string to another, ignoring case.

Parameters:
string  The string to compare this one to.
Returns:
Either less than zero if string is less than this string, greater than zero if string greater than this object, or zero if the two strings are equal.

int String::compareToIgnoreCase const char *    string [virtual]
 

Compares this string to another, ignoring case.

Parameters:
string  The string to compare this one to.
Returns:
Either less than zero if string is less than this string, greater than zero if string greater than this object, or zero if the two strings are equal.

int String::compareToIgnoreCase const String &    string [virtual]
 

Compares this string to another, ignoring case.

Parameters:
string  The string to compare this one to.
Returns:
Either less than zero if string is less than this string, greater than zero if string greater than this object, or zero if the two strings are equal.

String String::concat const WCHAR *    string [virtual]
 

Returns the concatenation of this string and another.

Parameters:
string  The string to concatenate with this one.
Returns:
The concatenation of this string and string.

String String::concat const char *    string [virtual]
 

Returns the concatenation of this string and another.

Parameters:
string  The string to concatenate with this one.
Returns:
The concatenation of this string and string.

String String::concat const String &    string [virtual]
 

Returns the concatenation of this string and another.

Parameters:
string  The string to concatenate with this one.
Returns:
The concatenation of this string and string.

BOOL String::equals const WCHAR *    string [virtual]
 

Returns whether this string and another are equal.

Parameters:
string  The string to compare this one to.
Returns:
TRUE if they are the same, FALSE otherwise.

BOOL String::equals const char *    string [virtual]
 

Returns whether this string and another are equal.

Parameters:
string  The string to compare this one to.
Returns:
TRUE if they are the same, FALSE otherwise.

BOOL String::equals const String &    string [virtual]
 

Returns whether this string and another are equal.

Parameters:
string  The string to compare this one to.
Returns:
TRUE if they are the same, FALSE otherwise.

BOOL String::equalsIgnoreCase const WCHAR *    string [virtual]
 

Returns whether this string and another are equal, ignoring case.

Parameters:
string  The string to compare this one to.
Returns:
TRUE if they are the same, FALSE otherwise.

BOOL String::equalsIgnoreCase const char *    string [virtual]
 

Returns whether this string and another are equal, ignoring case.

Parameters:
string  The string to compare this one to.
Returns:
TRUE if they are the same, FALSE otherwise.

BOOL String::equalsIgnoreCase const String &    string [virtual]
 

Returns whether this string and another are equal, ignoring case.

Parameters:
string  The string to compare this one to.
Returns:
TRUE if they are the same, FALSE otherwise.

long String::indexOf WCHAR    c,
long    fromindex
[virtual]
 

Returns the index of the first occurence of c starting at fromindex.

Parameters:
c  The wide character to find.
fromindex  the starting index for the search.
Returns:
The index of the first occurence of the character in the string, or -1 if it is not found.

long String::indexOf char    c,
long    fromindex
[virtual]
 

Returns the index of the first occurence of c starting at fromindex.

Parameters:
c  The character to find.
fromindex  the starting index for the search.
Returns:
The index of the first occurence of the character in the string, or -1 if it is not found.

long String::indexOf WCHAR    c [virtual]
 

Returns the index of the first occurence of c.

Parameters:
c  The wide character to find.
Returns:
The index of the first occurence of the character in the string, or -1 if it is not found.

long String::indexOf char    c [virtual]
 

Returns the index of the first occurence of c.

Parameters:
c  The character to find.
Returns:
The index of the first occurence of the character in the string, or -1 if it is not found.

void String::insert const WCHAR *    string,
int    bindex
[virtual]
 

Inserts the given string into the this one.

Parameters:
string  The string to insert into this string.
bindex  The begining index to insert the string at.

void String::insert const char *    string,
int    bindex
[virtual]
 

Inserts the given string into the this one.

Parameters:
string  The string to insert into this string.
bindex  The begining index to insert the string at.

void String::insert const String &    string,
int    bindex
[virtual]
 

Inserts the given string into the this one.

Parameters:
string  The string to insert into this string.
bindex  The begining index to insert the string at.

long String::lastIndexOf WCHAR    c,
long    fromindex
[virtual]
 

Returns the index of the last occurence of c starting at fromindex.

Parameters:
c  The wide character to find.
fromindex  the starting index for the search.
Returns:
The index of the last occurence of the character in the string, or -1 if it is not found.

long String::lastIndexOf char    c,
long    fromindex
[virtual]
 

Returns the index of the last occurence of c starting at fromindex.

Parameters:
c  The character to find.
fromindex  the starting index for the search.
Returns:
The index of the last occurence of the character in the string, or -1 if it is not found.

long String::lastIndexOf WCHAR    c [virtual]
 

Returns the index of the last occurence of c.

Parameters:
c  The wide character to find.
Returns:
The index of the last occurence of the character in the string, or -1 if it is not found.

long String::lastIndexOf char    c [virtual]
 

Returns the index of the last occurence of c.

Parameters:
c  The character to find.
Returns:
The index of the last occurence of the character in the string, or -1 if it is not found.

long String::length   [virtual]
 

Returns the length of this string.

Returns:
The length of this string, i.e. String::clen.

String::operator char *   [virtual]
 

Returns this string as a new char*.

String::operator LPARAM   [virtual]
 

Returns this string as a new LPARAM.

String::operator String *   [virtual]
 

Returns a pointer to this class.

String::operator WCHAR *   [virtual]
 

Returns this string as a new WCHAR*.

BOOL String::operator!= const WCHAR *    string [virtual]
 

Returns whether this string and another are not equal.

Parameters:
string  The string to compare this one to.
Returns:
FALSE if they are the same, TRUE otherwise.

BOOL String::operator!= const char *    string [virtual]
 

Returns whether this string and another are not equal.

Parameters:
string  The string to compare this one to.
Returns:
FALSE if they are the same, TRUE otherwise.

BOOL String::operator!= const String &    string [virtual]
 

Returns whether this string and another are not equal.

Parameters:
string  The string to compare this one to.
Returns:
FALSE if they are the same, TRUE otherwise.

String String::operator+ const WCHAR *    string [virtual]
 

Concatenates this string and another.

Parameters:
string  The string to concatenate with this one.
Returns:
The concatenation of this string and string.

String String::operator+ const char *    string [virtual]
 

Concatenates this string and another.

Parameters:
string  The string to concatenate with this one.
Returns:
The concatenation of this string and string.

String String::operator+ const String &    string [virtual]
 

Concatenates this string and another.

Parameters:
string  The string to concatenate with this one.
Returns:
The concatenation of this string and string.

void String::operator= const WCHAR *    string [virtual]
 

Gives this string the same value as another.

Parameters:
string  The string to set this string's value to.

void String::operator= const char *    string [virtual]
 

Gives this string the same value as another.

Parameters:
string  The string to set this string's value to.

void String::operator= const String &    string [virtual]
 

Gives this string the same value as another.

Parameters:
string  The string to set this string's value to.

BOOL String::operator== const WCHAR *    string [virtual]
 

Returns whether this string and another are equal.

Parameters:
string  The string to compare this one to.
Returns:
TRUE if they are the same, FALSE otherwise.

BOOL String::operator== const char *    string [virtual]
 

Returns whether this string and another are equal.

Parameters:
string  The string to compare this one to.
Returns:
TRUE if they are the same, FALSE otherwise.

BOOL String::operator== const String &    string [virtual]
 

Returns whether this string and another are equal.

Parameters:
string  The string to compare this one to.
Returns:
TRUE if they are the same, FALSE otherwise.

void String::replace WCHAR    old_char,
WCHAR    new_char
[virtual]
 

Replaces all occurences of a character with another.

Parameters:
old_char  The character to replace all occurences of.
new_char  The character to replace old_char with.

void String::replace char    old_char,
char    new_char
[virtual]
 

Replaces all occurences of a character with another.

Parameters:
old_char  The character to replace all occurences of.
new_char  The character to replace old_char with.

void String::setCharAt char    c,
long    index
[virtual]
 

Sets the char at the given index.

Parameters:
c  The new character
index  The index of character to set.

void String::setString const WCHAR *    string [virtual]
 

Copies the given string into this one.

Parameters:
string  The string to set this string's value to.

void String::setString const char *    string [virtual]
 

Copies the given string into this one.

Parameters:
string  The string to set this string's value to.

void String::setString const String &    string [virtual]
 

Copies the given string into this one.

Parameters:
string  The string to set this string's value to.

void String::setWCharAt WCHAR    c,
long    index
[virtual]
 

Sets the WCHAR at the given index.

Parameters:
c  The new wide character
index  The index of wide character to set.

String String::substring long    sindex,
long    count
[virtual]
 

Return sthe substring from sindex to count.

Parameters:
sindex  The index of the initial offset.
count  The length.
Returns:
The substring of this string starting at sindex and having a length equal to count.

String String::substring long    sindex [virtual]
 

Returns the substring from sindex to the end of the string.

Parameters:
sindex  The index of the initial offset.
Returns:
The substring of this string going from sindex to the end.

void String::toLower   [virtual]
 

Converts this string to all lower case letters.

void String::toUpper   [virtual]
 

Converts this string to all upper case letters.

void String::trim   [virtual]
 

Removes leading and trailing whitespace.

String String::valueOf double    d [static]
 

Returns the string value of the given double value.

Parameters:
d  the value to find the string representation for.
Returns:
the string representation of d.

String String::valueOf bool    b [static]
 

Returns the string value of the given boolean value.

Parameters:
b  the value to find the string representation for.
Returns:
the string representation of b.

String String::valueOf const WCHAR *    string [static]
 

Returns the string value of the given wide character string.

Parameters:
string  the value to find the string representation for.
Returns:
the string representation of string.

String String::valueOf WCHAR    wc [static]
 

Returns the string value of the given wide character.

Parameters:
wc  the value to find the string representation for.
Returns:
the string representation of wc.

String String::valueOf const char *    string [static]
 

Returns the string value of the given string.

Parameters:
string  the value to find the string representation for.
Returns:
the string representation of string.

String String::valueOf char    c [static]
 

Returns the string value of the given character value.

Parameters:
c  the value to find the string representation for.
Returns:
the string representation of c.

String String::valueOf long    i [static]
 

Returns the string value of the given integer value.

Parameters:
i  the value to find the string representation for.
Returns:
the string representation of i.

WCHAR String::wcharAt long    index [virtual]
 

Returns the WCHAR at the given index.

Parameters:
index  The index of character to retrieve.
Returns:
The wide character at the given index.


Member Data Documentation

WCHAR* wkgl::String::chars [protected]
 

The actual string in memory.

long wkgl::String::clen [protected]
 

The length of the string.


The documentation for this class was generated from the following files:
Generated on Tue Apr 29 03:19:02 2003 for GuiLib by doxygen1.2.18