Class WStr

3DS Max Plug-In SDK

Class WStr

See Also: Class CStr, Character Strings.

class WStr

Description:

A wide character string class. This class uses 16 bits to hold each character. Methods and operators are provided for calculating lengths, concatenation, substring operations, character searching, case conversion, comparison, and formatted writing. All methods are implemented by the system.

OLE file IO requires the wide characters of WStr.

Methods:

Prototype:

WStr();

Remarks:

Constructor. The string is set to NULL.

Prototype:

WStr(const char *cs);

Remarks:

Constructor. The string is initialized to the string passed.

Prototype:

WStr(const wchar_t *wcstr);

Remarks:

Constructor. The string is initialized to the string passed.

Prototype:

WStr(const WStr& ws);

Remarks:

Constructor. The string is initialized to the string passed.

Prototype:

~WStr()

Remarks:

Destructor. The string is deleted.

Prototype:

wchar_t *data();

Remarks:

Returns a pointer to the string. If the string is NULL, 0 is returned.

Prototype:

const wchar_t *data() const;

Remarks:

This method is available in release 3.0 and later only.

Returns a pointer to the string. If the string is NULL, 0 is returned.

Prototype:

const wchar_t *data() const;

Remarks:

This method is available in release 3.0 and later only.

Returns a pointer to the string. If the string is NULL, 0 is returned.

Prototype:

operator wchar_t *();

Remarks:

Returns a pointer to the string. If the string is NULL, 0 is returned.

Prototype:

void Resize(int nchars);

Remarks:

Reallocates the string to contain nchars characters. If the string is enlarged it is padded with blanks.

Parameters:

int nchars

Specifies the new number of characters for the string.

Prototype:

int Length() const;

Remarks:

Returns the number of characters in the string.

Prototype:

int length() const;

Remarks:

Returns the number of characters in the string.

Prototype:

BOOL isNull();

Remarks:

Returns TRUE if the string length is 0; otherwise FALSE.

Prototype:

WStr & operator=(const WStr& ws);

Remarks:

Assignment operator. In release 3.0 and later this operator checks for self-assignment.

Prototype:

WStr & operator=(const wchar_t *wcstr);

Remarks:

Assignment operator.

Prototype:

WStr & operator=(const char *cstr);

Remarks:

Assignment operator.

Prototype:

WStr operator+(const WStr& ws) const;

Remarks:

Concatenation operator. Returns a new string that is this string with string ws appended.

Prototype:

WStr & operator+=(const WStr& ws);

Remarks:

Concatenation. Returns this string with ws appended.

Prototype:

WStr& Append(const WStr& ws)

Remarks:

Concatenation. Returns this string with ws appended.

Prototype:

WStr& append(const WStr& ws);

Remarks:

Concatenation. Returns this string with ws appended.

Prototype:

WStr& remove(int pos);

Remarks:

Returns this string with N characters removed from pos to the end.

Parameters:

int pos

Specifies the position to begin removing characters.

int N

Specifies the number of characters to remove.

Prototype:

WStr Substr(int start, int nchars) const;

Remarks:

Returns a substring of this string, beginning at position start, of length nchars.

Prototype:

wchar_t& operator[](int i)

Remarks:

Returns a substring of this string beginning at position i.

Prototype:

int first(wchar_t c) const;

Remarks:

Returns the index of the first occurrence of character c in this string. Returns -1 if not found.

Prototype:

int last(wchar_t c) const;

Remarks:

Returns the index of the last occurrence of character c in this string. Returns -1 if not found.

Prototype:

int operator==(const WStr &ws) const;

Remarks:

Equality operator.

Return Value:

Nonzero if the strings are equal; otherwise 0.

Prototype:

int operator<(const WStr &ws) const;

Remarks:

Returns nonzero if this string is less than ws; otherwise 0.

Prototype:

int operator<=(const WStr &ws) const;

Remarks:

Returns nonzero if this string is less than or equal to ws; otherwise 0.

Prototype:

int operator>(const WStr &ws) const;

Remarks:

Returns nonzero if this string is greater than ws; otherwise 0.

Prototype:

int operator>=(const WStr &ws) const;

Remarks:

Returns nonzero if this string is greater than or equal to ws; otherwise 0.

Prototype:

void toUpper();

Remarks:

Converts all character of this string to uppercase.

Prototype:

void toLower();

Remarks:

Converts all character of this string to lowercase.

Prototype:

int printf(const wchar_t *format, ...);

Remarks:

Formatted output to this string.

Return Value:

The number of character output or EOF on error.

Sample Code:

WStr buf;

buf.printf(_T("Rendering In Progress: Frame %d"),curFrame);