Tools.h++ Manual

8-4 104011 Tandem Computers Incorporated
8
with whitespace, commas, or any other kind of formatting. You are effectively
telling
RWvostream
, “Here is a double. Please store it for me in whatever
format is convenient and give it back to me in good shape when I ask for it”.
The results are extremely powerful. You can not only use, but also write,
streaming operators without knowing anything about the final output medium
or formatting that is to be used. For example, the output medium could be a
disk, memory allocation, or even a network. The formatting could be in binary,
ASCII, or network packet. In all of these cases, the same streaming operators
can be used.
8.1 Specializing virtual streams
The Tools.h++ classes come with three types of classes that specialize
RWvistream
and
RWvostream
. The first uses a “portable ASCII” formatting,
the second a binary formatting, and the third an XDR (eXternal Data
Representation; a Sun Microsytems standard) formatting:
The “portable ASCII” versions store their inserted items in an ASCII format
that escapes special characters such as tabs, newlines, etc., in such a manner
that they will be restored properly, even under a new operating system. The
“binary” versions do not reformat inserted items and, instead, store them in
their native format. The XDR streams send their items to an XDR stream, to be
transmitted remotely over a network.
None of these versions retain any state: they can be freely interchanged with
regular streams (including XDR)—using them does not lock you into doing all
your file I/O with them. For more information, see the respective entries in
Part II: Class Reference.
Table 8-1
Input class Output class
Abstract base class
RWvistream RWvostream
Portable ASCII
RWpistream RWpostream
Binary
RWbistream RWbostream
XDR
RWXDRistream RWXDRostream