Tools.h++ Class Reference

Table Of Contents
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_; // Stores the number 10.
The expression "pstr << c" treats c as a symbol for a newline, an unprintable character. The
expression "pstr.put_" treats c as the literal number "10".
Note that variables should not be separated with white space. Such white space would be
interpreted literally and would have to be read back in as a character string.
RWpostream can be interrogated as to the stream state using member functions good(), bad(),
eof(),precision(), etc.
Persistence
None
Example
See RWpistream for an example of how to read back in the results of this program. The symbol
"o" is intended to represent a control-G, or bell.
.cpp
#include <rw/pstream.h>
main(){
// Construct an RWpostream to use standard output:
RWpostream pstr(cout);
int i = 5;
float f = 22.1;
double d = -0.05;
char string[]
= "A string with\ttabs,\nnewlines and a o bell.";
pstr << i; // Store an int in binary
pstr << f << d; // Store a float & double
pstr << string; // Store a string