RWvostream RWiosRWvios RWbostream ios
Member Functions | ||
flush() operator void*() |
operator<<() put() |
putString() |
#include <rw/bstream.h> // Construct an RWbostream, using cout's streambuf: RWbostream bstr(cout);
Class RWbostream specializes the abstract base class RWvostream to store variables in binary format. The results can be restored by using its counterpart, RWbistream.
You can think of RWbostream as a binary veneer over an associated streambuf. Because the RWbostream retains no information about the state of its associated streambuf, its use can be freely exchanged with other users of the streambuf, such as ostream or ofstream.
NOTE:Variables should not be separated with white space. Such white space is interpreted literally and is read back in as a character string.
RWbostream can be interrogated as to the stream state using member functions good(), bad(), eof(), and so on.
See RWbistream for an example of how the file "data.dat" might be read back in.
#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 }
RWbostream(streambuf* s);
Constructs an RWbostream from the streambuf s. For DOS, the streambuf must have been opened in binary mode.
RWbostream(ostream& str);
Constructs an RWbostream from the streambuf associated with the output stream str. For DOS, the streambuf must have been opened in binary mode. This can be done by specifying ios::binary as part of the second argument to the constructor for an ofstream. Using the example above, the line to create the ofstream would read:
ofstream fstr("data.dat", ios::out | ios::binary);
where the | is the binary OR operator.
virtual ~RWvostream();
Virtual destructor. Allows specializing classes to deallocate any resources that they have allocated.
virtual RWvostream& operator<<(const char* s);
Redefined from class RWvostream. Stores 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. Stores the wide character string starting at ws to the output stream in binary. The wide character string is expected to be null terminated.
virtual RWvostream& operator<<(char c);
Redefined from class RWvostream. Stores the char c to the output stream in binary.
virtual RWvostream& operator<<(wchar_t wc);
Redefined from class RWvostream. Stores the wide char wc to the output stream in binary.
virtual RWvostream& operator<<(unsigned char c);
Redefined from class RWvostream. Stores the unsigned char c to the output stream in binary.
virtual RWvostream& operator<<(double d);
Redefined from class RWvostream. Stores the double d to the output stream in binary.
virtual RWvostream& operator<<(float f);
Redefined from class RWvostream. Stores the float f to the output stream in binary.
virtual RWvostream& operator<<(int i);
Redefined from class RWvostream. Stores the int i to the output stream in binary.
virtual RWvostream& operator<<(unsigned int i);
Redefined from class RWvostream. Stores the unsigned int i to the output stream in binary.
virtual RWvostream& operator<<(long l);
Redefined from class RWvostream. Stores the long l to the output stream in binary.
virtual RWvostream& operator<<(unsigned long l);
Redefined from class RWvostream. Stores the unsigned long l to the output stream in binary.
virtual RWvostream& operator<<(short s);
Redefined from class RWvostream. Stores the short s to the output stream in binary.
virtual RWvostream& operator<<(unsigned short s);
Redefined from class RWvostream. Stores the unsigned short s to the output stream in binary.
operator void*();
Inherited via RWvostream from RWvios.
virtual RWvostream& flush();
Sends the contents of the stream buffer to output immediately.
virtual RWvostream& put(char c);
Redefined from class RWvostream. Stores the char c to the output stream.
virtual RWvostream& put(wchar_t wc);
Redefined from class RWvostream. Stores the wide character wc to the output stream.
virtual RWvostream& put(unsigned char c);
Redefined from class RWvostream. Stores the unsigned char c to the output stream.
virtual RWvostream& put(const char* p, size_t N);
Redefined from class RWvostream. Stores the vector of chars starting at p to the output stream in binary.
virtual RWvostream& put(const wchar_t* p, size_t N);
Redefined from class RWvostream. Stores the vector of wide chars starting at p to the output stream in binary.
virtual RWvostream& put(const unsigned char* p, size_t N);
Redefined from class RWvostream. Stores the vector of unsigned chars starting at p to the output stream in binary.
virtual RWvostream& put(const short* p, size_t N);
Redefined from class RWvostream. Stores the vector of shorts starting at p to the output stream in binary.
virtual RWvostream& put(const unsigned short* p, size_t N);
Redefined from class RWvostream. Stores the vector of unsigned shorts starting at p to the output stream in binary.
virtual RWvostream& put(const int* p, size_t N);
Redefined from class RWvostream. Stores the vector of ints starting at p to the output stream in binary.
virtual RWvostream& put(const unsigned int* p, size_t N);
Redefined from class RWvostream. Stores the vector of unsigned ints starting at p to the output stream in binary.
virtual RWvostream& put(const long* p, size_t N);
Redefined from class RWvostream. Stores the vector of longs starting at p to the output stream in binary.
virtual RWvostream& put(const unsigned long* p, size_t N);
Redefined from class RWvostream. Stores the vector of unsigned longs starting at p to the output stream in binary.
virtual RWvostream& put(const float* p, size_t N);
Redefined from class RWvostream. Stores the vector of floats starting at p to the output stream in binary.
virtual RWvostream& put(const double* p, size_t N);
Redefined from class RWvostream. Stores the vector of doubles starting at p to the output stream in binary.
virtual RWvostream& putString(const char* p, size_t N);
Redefined from class RWvostream. Data is formatted as a string containing N characters.
virtual RWvostream& putString(const char*s, size_t N);
Stores the character string, including embedded nulls, starting at s to the output string.
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.