Tools.h++ Manual
104011 Tandem Computers Incorporated 21-31
21
Example See
RWbistream
for an example of how the file "data.dat" might be read back
in.
Public constructors
RWbostream(streambuf* s);
Construct a
RWbostream
from the
streambuf s
.
RWbostream(ostream& str);
Construct a
RWbostream
from the
streambuf
associated with the output
stream
str
.
Public member functions
virtual RWvostream& operator<<(const char* s);
Redefined from class
RWvostream
. Store the character string starting at s to
the output stream in binary. The character string is expected to be null
terminated.
virtual RWvostream& operator<<(const wchar_t* ws);
Redefined from class
RWvostream
. Store the wide character string starting at
ws
to the output stream in binary. The character string is expected to be null
terminated.
virtual RWvostream& operator<<(char c);
Redefined from class
RWvostream
. Store the
char c
to the output stream in
binary.
virtual RWvostream& operator<<(wchar_t wc);
Redefined from class
RWvostream
. Store the wide
char wc
to the output
stream in binary.
#include <rw/bstream.h>
#include <fstream.h>
main()
{
ofstream fstr("data.dat"); // Open an output file
RWbostream bstr(fstr); // Construct an RWbostream from it
int i = 5;
float f = 22.1;
double d = -0.05;
bstr << i; // Store an int in binary
bstr << f << d; // Store a float & double}