Module: Essential Tools Module Group: String Processing Classes
Does not inherit
#include <rw/tools/nostl/cstring.h> RWCString a;
NOTE -- Use this class instead of RWCSubString only if Technical Support has advised you to do so.
The class RWClassicCSubString allows some subsection of an RWClassicCString to be addressed by defining a starting position and an extent.
For more information, see RWCSubString.
None
#include <iostream> #include <rw/cstring.h> int main() { RWCString s ("What I tell you is true."); std::cout << "Take the string: [" << s << "]\n"; // Create a substring and use it as an lvalue: s(16, 0) = "three times "; std::cout << "After assigning text to a substring, it becomes: [" << s << "]" << std::endl; return 0; }
Program output:
Take the string: [What I tell you is true.] After assigning text to a substring, it becomes: [What I tell you three times is true.]
RWClassicCSubString& operator=(const RWClassicCString&);
Assignment from an RWClassicCString. The statements:
RWClassicCString a; RWClassicCString b; ... b(2, 3) = a;
will copy a's data into the substring b(2,3). The number of elements need not match: if they differ, b will be resized appropriately. Sets self's extent to be the length of the assigned RWClassicCString. If self is the null substring, then the statement has no effect. Returns a reference to self.
RWClassicCSubString& operator=(const RWClassicCSubString&);
Assignment from an RWClassicCSubString. The statements:
RWClassicCString a; RWClassicCString b; ... b(2, 3) = a(5,5);
will copy 5 characters of a's data into the substring b(2,3). The number of elements need not match: if they differ, b will be resized appropriately. Sets self's extent to be the extent of the assigned RWClassicCSubString. If self is the null substring, then the statement has no effect. Returns a reference to self.
RWClassicCSubString& operator=(const char*);
Assignment from a character string. Example:
RWClassicCString str("Mary had a lamb"); char dat[] = "Perrier"; str(11,4) = dat; // "Mary had a Perrier"
Note that the number of characters selected need not match: if they differ, str will be resized appropriately. Sets self's extent to be the strlen() of the assigned character string. If self is the null substring, then the statement has no effect. Returns a reference to self.
char& operator[](size_t i); char 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 will occur.
char& operator()(size_t i); char 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. Enable bounds checking by defining the pre-processor macro RWBOUNDS_CHECK before including <rw/cstring.h>. In this case, if the index is out of range, then an exception of type RWBoundsErr will occur.
bool isNull() const;
Returns true if this is a null substring.
size_t length() const;
Returns the extent (i.e., length) of the RWClassicCSubString.
int operator!() const;
Returns true if this is a null substring.
size_t start() const;
Returns the starting element of the RWClassicCSubString.
void toLower();
Changes all upper-case letters in self to lower-case. Uses the standard C library function tolower().
void toUpper();
Changes all lower-case letters in self to upper-case. Uses the standard C library function toupper().
bool operator==(const RWClassicCSubString&, const RWClassicCSubString&); bool operator==(const RWClassicCString&, const RWClassicCSubString&); bool operator==(const RWClassicCSubString&, const RWClassicCString& ); bool operator==(const char*, const RWClassicCSubString&); bool operator==(const RWClassicCSubString&, const char* );
Returns true if the substring is lexicographically equal to the character string or RWClassicCString argument. Case sensitivity is exact.
bool operator!=(const RWClassicCString&, const RWClassicCString& ); bool operator!=(const RWClassicCString&, const RWClassicCSubString&); bool operator!=(const RWClassicCSubString&, const RWClassicCString& ); bool operator!=(const char*, const RWClassicCString& ); bool operator!=(const RWClassicCString&, const char* );
bool operator==(const RWClassicCSubString&, const RWClassicCSubString&); bool operator==(const RWClassicCString&, const RWClassicCSubString&); bool operator==(const RWClassicCSubString&, const RWClassicCString& ); bool operator==(const char*, const RWClassicCSubString&); bool operator==(const RWClassicCSubString&, const char* );
Returns true if the substring is lexicographically equal to the character string or RWClassicCString argument. Case sensitivity is exact.
bool operator!=(const RWClassicCString&, const RWClassicCString& ); bool operator!=(const RWClassicCString&, const RWClassicCSubString&); bool operator!=(const RWClassicCSubString&, const RWClassicCString& ); bool operator!=(const char*, const RWClassicCString& ); bool operator!=(const RWClassicCString&, const char* );
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.