WT_String Class Reference

#include <wtstring.h>

Collaboration diagram for WT_String:

Collaboration graph
[legend]
List of all members.

Detailed Description

A generic string class which supports both ascii and wide characters.
Examples:

WhipExamples/ColorMap.cpp, WhipExamples/FileRead.cpp, WhipExamples/FileWrite.cpp, WhipExamples/Font.cpp, WhipExamples/OutputBlocks.cpp, WhipExamples/Text.cpp, WhipExamples/UserData.cpp, and WhipExamples/Visibility.cpp.

Definition at line 30 of file wtstring.h.

Public Member Functions

 WT_String ()
 Constructs a WT_String object.
 WT_String (WT_String const &string) throw (WT_Result)
 Constructs a WT_String object. Copy constructor.
 WT_String (WT_Unsigned_Integer16 const *string) throw (WT_Result)
 Constructs a WT_String object from a null-terminated wide character string (i.e. Unicode.).
 WT_String (WT_Byte const *string) throw (WT_Result)
 Constructs a WT_String object from a null-terminated ASCII character string.
 WT_String (char const *string) throw (WT_Result)
 Constructs a WT_String object from a null-terminated ASCII character string.
 WT_String (int length, WT_Unsigned_Integer16 const *string) throw (WT_Result)
 Constructs a WT_String object from a wide character string (i.e. Unicode) buffer for the specified length.
 WT_String (int length, WT_Byte const *string) throw (WT_Result)
 Constructs a WT_String object from an ASCII character string buffer for the specified length.
 WT_String (int length, char const *string) throw (WT_Result)
 Constructs a WT_String object from an ASCII character string buffer for the specified length.
 ~WT_String ()
 Destroys a WT_String object.
WT_Result serialize (WT_File &file, WT_Boolean force_quotes=WD_False) const
 Writes the WT_String to a file.
WT_Result materialize (WT_File &file)
 Reads a string from a file.
char const * ascii () const
 Returns an ASCII version of the string.
int length () const
 Returns the string length (in characters.).
WT_Unsigned_Integer16 const * unicode () const
 Returns a wide character (Unicode) version of the string.
 operator const WT_Unsigned_Integer16 * () const
 Wide character type cast operator - returns a wide character (Unicode) version of the string.
WT_Result set (int length, WT_Unsigned_Integer16 const *string)
 Sets the string from a wide character string (i.e. Unicode) buffer for the specified length.
WT_Result set (int length, WT_Byte const *string)
 Sets the string from a null-terminated ASCII character string buffer for the specified length.
WT_Result set (int length, char const *string)
 Sets the string from a null-terminated ASCII character string buffer for the specified length.
WT_Result set (WT_String const &string)
 Sets the string from another (performs a copy).
WT_String const & operator= (WT_Unsigned_Integer16 const *string) throw (WT_Result)
 Assignment operator. Sets the string from a null-terminated wide character string (i.e. Unicode.).
WT_String const & operator= (WT_Byte const *string) throw (WT_Result)
 Assignment operator. Sets the string from a null-terminated ASCII character string.
WT_String const & operator= (char const *string) throw (WT_Result)
 Assignment operator. Sets the string from a null-terminated ASCII character string.
WT_String const & operator= (WT_String const &string) throw (WT_Result)
 Assignment operator. Sets the string from another WT_String object.
WT_Boolean operator== (char const *string) const
 Equality operator. Returns WD_True if the strings are equal.
WT_Boolean operator== (WT_String const &string) const
 Equality operator. Returns WD_True if the strings are equal.
WT_Boolean operator!= (char const *string) const
 Inequality operator. Returns WD_True if the strings are NOT equal.
WT_Boolean operator!= (WT_String const &string) const
 Inequality operator. Returns WD_True if the strings are NOT equal.
WT_Boolean equals (char const *string, WT_Boolean case_sensitive=WD_True) const
 Equality method with case sensitivity toggle. Returns WD_True if the strings are equal.
WT_Boolean equals (WT_String const &string, WT_Boolean case_sensitive=WD_True) const
 Equality method with case sensitivity toggle. Returns WD_True if the strings are equal.
WT_Boolean equals_no_case (char const *string) const
 Equality method with no case sensitivity. Returns WD_True if the strings are equal (regardless of case.).
WT_Boolean equals_no_case (WT_String const &string) const
 Equality method with no case sensitivity. Returns WD_True if the strings are equal (regardless of case.).
WT_Boolean is_ascii () const
 Returns true if the string is an ASCII string (contains no Unicode characters.).

Static Public Member Functions

static int wcslen (WT_Unsigned_Integer16 const *string)
static WT_Boolean is_ascii (int length, WT_Unsigned_Integer16 const *string)
 Returns true if the string buffer is an ASCII string (contains no Unicode characters.).
static WT_Boolean is_ascii (int length, char const *string)
 Returns true if the string buffer is an ASCII string (contains no Unicode characters.).
static WT_Unsigned_Integer16to_unicode (int length, WT_Byte const *string) throw (WT_Result)
 Creates a wide character (Unicode) string from an ASCII buffer.
static wchar_t * to_wchar (int length, WT_Unsigned_Integer16 const *string) throw (WT_Result)
 Creates a wchar_t (portable Unicode) string from a wide (Unicode) string.
static WT_Byteto_ascii (int length, WT_Unsigned_Integer16 const *string) throw (WT_Result)
 Creates an ASCII string from a wide (Unicode) string.
static WT_Byte to_binary (WT_Byte ascii_hex_digit)
 Takes a hex character digit and returns the binary value (0-15).

Static Public Attributes

static const WT_String kNull
 Static empty string.


Member Function Documentation

WT_Result WT_String::materialize WT_File file  ) 
 

Reads a string from a file.

Return values:
WT_Result::Success The operation was successful.
Parameters:
file  The file to read from.

WT_Result WT_String::serialize WT_File file,
WT_Boolean  force_quotes = WD_False
const
 

Writes the WT_String to a file.

Return values:
WT_Result::Success The operation was successful.
Parameters:
file  The file to write to.
force_quotes  Add "quotation marks" around the string.

static WT_Byte* WT_String::to_ascii int  length,
WT_Unsigned_Integer16 const *  string
throw (WT_Result) [static]
 

Creates an ASCII string from a wide (Unicode) string.

The low-byte of each wide character is copied to the relative ASCII character.

Warning:
Client is responsible for calling delete[] on the returned pointer.
Return values:
WT_Byte* The new ASCII string.
Parameters:
length  The length of the string in characters.
string  The wide character (Unicode) buffer to copy from.

static WT_Byte WT_String::to_binary WT_Byte  ascii_hex_digit  )  [static]
 

Takes a hex character digit and returns the binary value (0-15).

Parameters:
ascii_hex_digit  Hex character ('0'-'9', 'A'-'F')

static WT_Unsigned_Integer16* WT_String::to_unicode int  length,
WT_Byte const *  string
throw (WT_Result) [static]
 

Creates a wide character (Unicode) string from an ASCII buffer.

The low-byte of each wide character is taken from the relative ASCII character, and the high-byte is zero.

Warning:
Client is responsible for calling delete[] on the returned pointer.
Return values:
WT_Unsigned_Integer16* The new wide string.
Parameters:
length  The length of the string in characters.
string  The ASCII buffer to copy from.

static wchar_t* WT_String::to_wchar int  length,
WT_Unsigned_Integer16 const *  string
throw (WT_Result) [static]
 

Creates a wchar_t (portable Unicode) string from a wide (Unicode) string.

On systems where wchar_t is the same as WT_Unsigned_Integer16, this returns a simple copy of the input string. On other systems, the input string is translated to the appropriate wchar_t representation.

Warning:
Client is responsible for calling delete[] on the returned pointer.
Return values:
wchar_t* The new wide string.
Parameters:
length  The length of the string in characters.
string  The 16 bit wide character (Unicode) buffer to copy from.
Examples:
WhipExamples/OutputBlocks.cpp.

static int WT_String::wcslen WT_Unsigned_Integer16 const *  string  )  [static]
 

A platform-independent implementation of wcslen for 16-bit characters. Note that we return 'int', not size_t.


The documentation for this class was generated from the following file:
Generated on Tue Jan 6 22:41:25 2009 for Autodesk DWF Whip 2D Toolkit by  doxygen 1.4.5