Tools.h++ Manual

21-218 104011 Tandem Computers Incorporated
21
RWWSubString
Synopsis
#include <rw/wstring.h>
RWWString s(L"test string");
s(6,3); // "tri"
Description The class
RWWSubString
allows some subsection of a
RWWString
to be
addressed by defining a starting position and an extent. For example the 7'th
through the 11'th elements, inclusive, would have a starting position of 7 and
an extent of 5. The specification of a starting position and extent can also be
done in your behalf by such functions as
RWWString::strip()
or the
overloaded function call operator taking a regular expression as an argument.
There are no public constructors—
RWWSubStrings
are constructed by various
functions of the
RWWString
class and then destroyed immediately.
A zero lengthed substring is one with a defined starting position and an extent
of zero. It can be thought of as starting just before the indicated character, but
not including it. It can be used as an lvalue. A null substring is also legal and
is frequently used to indicate that a requested substring, perhaps through a
search, does not exist. A null substring can be detected with member function
isNull()
. However, it cannot be used as an lvalue.
Example
Program output:
What I tell you is three times true.
#include <rw/rstream.h>
#include <rw/wstring.h>
main()
{
RWWString s(L"What I tell you is true.");
// Create a substring and use it as an lvalue:
s(19,0) = RWWString(L"three times");
cout << s << endl;
return 0;
}