Tools.h++ Manual
104011 Tandem Computers Incorporated 21-19
21
RWbistream
RWbistream
||
RWvistream ios
|
RWvios
Synopsis
#include <rw/bstream.h>
RWbistream bstr(cin); // Construct a RWbistream,
// using cin's streambuf
Description Class
RWbistream
specializes the abstract base class
RWvistream
to restore
variables stored in binary format by
RWbostream
.
You can think of it as a binary veneer over an associated streambuf. Because
the
RWbistream
retains no information about the state of its associated
streambuf
, its use can be freely exchanged with other users of the streambuf
(such as an
istream
or
ifstream
).
RWbistream
can be interrogated as to the stream state using member
functions
good(), bad(), eof(),
etc.
Example See
RWbostream
for an example of how the file
"data.dat"
might be
created.
Public constructors
RWbistream(streambuf* s);
Construct a
RWbistream
from the streambuf
s
.
#include <rw/bstream.h>
#include <rw/fstream.h>
main()
{
ifstream fstr("data.dat"); // Open an input file
RWbistream bstr(fstr); // Construct RWbistream from it
int i;
float f;
double d;
bstr >> i; // Restore an int that was stored in binary
bstr >> f >> d; // Restore a float & double}