Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Tools Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

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 C++ Standard 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 description of the SourcePro C++ API 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 DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.