SourcePro® API Reference Guide

Product Documentation:
   SourcePro
Documentation Home
List of all members | Public Types | Public Member Functions
RWeostream Class Reference

Specializes the base class RWbostream to store values in a portable binary format. More...

#include <rw/estream.h>

Inheritance diagram for RWeostream:
RWbostream RWvostream RWvios

Public Types

enum  Endian { LittleEndian, BigEndian, HostEndian }
 

Public Member Functions

 RWeostream (std::ostream &str, Endian fmt=HostEndian)
 
 RWeostream (std::streambuf *sb, Endian fmt=HostEndian)
 
virtual RWvostreamflush ()
 
virtual RWvostreamput (char c)
 
virtual RWvostreamput (signed char c)
 
virtual RWvostreamput (unsigned char c)
 
virtual RWvostreamput (wchar_t wc)
 
virtual RWvostreamput (bool b)
 
virtual RWvostreamput (short i)
 
virtual RWvostreamput (unsigned short i)
 
virtual RWvostreamput (int i)
 
virtual RWvostreamput (unsigned int i)
 
virtual RWvostreamput (long i)
 
virtual RWvostreamput (unsigned long i)
 
virtual RWvostreamput (long long i)
 
virtual RWvostreamput (unsigned long long i)
 
virtual RWvostreamput (float f)
 
virtual RWvostreamput (double d)
 
virtual RWvostreamput (long double)
 
virtual RWvostreamput (const char *v, size_t n)
 
virtual RWvostreamput (const signed char *v, size_t n)
 
virtual RWvostreamput (const unsigned char *v, size_t n)
 
virtual RWvostreamput (const wchar_t *v, size_t n)
 
virtual RWvostreamput (const bool *v, size_t n)
 
virtual RWvostreamput (const short *v, size_t n)
 
virtual RWvostreamput (const unsigned short *v, size_t n)
 
virtual RWvostreamput (const int *v, size_t n)
 
virtual RWvostreamput (const unsigned int *v, size_t n)
 
virtual RWvostreamput (const long *v, size_t n)
 
virtual RWvostreamput (const unsigned long *v, size_t n)
 
virtual RWvostreamput (const long long *v, size_t n)
 
virtual RWvostreamput (const unsigned long long *v, size_t n)
 
virtual RWvostreamput (const float *v, size_t n)
 
virtual RWvostreamput (const double *v, size_t n)
 
virtual RWvostreamput (const long double *, size_t)
 
virtual RWvostreamputChar (char c)
 
virtual RWvostreamputChar (signed char c)
 
virtual RWvostreamputChar (unsigned char c)
 
virtual RWvostreamputChar (wchar_t wc)
 
virtual RWvostreamputChars (const char *s, size_t n)
 
virtual RWvostreamputSizeT (size_t sz)
 
virtual RWvostreamputString (const char *s, size_t n)
 
- Public Member Functions inherited from RWbostream
 RWbostream (std::ostream &str)
 
 RWbostream (std::streambuf *sb)
 
virtual int bad ()
 
virtual void clear (int v=0)
 
virtual int eof ()
 
virtual int fail ()
 
virtual int good ()
 
virtual int rdstate ()
 
- Public Member Functions inherited from RWvostream
virtual ~RWvostream ()
 
void version (unsigned v)
 
unsigned version () const
 
- Public Member Functions inherited from RWvios
 operator void * ()
 

Additional Inherited Members

Detailed Description

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.

Synopsis
#include <rw/estream.h>
// Construct an RWeostream that uses cout's streambuf,
// and writes out values in little-endian format
Persistence
None.
Example
#include <iostream>
#include <fstream>
#include <rw/estream.h>
int main()
{
// Open an output file
std::ofstream fstr("data.dat");
// Construct an 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;
}

Member Enumeration Documentation

Specifies the format to use to represent numeric values in the stream.

Enumerator
LittleEndian 

Use little-endian format.

BigEndian 

Use big-endian format.

HostEndian 

Use native format of the current environment.

Constructor & Destructor Documentation

RWeostream::RWeostream ( std::ostream &  str,
Endian  fmt = HostEndian 
)

Constructs an RWeostream from the std::streambuf associated with the std::ostream str. Values placed into the stream have an endian format given by fmt. For DOS, the str must have been opened in binary mode.

Exceptions
RWStreamErrThrown if the underlying std::streambuf is not empty.
RWeostream::RWeostream ( std::streambuf *  sb,
Endian  fmt = HostEndian 
)

Constructs an RWeostream from the std::streambuf s. Values placed into the stream have an endian format given by fmt. For DOS, the std::streambuf s must have been created in binary mode.

Exceptions
RWStreamErrThrown if the std::streambuf sb is not empty.

Member Function Documentation

virtual RWvostream& RWeostream::flush ( )
inlinevirtual

Sends the contents of the stream buffer to output immediately.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( char  c)
inlinevirtual

Stores the char c to the output stream, preserving its value.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( signed char  c)
inlinevirtual

Stores the signed char c to the output stream, preserving its value.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( unsigned char  c)
inlinevirtual

Stores the unsigned char c to the output stream, preserving its value.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( wchar_t  wc)
virtual

Stores the wchar_t wc to the output stream, preserving its value.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( bool  b)
inlinevirtual

Stores the bool b to the output stream.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( short  i)
virtual

Stores the short i to the output stream.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( unsigned short  i)
virtual

Stores the unsigned short i to the output stream.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( int  i)
virtual

Stores the int i to the output stream.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( unsigned int  i)
virtual

Stores the unsigned int i to the output stream.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( long  i)
virtual

Stores the long i to the output stream.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( unsigned long  i)
virtual

Stores the unsigned long i to the output stream.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( long long  i)
virtual

Stores the long long i to the output stream.

Note
This operator function is available only if your compiler supports the long long type.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( unsigned long long  i)
virtual

Stores the unsigned long long i to the output stream.

Note
This operator function is available only if your compiler supports the unsigned long long type.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( float  f)
virtual

Stores the float f to the output stream.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( double  d)
virtual

Stores the double d to the output stream.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( long double  )
inlinevirtual
Exceptions
RWInternalErrThis function is not supported with endian streams.
Note
This operator function is available only if your compiler supports the long double type.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( const char *  v,
size_t  n 
)
inlinevirtual

Stores the vector of n char starting at v to the output stream. The characters should be treated as literal numbers (i.e., not as a character string).

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( const signed char *  v,
size_t  n 
)
inlinevirtual

Stores the vector of n signed char starting at v to the output stream. The characters should be treated as literal numbers (i.e., not as a character string).

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( const unsigned char *  v,
size_t  n 
)
inlinevirtual

Stores the vector of n unsigned char starting at v to the output stream. The characters should be treated as literal numbers (i.e., not as a character string).

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( const wchar_t *  v,
size_t  n 
)
virtual

Stores the vector of n wchar_t starting at v to the output stream. The characters should be treated as literal numbers (i.e., not as a character string).

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( const bool *  v,
size_t  n 
)
inlinevirtual

Stores the vector of n bool starting at v to the output stream.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( const short *  v,
size_t  n 
)
virtual

Stores the vector of n short starting at v to the output stream.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( const unsigned short *  v,
size_t  n 
)
virtual

Stores the vector of n unsigned short starting at v to the output stream.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( const int *  v,
size_t  n 
)
virtual

Stores the vector of n int starting at v to the output stream.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( const unsigned int *  v,
size_t  n 
)
virtual

Stores the vector of n unsigned int starting at v to the output stream.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( const long *  v,
size_t  n 
)
virtual

Stores the vector of n long starting at v to the output stream.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( const unsigned long *  v,
size_t  n 
)
virtual

Stores the vector of n unsigned long starting at v to the output stream.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( const long long *  v,
size_t  n 
)
virtual

Stores the vector of n long long starting at v to the output stream.

Note
This operator function is available only if your compiler supports the long long type.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( const unsigned long long *  v,
size_t  n 
)
virtual

Stores the vector of n unsigned long long starting at v to the output stream.

Note
This operator function is available only if your compiler supports the unsigned long long type.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( const float *  v,
size_t  n 
)
virtual

Stores the vector of n float starting at v to the output stream.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( const double *  v,
size_t  n 
)
virtual

Stores the vector of n double starting at v to the output stream.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::put ( const long double *  ,
size_t   
)
inlinevirtual
Exceptions
RWInternalErrThis function is not supported with endian streams.
Note
This operator function is available only if your compiler supports the long double type.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::putChar ( char  c)
inlinevirtual

Stores the char c to the output stream, preserving its meaning. c is treated as a character.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::putChar ( signed char  c)
inlinevirtual

Stores the signed char c to the output stream, preserving its meaning. c is treated as a character.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::putChar ( unsigned char  c)
inlinevirtual

Stores the unsigned char c to the output stream, preserving its meaning. c is treated as a character.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::putChar ( wchar_t  wc)
inlinevirtual

Stores the wchar_t wc to the output stream, preserving its value. wc is treated as a character.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::putChars ( const char *  s,
size_t  n 
)
virtual

Stores n char starting at s to the output stream.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::putSizeT ( size_t  sz)
virtual

Stores the size_t sz to the output stream.

Reimplemented from RWbostream.

virtual RWvostream& RWeostream::putString ( const char *  s,
size_t  n 
)
virtual

Stores the character string, including embedded nulls, starting at s to the output stream.

Reimplemented from RWbostream.

Copyright © 2021 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.