Module: Essential Tools Module Group: String Processing Classes
Does not inherit
#include <rw/wstring.h> RWWString s(L"test string"); s(6,3); // "tri"
NOTE -- Use this class instead of RWWSubString only if Technical Support has advised you to do so.
The class RWClassicWSubString allows some subsection of an RWClassicWString to be addressed by defining a starting position and an extent.
For more information, see RWWSubString.
None
#include <rw/rstream.h> #include <rw/wstring.h> main(){ RWClassicWString s(L"What I tell you is true."); // Create a substring and use it as an lvalue: s(16,0) = RWClassicWString(L"three times "); cout << s << endl; return 0; }
Program output:
What I tell you three times is true.
void operator=(const RWClassicWString&); operator=(const RWClassicWSubString&);
Assignment from an RWClassicWString. The statements:
RWClassicWString a; RWClassicWString b; ... b(2, 3) = a;
copy a's data into the substring b(2,3). The number of elements need not match: if they differ, b is resized appropriately. If self is the null substring, then the statement has no effect.
void operator=(const wchar_t*);
Assignment from a wide character string. Example:
RWClassicWString wstr(L"Mary had a little lamb"); wchar_t dat[] = L"Perrier"; wstr(11,4) = dat; // "Mary had a Perrier"
Note that the number of characters selected need not match: if they differ, wstr will be resized appropriately. If self is the null substring, then the statement has no effect.
wchar_t operator[](size_t i); wchar_t& operator[](size_t i) const;
Returns the ith character of the substring. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the length of the substring less one. Bounds checking is performed: if the index is out of range, then an exception of type RWBoundsErr is thrown.
wchar_t operator()(size_t i); wchar_t& operator()(size_t i) const;
Returns the ith character of the substring. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the length of the substring less one. Bounds checking is enabled by defining the pre-processor macro RWBOUNDS_CHECK before including <rw/wstring.h>. In that case, if the index is out of range, then an exception of type RWBoundsErr is thrown.
bool isNull() const;
Returns true if this is a null substring.
size_t length() const;
Returns the extent (length) of the RWClassicWSubString.
bool operator!() const;
Returns true if this is a null substring.
size_t start() const;
Returns the starting element of the RWClassicWSubString.
void toLower();
Changes all upper-case letters in self to lower-case. Uses the C library function towlower().
void toUpper();
Changes all lower-case letters in self to upper-case. Uses the C library function towupper().
bool operator==(const RWClassicWSubString&, const RWClassicWSubString&); bool operator==(const RWClassicWString&, const RWClassicWSubString&); bool operator==(const RWClassicWSubString&, const RWClassicWString& ); bool operator==(const wchar_t*, const RWClassicWSubString&); bool operator==(const RWClassicWSubString&, const wchar_t* );
Returns true if the substring is lexicographically equal to the wide character string or RWClassicWString argument. Case sensitivity is exact.
bool operator!=(const RWClassicWString&, const RWClassicWString& ); bool operator!=(const RWClassicWString&, const RWClassicWSubString&); bool operator!=(const RWClassicWSubString&, const RWClassicWString& ); bool operator!=(const wchar_t*, const RWClassicWString& ); bool operator!=(const RWClassicWString&, const wchar_t* );
Returns the negation of the respective operator==()
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.