Main Page   Modules   Class Hierarchy   Compound List   Compound Members  

GAUGE3D::GString Class Reference

A unicode-capable string class. More...

#include <gauge3d/gstring.h>

List of all members.

Public Methods

 GString ()
 Create an empty (zero-length) string.

 GString (const GString &other)
 Copy constructor.

 GString (const char cstr[])
 Construct from ASCII character array.

 GString (const wchar_t cstr[])
 Construct from Unicode character array.

 GString (const char cstr[],int length)
 Construct from ASCII character array of given length (in characters).

 GString (const wchar_t cstr[],int length)
 Construct from Unicode character array of given length (in wide characters).

 GString (int i)
 Create a string representation of an int (base-10).

 GString (double f)
 Create a string representation of a float (base-10).

 ~GString ()
int Compare (const GString &other)const
 Compare one string to another. More...

int Compare (const char other[])const
 Compare to a null-terminated char string.

int Compare (const wchar_t other[])const
 Compare to a null-terminated wide char string.

int FindFirstOf (wchar_t c)const
 Returns the index of the first instance of the given character in the string.

int FindLastOf (wchar_t c)const
 Returns the index of the last instance of the given character in the string.

int FindNext (wchar_t c,int start)const
 Returns the index of the first instance of the character occurring after the start position.

GString SubString (int start)const
 Returns a sub string of the string. More...

GString SubString (int start,int length)const
 Returns a sub string of the string. More...

int Length ()const
 Gets the length of the string in characters (or wide characters).

bool IsUnicode ()const
 Returns true if the string is represented as Unicode internally. More...

GString ToUnicode ()const
 Returns the same string, except with a Unicode internal representation. More...

GString ToAscii ()const
 Returns the same string, except with an ASCII internal representation. More...

const char* AsciiData ()const
 Returns a pointer to the internal buffer of the string. More...

const wchar_t* UnicodeData ()const
 Returns a pointer to the internal buffer of the string. More...

void SetChar (int index,wchar_t value)
 Set the given character in the string to the given value. More...

 operator int ()
 Interpret string as an integer and convert.

 operator float ()
 Interpret string as a floating point value and convert.

wchar_t operator[] (int index)const
 Array-like access to the characters in the string. More...

const GString& operator= (const GString &other)
 Assignment operator.

String concatination operators.
GString operator+ (const GString &other)const
const GString& operator+= (const GString &other)
GString operator+ (char other)const
const GString& operator+= (char other)
GString operator+ (char other[])const
const GString& operator+= (char other[])
GString operator+ (wchar_t other[])const
const GString& operator+= (wchar_t other[])
String comparison operators.
bool operator== (const GString &other)const
bool operator!= (const GString &other)const
bool operator< (const GString &other)const
bool operator> (const GString &other)const
bool operator<= (const GString &other)const
bool operator>= (const GString &other)const
bool operator== (const char other[])const
bool operator!= (const char other[])const
bool operator< (const char other[])const
bool operator> (const char other[])const
bool operator<= (const char other[])const
bool operator>= (const char other[])const
bool operator== (const wchar_t other[])const
bool operator!= (const wchar_t other[])const
bool operator< (const wchar_t other[])const
bool operator> (const wchar_t other[])const
bool operator<= (const wchar_t other[])const
bool operator>= (const wchar_t other[])const

Related Functions

(Note that these are not member functions.)

GString operator+ (const char *str1,const GString &str2)
GString operator+ (const wchar_t str1[],const GString &str2)


Detailed Description

A unicode-capable string class.

GString can represent both ASCII and Unicode strings and it can convert between them. The internal buffer is reference-counted, so it is perfectly performance-safe to pass strings by value. When a write operation on the string occurs, the internal buffer will be copied if and only if it does not have a reference count of one.


Member Function Documentation

int GAUGE3D::GString::Compare ( const GString & other ) const
 

Compare one string to another.

Returns:
Negative if the string is less than other, positive if it is greater than other, or zero if the strings are equal.
Remarks:
This function basically just calls strcmp (or wcscmp for Unicode) and returns the result.

GString GAUGE3D::GString::SubString ( int start ) const
 

Returns a sub string of the string.

Parameters:
start   The index of the character at which to start the substring.
Returns:
The substring, or an empty string if start was out-of-range.

GString GAUGE3D::GString::SubString ( int start,
int length ) const
 

Returns a sub string of the string.

Parameters:
start   The index of the character at which to start the substring.
length   The number of characters to place in the substring.
Returns:
The substring, or an empty string if start was out-of-range.

bool GAUGE3D::GString::IsUnicode ( ) const
 

Returns true if the string is represented as Unicode internally.

Remarks:
Internally, the string could be represented in either ASCII or Unicode. Do not assume to know what a string is without testing it.

GString GAUGE3D::GString::ToUnicode ( ) const
 

Returns the same string, except with a Unicode internal representation.

Remarks:
You only need to use this if you are planning to call UnicodeData() and the string is not already in Unicode format. Note that if the string is already in Unicode format, then this function will return the same string, so calling IsUnicode() first is not faster.

GString GAUGE3D::GString::ToAscii ( ) const
 

Returns the same string, except with an ASCII internal representation.

Remarks:
You only need to use this if you are planning to call AsciiData() and the string is not already in ASCII format. Note that if the string is already in ASCII format, then this function will return the same string, so calling IsUnicode() first is not faster.
Note:
If any non-ASCII characters are part of the string, they will be corrupted by this function.

const char * GAUGE3D::GString::AsciiData ( ) const
 

Returns a pointer to the internal buffer of the string.

Returns:
A pointer to a null-terminated ASCII character array, or NULL if the string is not represented in ASCII internally.
Remarks:
Avoid doing operations on raw character arrays. You should try to use GString's member functions to manipulate the string. If you must operate on char arrays directly, remember to write versions of the operation for both ASCII and Unicode!

const wchar_t * GAUGE3D::GString::UnicodeData ( ) const
 

Returns a pointer to the internal buffer of the string.

Returns:
A pointer to a null-terminated Unicode character array, or NULL if the string is not represented in Unicode internally.
Remarks:
Avoid doing operations on raw character arrays. You should try to use GString's member functions to manipulate the string. If you must operate on char arrays directly, remember to write versions of the operation for both ASCII and Unicode!

void GAUGE3D::GString::SetChar ( int index,
wchar_t value )
 

Set the given character in the string to the given value.

Note:
This function is relatively slow (compared to real array access).

wchar_t GAUGE3D::GString::operator[] ( int index ) const
 

Array-like access to the characters in the string.

Remarks:
Remember, this function does not return a reference to the character, so you cannot assign to it. Use SetChar() to change a character if you must.
Note:
This function is relatively slow (compared to real array access).


The documentation for this class was generated from the following file:
Generated at Tue Jan 30 17:07:34 2001 for gauge3d by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000