This reference page is linked to from the following overview topics: General Best Practices, Guidelines for Handling Character Strings, Unicode, wchar_t is Now Treated as a Type.
#include <strclass.h>
Public Member Functions |
|
WStr () | |
WStr (const wchar_t *wcstr) | |
WStr (const WStr &ws) | |
WStr (const MaxSDK::Util::MaxString &ws) | |
WStr (const MaxSDK::Util::MaxStringCast< WCHAR > &ws) | |
~WStr () | |
wchar_t * | dataForWrite (size_t nchars=(size_t)-1) |
const wchar_t * | data () const |
operator const wchar_t * () const | |
void | Resize (int nchars) |
int | Length () const |
int | length () const |
int | ByteCount () const |
int | LanguageCharacterCount () const |
size_t | AllocatedChars () const |
bool | isNull () const |
WStr & | operator= (const WStr &ws) |
WStr & | operator= (const MaxSDK::Util::MaxString &mstr) |
WStr & | operator= (const wchar_t *wcstr) |
WStr & | operator= (const MaxSDK::Util::MaxStringCast< WCHAR > &mstr) |
WStr | operator+ (const WStr &ws) const |
WStr & | operator+= (const WStr &ws) |
WStr & | Append (const WStr &ws) |
WStr & | append (const WStr &ws) |
WStr & | remove (int pos) |
WStr & | remove (int pos, int N) |
WStr | Substr (int start, int nchars) const |
wchar_t | operator[] (int i) const |
Returns the nth character of this string.
|
|
int | first (wchar_t c) const |
int | last (wchar_t c) const |
bool | operator== (const WStr &ws) const |
bool | operator== (wchar_t c) const |
bool | operator!= (const WStr &ws) const |
bool | operator!= (wchar_t c) const |
bool | operator< (const WStr &ws) const |
bool | operator<= (const WStr &ws) const |
bool | operator> (const WStr &ws) const |
bool | operator>= (const WStr &ws) const |
void | toUpper () |
void | toLower () |
int | printf (const wchar_t *format,...) |
Write a formatted string into this WStr. |
|
int | vprintf (const wchar_t *format, va_list args) |
Write a formatted string into this WStr. |
|
WStr | MultiByteCharacterSubString (int firstCharacterIndex, int numberOfMBCharacters) const |
wchar_t * | ToBSTR () const |
MaxSDK::Util::MaxStringCastCP | ToCP (UINT cp, size_t *length=NULL) const |
MaxSDK::Util::MaxStringCast< char > | ToACP (size_t *length=NULL) const |
MaxSDK::Util::MaxStringCastUTF8 | ToUTF8 (size_t *length=NULL) const |
MaxSDK::Util::MaxStringCast < WCHAR > |
ToOLESTR (size_t *length=NULL) const |
MaxSDK::Util::MaxStringCast < WCHAR > |
ToUTF16 (size_t *length=NULL) const |
MaxSDK::Util::MaxStringCast < unsigned int > |
ToUTF32 (size_t *length=NULL) const |
MaxSDK::Util::MaxString | ToMaxString () const |
void | ToMaxString (MaxSDK::Util::MaxString &) const |
CStr | ToCStr () const |
WStr | ToWStr () const |
MaxSDK::Util::MaxStringCast< char > | ToMCHAR (size_t *length=NULL) const |
CStr | ToMSTR () const |
bool | EndsWith (const WStr &s, bool caseSensitive=true) |
Returns true if the string ends with s;
otherwise returns false. |
|
bool | EndsWith (wchar_t c, bool caseSensitive=true) |
Returns true if the string ends with c;
otherwise returns false. |
|
bool | StartsWith (const WStr &s, bool caseSensitive=true) |
Returns true if the string starts with s;
otherwise returns false. |
|
bool | StartsWith (wchar_t c, bool caseSensitive=true) |
Returns true if the string starts with c;
otherwise returns false. |
|
size_t | NumberOfLines () const |
Returns the number of lines inside a string.
|
|
size_t | Replace (const wchar_t *pFind, const wchar_t *pReplaceBy, bool firstOnly=false, size_t startPosition=0) |
Replaces one substring with another in this
string. |
|
Static Public Member Functions |
|
static WStr | FromBSTR (const wchar_t *string, size_t length=(size_t)-1) |
static WStr | FromCP (UINT cp, const char *string, size_t length=(size_t)-1) |
static WStr | FromACP (const char *string, size_t length=(size_t)-1) |
static WStr | FromUTF8 (const char *string, size_t length=(size_t)-1) |
static WStr | FromOLESTR (const wchar_t *string, size_t length=(size_t)-1) |
static WStr | FromUTF16 (const wchar_t *string, size_t length=(size_t)-1) |
static WStr | FromUTF32 (const unsigned int *string, size_t length=(size_t)-1) |
static WStr | FromMaxString (MaxSDK::Util::MaxString &string) |
static WStr | FromCStr (const CStr &string) |
static WStr | FromWStr (const WStr &string) |
static WStr | FromMCHAR (const char *string, size_t length=(size_t)-1) |
static WStr | FromMSTR (const CStr &string) |
WStr | ( | ) |
WStr | ( | const wchar_t * | wcstr | ) |
Constructor. The string is initialized to the string passed.
WStr | ( | const MaxSDK::Util::MaxString & | ws | ) |
WStr | ( | const MaxSDK::Util::MaxStringCast< WCHAR > & | ws | ) |
~WStr | ( | ) |
wchar_t* dataForWrite | ( | size_t | nchars =
(size_t)-1 |
) |
const wchar_t* data | ( | ) | const |
operator const wchar_t * | ( | ) | const |
void Resize | ( | int | nchars | ) |
int Length | ( | ) | const |
int length | ( | ) | const [inline] |
{ return Length(); }
int ByteCount | ( | ) | const |
int LanguageCharacterCount | ( | ) | const |
This may be equal or less than the amount of WCHAR used to store the string in memory. For example, a chinese character might take two WCHARs. Length() will count the character as two distinct WCHARs. LanguageCharacterCount() will count it as a single character.
size_t AllocatedChars | ( | ) | const |
bool isNull | ( | ) | const [inline] |
{ return data()[0]==0; }
WStr& operator= | ( | const MaxSDK::Util::MaxString & | mstr | ) |
WStr& operator= | ( | const wchar_t * | wcstr | ) |
WStr& operator= | ( | const MaxSDK::Util::MaxStringCast< WCHAR > & | mstr | ) |
Assignment operator.
{ return ((*this) += ws); }
{ return ((*this) += ws); }
WStr& remove | ( | int | pos | ) |
WStr& remove | ( | int | pos, |
int | N | ||
) |
WStr Substr | ( | int | start, |
int | nchars | ||
) | const |
wchar_t operator[] | ( | int | i | ) | const |
Returns the nth character of this string.
Warning: In some environment, this function may return a partial character, especially for asiatic languages. If you intend to do any advance transformation or interpretation of the returned data, you should consider calling WStr::MultiByteCharacterSubString instead.
i | Index of that character. |
int first | ( | wchar_t | c | ) | const |
int last | ( | wchar_t | c | ) | const |
bool operator== | ( | const WStr & | ws | ) | const |
bool operator== | ( | wchar_t | c | ) | const |
bool operator!= | ( | const WStr & | ws | ) | const |
bool operator!= | ( | wchar_t | c | ) | const |
bool operator< | ( | const WStr & | ws | ) | const |
bool operator<= | ( | const WStr & | ws | ) | const |
bool operator> | ( | const WStr & | ws | ) | const |
bool operator>= | ( | const WStr & | ws | ) | const |
void toUpper | ( | ) |
void toLower | ( | ) |
int printf | ( | const wchar_t * | format, |
... | |||
) |
Write a formatted string into this WStr.
Writes the format string, filled in by the optional arguments into this WStr. See the ISO C++ documentation for more information on printf and format strings.
format | Specifies how to format the destination string. |
... | optional arguments to format into the destination string. |
int vprintf | ( | const wchar_t * | format, |
va_list | args | ||
) |
Write a formatted string into this WStr.
This method is similar to WStr::printf. Instead of taking a variable list of arguments as parameter, it takes a structure representing a variable list of argument. This allows WStr objects to be used to build strings based on a format string and a variable number of arguments:
WStr MultiByteCharacterSubString | ( | int | firstCharacterIndex, |
int | numberOfMBCharacters | ||
) | const |
wchar_t* ToBSTR | ( | ) | const |
static WStr FromBSTR | ( | const wchar_t * | string, |
size_t | length =
(size_t)-1 |
||
) | [static] |
MaxSDK::Util::MaxStringCastCP ToCP | ( | UINT | cp, |
size_t * | length =
NULL |
||
) | const |
static WStr FromCP | ( | UINT | cp, |
const char * | string, | ||
size_t | length =
(size_t)-1 |
||
) | [static] |
MaxSDK::Util::MaxStringCast<char> ToACP | ( | size_t * | length = NULL |
) | const |
static WStr FromACP | ( | const char * | string, |
size_t | length =
(size_t)-1 |
||
) | [static] |
MaxSDK::Util::MaxStringCastUTF8 ToUTF8 | ( | size_t * | length = NULL |
) | const |
static WStr FromUTF8 | ( | const char * | string, |
size_t | length =
(size_t)-1 |
||
) | [static] |
MaxSDK::Util::MaxStringCast<WCHAR> ToOLESTR | ( | size_t * | length = NULL |
) | const |
static WStr FromOLESTR | ( | const wchar_t * | string, |
size_t | length =
(size_t)-1 |
||
) | [static] |
MaxSDK::Util::MaxStringCast<WCHAR> ToUTF16 | ( | size_t * | length = NULL |
) | const |
static WStr FromUTF16 | ( | const wchar_t * | string, |
size_t | length =
(size_t)-1 |
||
) | [static] |
MaxSDK::Util::MaxStringCast<unsigned int> ToUTF32 | ( | size_t * | length = NULL |
) | const |
static WStr FromUTF32 | ( | const unsigned int * | string, |
size_t | length =
(size_t)-1 |
||
) | [static] |
MaxSDK::Util::MaxString ToMaxString | ( | ) | const |
void ToMaxString | ( | MaxSDK::Util::MaxString & | ) | const |
static WStr FromMaxString | ( | MaxSDK::Util::MaxString & | string | ) | [inline, static] |
{ return WStr(string); }
CStr ToCStr | ( | ) | const |
WStr ToWStr | ( | ) | const [inline] |
{ return *this; }
{ return WStr(string); }
MaxSDK::Util::MaxStringCast<char> ToMCHAR | ( | size_t * | length = NULL |
) | const [inline] |
static WStr FromMCHAR | ( | const char * | string, |
size_t | length =
(size_t)-1 |
||
) | [inline, static] |
CStr ToMSTR | ( | ) | const |
bool EndsWith | ( | const WStr & | s, |
bool | caseSensitive =
true |
||
) |
Returns true if the string ends with s; otherwise returns false.
s | The string to be searched. |
caseSensitive | If it is true(default), the search is case sensitive; otherwise the search is case insensitive. |
bool EndsWith | ( | wchar_t | c, |
bool | caseSensitive =
true |
||
) |
Returns true if the string ends with c; otherwise returns false.
This function overloads EndsWith().
c | The character to be searched. |
caseSensitive | If it is true(default), the search is case sensitive; otherwise the search is case insensitive. |
bool StartsWith | ( | const WStr & | s, |
bool | caseSensitive =
true |
||
) |
Returns true if the string starts with s; otherwise returns false.
s | The string to be searched. |
caseSensitive | If it is true(default), the search is case sensitive; otherwise the search is case insensitive. |
bool StartsWith | ( | wchar_t | c, |
bool | caseSensitive =
true |
||
) |
Returns true if the string starts with c; otherwise returns false.
This function overloads StartsWith().
c | The character to be searched. |
caseSensitive | If it is true(default), the search is case sensitive; otherwise the search is case insensitive. |
size_t NumberOfLines | ( | ) | const |
Returns the number of lines inside a string.
size_t Replace | ( | const wchar_t * | pFind, |
const wchar_t * | pReplaceBy, | ||
bool | firstOnly = false , |
||
size_t | startPosition =
0 |
||
) |
Replaces one substring with another in this string.
pFind | The substring to be replaced. |
pReplaceBy | The string the substring is to be replaced with. |
firstOnly | If true, only first occurrence of 'from' is replaced, otherwise all occurrences are replaced |
startPosition | The character position to start searching from |