Tools.h++ Manual
104011 Tandem Computers Incorporated 21-155
21
RWpostream
RWpostream
||
RWvostream ostream
|
RWvios
Synopsis
#include <rw/pstream.h>
// Construct a RWpostream, using cout's streambuf:
RWBostream pstr(cout);
Description Class
RWpostream
specializes the abstract base class
RWvostream
to store
variables in a portable (printable) ASCII format. The results can be restored by
using its counterpart
RWpistream
.
You can think of
RWpistream
and
RWpostream
as an ASCII veneer over an
associated
streambuf
which are responsbile for formatting variables and
escaping characters such that the results can be interchanged between any
machines. As such, they are slower than their binary counterparts
RWbistream
and
RWbostream
which are more machine dependent. Because
RWpistream
and
RWpostream
retain no information about the state of their
associated
streambufs
, their use can be freely exchanged with other users of
the
streambuf
(such as
istream
or
ifstream
).
The goal of class
RWpostream
and
RWpistream
is to store variables using
nothing but printable ASCII characters. Hence, nonprintable characters must
be converted into an external representation where they can be recognized.
Furthermore, other characters may be merely bit values (a bit image, for
example), having nothing to do with characters as symbols. For example,
RWpostream pstrm(cout);
char c = '\n';
pstr << c; // Stores "newline"
pstr.put(c); // Stores the number 10
.
The expression
"pstr << c"
treats
c
as a symbol for a newline, an
unprintable character. The expression
"pstr.put(c)"
treats
c
as the literal
number “10”.