A separate RWCSubString class supports substring extraction and modification. There are no public constructors; RWCSubStrings are constructed indirectly by various member functions of RWCString, and destroyed at the first opportunity.
You can use substrings in a variety of situations. For example, you can create a substring with RWCString::operator(), then use it to initialize an RWCString:
RWCString s("this is a string"); // Construct an RWCString from a substring: RWCString s2 = s(0, 4); // "this"
The result is a string s2 that contains a copy of the first four characters of s.
You can also use RWSubStrings as lvalues in an assignment to a character string, or to an RWCString or RWCSubString:
// Construct an RWCString: RWCString article("the"); RWCString s("this is a string"); s(0, 4) = "that"; // "that is a string" s(8, 1) = article; // "that is the string"
Note that assignment to a substring is not a conformal operation: the two sides of the assignment operator need not have the same number of characters.
© 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.