Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Tools Module User's Guide

4.7 String I/O

Class RWCString offers a rich I/O facility to and from both iostreams and Rogue Wave virtual streams.

4.7.1 Iostreams

The standard left-shift and right-shift operators have been overloaded to work with iostreams and RWCStrings:

The semantics parallel the operators:

which are defined by the Standard C++ Library that comes with your compiler. In other words, the left-shift operator << writes a null-terminated string to the given output stream. The right-shift operator >> reads a single token, delimited by white space, from the input stream into the RWCString, replacing the previous contents.

Other functions allow finer tuning of RWCString input. Details about methods readFile(); readLine(); readString(istream&); readToDelim(); and readToken() may be found in the RWCString section of the Essential Tools Module Reference Guide. For instance, function readLine() reads strings separated by newlines. It has an optional parameter controlling whether white space is skipped before storing characters. You can see the difference skipping white space makes in the following example:

Program Input:

Program Output:

4.7.2 Virtual Streams

String operators to and from Rogue Wave virtual streams are also supported:

By using these operators, you can save and restore a string without knowing its formatting. See Chapter 5 for details on virtual streams.



Previous fileTop of DocumentContentsIndex pageNext file

©2004 Copyright Quovadx, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Quovadx, 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.