Tools.h++ Manual
5-8 104011 Tandem Computers Incorporated
5
Program output:
2 lines, skipping whitespace.
5 lines, not skipping whitespace.
Virtual streams
String operators to and from virtual streams are also supported:
RWvistream&operator>>(RWvistream& vstream, RWCString&
cstr);
RWvostream&operator<<(RWvostream& vstream, const
RWCString& cstr);
This allows a string to be saved and restored without knowing the formatting
that is to be used. See Chapter 16, “Persistence” for details on virtual streams.
5.6 Tokenizer
Class
RWCTokenizer
can be used to break a string up into tokens, separated
by an arbitrary "white space". See Part 2: Class Reference, under
RWCTokenizer
, for additional details. Here's an example:
#include <rw/ctoken.h>
#include<rw/cstring.h>
#include <rw/rstream.h>
main()
{
RWCString a("a string with five tokens");
RWCTokenizer next(a);
int i = 0;
// Advance until the null string is returned:
while( !next().isNull() ) i++;