Module: Essential Tools Module Group: Virtual Stream Classes
...std::ios RWeostream ... ...RWbostreamRWvostreamRWvios
#include <rw/estream.h> // Construct an RWeostream that uses cout's streambuf, // and writes out values in little-endian format: RWeostream estr(std::cout, RWeostream::LittleEndian);
Class RWeostream specializes the base class RWbostream to store values in a portable binary format. The results can be restored via its counterpart, RWeistream.
See the entry for RWeistream for a general description of the endian stream classes.
None.
See RWeistream for an example of how the file "data.dat" might be read.
#include <iostream> #include <fstream> #include <rw/estream.h> int main() { // Open an output file std::ofstream fstr ("data.dat"); // Construct a RWeostream from it RWeostream estr (fstr); int i = 5; float f = 22.1f; double d = -0.05; std::cout << "An integer, a float and a double sent out on a RWeostream!\n"; // Store a float & double estr << i << f << d; return 0; }
Program output:
An integer, a float and a double sent out on a RWeostream!
enum RWeostream::Endian { LittleEndian, BigEndian, HostEndian }
Used to specify the format that RWeostreams should use to represent numeric values in the stream. HostEndian means to use the native format of the current environment.
RWeostream(streambuf* s, Endian fmt = HostEndian);
Construct an RWeostream from the std::streambuf s. Values placed into the stream will have an endian format given by fmt. For DOS, the streambuf must have been created in binary mode. Throw exception RWStreamErr if streambuf s is not empty.
RWeostream(ostream& str, Endian fmt = HostEndian);
Construct an RWeostream from the std::streambuf associated with the output stream str. Values placed into the stream will have an endian format given by fmt. For DOS, the str must have been opened in binary mode. Throw exception RWStreamErr if streambuf s is not empty.
virtual RWvostream& flush();
Send the contents of the stream buffer to output immediately.
virtual RWvostream& operator<<(const char* s);
Redefined from class RWbostream. Store the character string starting at s to the output stream. The character string is expected to be null terminated. Note that the elements of s are treated as characters, not as numbers.
virtual RWvostream& operator<<(char c);
Redefined from class RWbostream. Store the char c to the output stream. Note that c is treated as a character, not a number.
virtual RWvostream& operator<<(wchar_t wc);
Redefined from class RWbostream. Store the wchar_t wc to the output stream in binary, using the appropriate endian representation.
virtual RWvostream& operator<<(unsigned char c);
Redefined from class RWbostream. Store the unsigned char c to the output stream. Note that c is treated as a character, not a number.
virtual RWvostream& operator<<(double d);
Redefined from class RWbostream. Store the double d to the output stream in binary, using the appropriate endian representation.
virtual RWvostream& operator<<(float f);
Redefined from class RWbostream. Store the float f to the output stream in binary, using the appropriate endian representation.
virtual RWvostream& operator<<(int i);
Redefined from class RWbostream. Store the int i to the output stream in binary, using the appropriate endian representation.
virtual RWvostream& operator<<(unsigned int i);
Redefined from class RWbostream. Store the unsigned int i to the output stream in binary, using the appropriate endian representation.
virtual RWvostream& operator<<(long l);
Redefined from class RWbostream. Store the long l to the output stream in binary, using the appropriate endian representation.
virtual RWvostream& operator<<(long long l);
Redefined from class RWbostream. Store the long long l to the output stream in binary, using the appropriate endian representation. Note: This operator function is available only if your compiler supports the long long l type.
virtual RWvostream& operator<<(unsigned long l);
Redefined from class RWbostream. Store the unsigned long l to the output stream in binary, using the appropriate endian representation.
virtual RWvostream& operator<<(unsigned long long l);
Redefined from class RWbostream. Store the unsigned long long l to the output stream in binary, using the appropriate endian representation. Note: This operator function is available only if your compiler supports the unsigned long long l type.
virtual RWvostream& operator<<(short s);
Redefined from class RWbostream. Store the short s to the output stream in binary, using the appropriate endian representation.
virtual RWvostream& operator<<(unsigned short s);
Redefined from class RWbostream. Store the unsigned short s to the output stream in binary, using the appropriate endian representation.
virtual RWvostream& put(char c); virtual RWvostream& put(unsigned char c); virtual RWvostream& put(const char* p, size_t N);
Inherited from class RWbostream.
virtual RWvostream& put(wchar_t wc);
Redefined from class RWbostream. Store the wchar_t wc to the output stream in binary, using the appropriate endian representation.
virtual RWvostream& put(const wchar_t* p, size_t N);
Redefined from class RWbostream. Store the vector of wchar_ts starting at p to the output stream in binary, using the appropriate endian representation.
virtual RWvostream& put(const unsigned char* p, size_t N);
Redefined from class RWbostream. Store the vector of unsigned chars starting at p to the output stream in binary, using the appropriate endian representation.
virtual RWvostream& put(const short* p, size_t N);
Redefined from class RWbostream. Store the vector of shorts starting at p to the output stream in binary, using the appropriate endian representation.
virtual RWvostream& put(const unsigned short* p, size_t N);
Redefined from class RWbostream. Store the vector of unsigned shorts starting at p to the output stream in binary, using the appropriate endian representation.
virtual RWvostream& put(const int* p, size_t N);
Redefined from class RWbostream. Store the vector of ints starting at p to the output stream in binary, using the appropriate endian representation.
virtual RWvostream& put(const unsigned int* p, size_t N);
Redefined from class RWbostream. Store the vector of unsigned ints starting at p to the output stream in binary, using the appropriate endian representation.
virtual RWvostream& put(const long* p, size_t N);
Redefined from class RWbostream. Store the vector of longs starting at p to the output stream in binary, using the appropriate endian representation.
virtual RWvostream& put(const long long* p, size_t N);
Redefined from class RWbostream. Store the vector of long longs starting at p to the output stream in binary, using the appropriate endian representation.
NOTE -- This operator function is available only if your compiler supports the long long type.
virtual RWvostream& put(const unsigned long* p, size_t N);
Redefined from class RWbostream. Store the vector of unsigned longs starting at p to the output stream in binary, using the appropriate endian representation.
virtual RWvostream& put(const unsigned long long* p, size_t N);
Redefined from class RWbostream. Store the vector of unsigned long longs starting at p to the output stream in binary, using the appropriate endian representation.
NOTE -- This operator function is available only if your compiler supports the unsigned long long type.
virtual RWvostream& put(const float* p, size_t N);
Redefined from class RWbostream. Store the vector of floats starting at p to the output stream in binary, using the appropriate endian representation.
virtual RWvostream& put(const double* p, size_t N);
Redefined from class RWbostream. Store the vector of doubles starting at p to the output stream in binary, using the appropriate endian representation.
virtual RWvostream& put(const long double* p, size_t N);
Redefined from class RWbostream. Store the vector of long doubles starting at p to the output stream in binary, using the appropriate endian representation. Note: This operator function is available only if your compiler supports the long double type.
virtual RWvostream& putString(const char*s, size_t N);
Store the character string, including embedded nulls, starting at s to the output string.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.