SourcePro® API Reference Guide

 
List of all members | Public Member Functions
RWeistream Class Reference

Specializes the base class RWbistream to restore values previously stored by RWeostream. More...

#include <rw/estream.h>

Inheritance diagram for RWeistream:
RWbistream RWvistream RWvios

Public Member Functions

 RWeistream (std::istream &str)
 
 RWeistream (std::streambuf *sb)
 
virtual int get ()
 
virtual RWvistreamget (char &c)
 
virtual RWvistreamget (signed char &c)
 
virtual RWvistreamget (unsigned char &c)
 
virtual RWvistreamget (wchar_t &wc)
 
virtual RWvistreamget (bool &b)
 
virtual RWvistreamget (short &i)
 
virtual RWvistreamget (unsigned short &i)
 
virtual RWvistreamget (int &i)
 
virtual RWvistreamget (unsigned int &i)
 
virtual RWvistreamget (long &i)
 
virtual RWvistreamget (unsigned long &i)
 
virtual RWvistreamget (long long &i)
 
virtual RWvistreamget (unsigned long long &i)
 
virtual RWvistreamget (float &f)
 
virtual RWvistreamget (double &d)
 
virtual RWvistreamget (long double &)
 
virtual RWvistreamget (char *v, size_t n)
 
virtual RWvistreamget (signed char *v, size_t n)
 
virtual RWvistreamget (unsigned char *v, size_t n)
 
virtual RWvistreamget (wchar_t *v, size_t n)
 
virtual RWvistreamget (bool *v, size_t n)
 
virtual RWvistreamget (short *v, size_t n)
 
virtual RWvistreamget (unsigned short *v, size_t n)
 
virtual RWvistreamget (int *v, size_t n)
 
virtual RWvistreamget (unsigned int *v, size_t n)
 
virtual RWvistreamget (long *v, size_t n)
 
virtual RWvistreamget (unsigned long *v, size_t n)
 
virtual RWvistreamget (long long *v, size_t n)
 
virtual RWvistreamget (unsigned long long *v, size_t n)
 
virtual RWvistreamget (float *v, size_t n)
 
virtual RWvistreamget (double *v, size_t n)
 
virtual RWvistreamget (long double *, size_t)
 
virtual RWvistreamgetChar (char &c)
 
virtual RWvistreamgetChar (signed char &c)
 
virtual RWvistreamgetChar (unsigned char &c)
 
virtual RWvistreamgetChar (wchar_t &wc)
 
virtual RWvistreamgetChars (char *s, size_t n)
 
virtual RWvistreamgetSizeT (size_t &sz)
 
virtual RWvistreamgetString (char *s, size_t n)
 
RWeostream::Endian streamEndian ()
 
size_t streamSizeofInt ()
 
size_t streamSizeofLong ()
 
size_t streamSizeofShort ()
 
size_t streamSizeofSizeT ()
 
size_t streamSizeofWchar ()
 
- Public Member Functions inherited from RWbistream
 RWbistream (std::istream &str)
 
 RWbistream (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 RWvistream
virtual ~RWvistream ()
 
void version (unsigned v)
 
unsigned version () const
 
- Public Member Functions inherited from RWvios
 operator void * ()
 

Additional Inherited Members

Detailed Description

Class RWeistream specializes the base class RWbistream to restore values previously stored by RWeostream. Please note, RWeostream must be opened before RWeistream, or the application does not function properly.

The endian streams, RWeistream and RWeostream, offer an efficient compromise between the portable streams (RWpistream, RWpostream) and the binary streams (RWbistream, RWbostream). By compensating for differences in big-endian vs. little-endian formats, as well as sizes of the various integral types, the endian streams offer portability without incurring the stream-size overhead of translating values into a series of printable characters. For example, data stored in little-endian format by an RWeostream object in a DOS program can be retrieved by an RWeistream object on any of several machines, regardless of its native endian format or the sizes of its integral types. Endian streams work properly when shared among a group of platforms that:

As with the portable streams, care must be taken when storing or retrieving variables of type char. Endian stream methods treat char types as numbers except where the method description explicitly states that the char is being treated, instead, as a character. See the entry for RWpostream for an example of this distinction.

Data stored in an integral type on one platform may be too large to fit into that type on a receiving platform. If so, the RWeistream class' failbit is set.

Endian streams can be interrogated as to their stream state using member functions good(), bad(), eof(), etc.

Synopsis
#include <rw/estream.h>
RWeistream estr(cin); // Construct an RWeistream using cin's streambuf
Persistence
None.
Example
#include <iostream>
#include <fstream>
#include <rw/estream.h>
int main()
{
// Open an input file
std::ifstream fstr("data.dat");
// Construct RWeistream from it
RWeistream estr(fstr);
int i;
float f;
double d;
// Restore an int that was stored in binary
if(!(estr >> i))
{
std::cout << "Run eostream.exe first!" << std::endl;
}
else
{
// Restore a float & double
estr >> f >> d;
std::cout << "The integer: " << i << std::endl;
std::cout << "The float: " << f << std::endl;
std::cout << "The double: " << d << std::endl;
}
return 0;
}

Constructor & Destructor Documentation

RWeistream::RWeistream ( std::istream &  str)

Constructs an RWeistream from the std::streambuf associated with the std::istream str. For DOS, str must have been created in binary mode.

Exceptions
RWStreamErrThrown if the data in str does not describe a valid endian stream.
RWeistream::RWeistream ( std::streambuf *  sb)

Constructs an RWeistream from the std::streambuf sb. For DOS, this std::streambuf must have been created in binary mode.

Exceptions
RWStreamErrThrown if the data in sb does not describe a valid endian stream.

Member Function Documentation

virtual int RWeistream::get ( )
inlinevirtual

Gets and returns the next byte from the input stream, returning its value. Returns EOF if end of file is encountered.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( char &  c)
inlinevirtual

Gets the next char from the input stream, returning its value in c.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( signed char &  c)
inlinevirtual

Gets the next signed char from the input stream, returning its value in c.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( unsigned char &  c)
inlinevirtual

Gets the next unsigned char from the input stream, returning its value in c.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( wchar_t &  wc)
virtual

Gets the next wchar_t from the input stream, returning its value in wc.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( bool &  b)
inlinevirtual

Gets the next bool from the input stream, returning its value in b.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( short &  i)
virtual

Gets the next short from the input stream, returning its value in i.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( unsigned short &  i)
virtual

Gets the next unsigned short from the input stream, returning its value in i.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( int &  i)
virtual

Gets the next int from the input stream, returning its value in i.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( unsigned int &  i)
virtual

Gets the next unsigned int from the input stream, returning its value in i.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( long &  i)
virtual

Gets the next long from the input stream, returning its value in i.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( unsigned long &  i)
virtual

Gets the next unsigned long from the input stream, returning its value in i.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( long long &  i)
virtual

Gets the next long long from the input stream, returning its value in i.

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

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( unsigned long long &  i)
virtual

Gets the next unsigned long long from the input stream, returning its value in i.

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

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( float &  f)
virtual

Gets the next float from the input stream, returning its value in f.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( double &  d)
virtual

Gets the next double from the input stream, returning its value in d.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( 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 RWbistream.

virtual RWvistream& RWeistream::get ( char *  v,
size_t  n 
)
inlinevirtual

Gets a vector of n char and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Note
This method retrieves raw characters and does not perform any conversions on special characters such as '\n'.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( signed char *  v,
size_t  n 
)
inlinevirtual

Gets a vector of n signed char and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( unsigned char *  v,
size_t  n 
)
inlinevirtual

Gets a vector of n unsigned char and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( wchar_t *  v,
size_t  n 
)
virtual

Gets a vector of n wchar_t and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Note
This method retrieves raw characters and does not perform any conversions on special characters such as L'\n'.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( bool *  v,
size_t  n 
)
inlinevirtual

Gets a vector of n bool and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( short *  v,
size_t  n 
)
virtual

Gets a vector of n short and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( unsigned short *  v,
size_t  n 
)
virtual

Gets a vector of n unsigned short and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( int *  v,
size_t  n 
)
virtual

Gets a vector of n int and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( unsigned int *  v,
size_t  n 
)
virtual

Gets a vector of n unsigned int and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( long *  v,
size_t  n 
)
virtual

Gets a vector of n long and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( unsigned long *  v,
size_t  n 
)
virtual

Gets a vector of n unsigned long and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( long long *  v,
size_t  n 
)
virtual

Gets a vector of n long long and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

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

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( unsigned long long *  v,
size_t  n 
)
virtual

Gets a vector of n unsigned long long and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

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

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( float *  v,
size_t  n 
)
virtual

Gets a vector of n float and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( double *  v,
size_t  n 
)
virtual

Gets a vector of n double and stores them in the array beginning at v. If the restore operation stops prematurely because there is no more data available on the stream, because an exception is thrown, or for some other reason, stores what has already been retrieved from the stream into v, and sets the failbit.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::get ( long double *  ,
size_t   
)
inlinevirtual
Exceptions
RWInternalErrThis function is not supported with endian streams.
Note
This method is available only if your compiler supports the long double type.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::getChar ( char &  c)
inlinevirtual

Gets the next char from the input stream, returning its value in c. c is treated as a character.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::getChar ( signed char &  c)
inlinevirtual

Gets the next signed char from the input stream, returning its value in c. c is treated as a character.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::getChar ( unsigned char &  c)
inlinevirtual

Gets the next unsigned char from the input stream, returning its value in c. c is treated as a character.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::getChar ( wchar_t &  wc)
inlinevirtual

Gets the next wchar_t from the input stream, returning its value in wc. wc is treated as a character.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::getChars ( char *  s,
size_t  n 
)
virtual

Restores n char from the input stream into the array beginning at s. The function stops reading after n char. The resulting buffer is not null terminated.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::getSizeT ( size_t &  sz)
virtual

Gets the next size_t value from the input stream, returning its value in sz.

Reimplemented from RWbistream.

virtual RWvistream& RWeistream::getString ( char *  s,
size_t  n 
)
virtual

Restores a character string from the input stream that has been stored to the output stream using RWvostream::putString(), then saves it in the array beginning at s. The function stops reading at the end of the string or after n - 1 characters, whichever comes first. If n - 1 characters have been read and the nth character is not the string terminator, then sets the failbit of the stream. In either case, the string is terminated with a null byte.

Reimplemented from RWbistream.

RWeostream::Endian RWeistream::streamEndian ( )
inline

Returns the endian format (RWeostream::BigEndian or RWeostream::LittleEndian) of numeric values, as represented in the stream.

size_t RWeistream::streamSizeofInt ( )
inline

Returns the size of int, as represented in the stream.

size_t RWeistream::streamSizeofLong ( )
inline

Returns the size of long, as represented in the stream.

size_t RWeistream::streamSizeofShort ( )
inline

Returns the size of short, as represented in the stream.

size_t RWeistream::streamSizeofSizeT ( )
inline

Returns the size of size_t, as represented in the stream.

size_t RWeistream::streamSizeofWchar ( )
inline

Returns the size of wchar_t, as represented in the stream.

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