Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

RWeistream


...-->ios RWeistream-->RWbistream ... ...-->RWvistream-->RWvios

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Synopsis

#include <rw/estream.h>
RWeistream estr(cin);           // Construct an RWeistream,
                                // using cin's streambuf

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 will 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 will 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 chars 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's failbit will be set.

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

Persistence

None.

Example

See RWeostream for an example of how the file "data.dat" might be created.

#include <rw/estream.h>
#include <fstream.h>
main()
{
 ifstream fstr("data.dat");     // Open an input file
 RWeistream estr(fstr);       // Construct an RWeistream from it
                              // (For DOS: RWeistream estr(fstr, ios::binary)
 int i;
 float f;
 double d;

 estr >> i;                   // Restore an int that was stored in binary,
                             //  without regard to size or endian format.
 estr >> f >> d;             //  Restore a float & double without regard to
                             //  endian formats.
}

Public Constructors

RWeistream(streambuf* s);
RWeistream(istream& str);

Public Member Functions

virtual int
get();
virtual RWvistream&
get(char& c);
virtual RWvistream&
get(unsigned char& c);
virtual RWvistream&
get(char* v, size_t N);
virtual RWvistream&
get(unsigned char* v, size_t N);
virtual RWvistream&
get(wchar_t& wc);
virtual RWvistream&
get(wchar_t* v, size_t N);
virtual RWvistream&
get(double* v, size_t N);
virtual RWvistream&
get(float* v, size_t N);
virtual RWvistream&
get(int* v, size_t N);
virtual RWvistream&
get(long* v, size_t N);
virtual RWvistream&
get(short* v, size_t N);
virtual RWvistream&
get(unsigned short* v, size_t N);
virtual RWvistream&
get(unsigned int* v, size_t N);
virtual RWvistream&
get(unsigned long* v, size_t N);
virtual RWvistream&
getString(char* s, size_t N);
virtual RWvistream&
operator>>(char& c);
virtual RWvistream&
operator>>(wchar_t& wc);
virtual RWvistream&
operator>>(double& d);
virtual RWvistream&
operator>>(float& f);
virtual RWvistream&
operator>>(int& i);
virtual RWvistream&
operator>>(long& l);
virtual RWvistream&
operator>>(short& s);
virtual RWvistream&
operator>>(unsigned char& c);
virtual RWvistream&
operator>>(unsigned short& s);
virtual RWvistream&
operator>>(unsigned int& i);
virtual RWvistream&
operator>>(unsigned long& l);
RWeostream::Endian streamEndian();
size_t
streamSizeofInt();
size_t
streamSizeofLong();
size_t
streamSizeofShort();
size_t
streamSizeofSizeT();
size_t
streamSizeofWchar();


Previous fileTop of documentContentsIndexNext file
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.