RWeistream(3C++) RWeistream(3C++)
NameRWeistream - Rogue Wave library class
Synopsis
#include <rw/estream.h>
RWeistreamestr(cin); // Construct an RWeistream, // using cin's streambuf
Description
Class RWeistream specializes the base class RWbistream to restore values
previously stored by RWeostream. 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:
Share a common size and representation (apart from endian format)
for types float and double;
Use two's complement format for negative integral values.
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
Page 1
RWeistream(3C++) RWeistream(3C++)
created.
Public Constructors
RWeistream(streambuf* s);
Construct an RWeistream from the streambuf s. For DOS, this streambuf
must have been created in binary mode. Throw exception RWStreamErr if
not a valid endian stream.
RWeistream(istream& str);
Construct an RWeistream using the streambuf associated with the istream
str. For DOS, the str must have been opened in binary mode. Throw
exception RWStreamErr if not a valid endian stream.
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);
Inherited from class RWbistream.
virtual RWvistream&
get(wchar_t& wc);
Redefined from class RWbistream. Get the next wchar_t from the input
stream and store it in wc, compensating for any differences in size or
endian format between the stream and the current environment. Set the
failbit if the value in the stream is too large to be stored in wc.
virtual RWvistream&
get(wchar_t* v, size_t N);
Redefined from class RWbistream. Get a vector of wchar_ts and store it
in the array beginning at v, compensating for any differences in size or
endian format between the stream and the current environment. If the
restore stops prematurely, store whatever possible in v, and set the
failbit. Also set the failbit if any values in the stream are too large
to be stored in an element of v.
Page 2
RWeistream(3C++) RWeistream(3C++)
virtual RWvistream&
get(double* v, size_t N);
Redefined from class RWbistream. Get a vector of doubles and store them
in the array beginning at v, compensating for any difference in endian
format between the stream and the current environment. If the restore
stops prematurely, store whatever possible in v, and set the failbit.
virtual RWvistream&
get(float* v, size_t N);
Redefined from class RWbistream. Get a vector of floats and store them
in the array beginning at v, compensating for any difference in endian
format between the stream and the current environment. If the restore
stops prematurely, store whatever possible in v, and set the failbit.
virtual RWvistream&
get(int* v, size_t N);
Redefined from class RWbistream. Get a vector of ints and store them in
the array beginning at v, compensating for any differences in size or
endian format between the stream and the current environment. If the
restore stops prematurely, store whatever possible in v, and set the
failbit. Also set the failbit if any values in the stream are too large
to be stored in an element of v.
virtual RWvistream&
get(long* v, size_t N);
Redefined from class RWbistream. Get a vector of longs and store them in
the array beginning at v, compensating for any differences in size or
endian format between the stream and the current environment. If the
restore stops prematurely, store whatever possible in v, and set the
failbit. Also set the failbit if any values in the stream are too large
to be stored in an element of v.
virtual RWvistream&
get(short* v, size_t N);
Redefined from class RWbistream. Get a vector of shorts and store them
in the array beginning at v, compensating for any differences in size or
endian format between the stream and the current environment. If the
restore stops prematurely, store whatever possible in v, and set the
failbit. Also set the failbit if any values in the stream are too large
to be stored in an element of v.
Page 3
RWeistream(3C++) RWeistream(3C++)
virtual RWvistream&
get(unsigned short* v, size_t N);
Redefined from class RWbistream. Get a vector of unsigned shorts and
store them in the array beginning at v. If the restore stops
prematurely, store whatever possible in v, and set the failbit. Also set
the failbit if any values in the stream are too large to be stored in an
element of v.
virtual RWvistream&
get(unsigned int* v, size_t N);
Redefined from class RWbistream. Get a vector of unsigned ints and store
them in the array beginning at v, compensating for any differences in
size or endian format between the stream and the current environment. If
the restore stops prematurely, store whatever possible in v, and set the
failbit. Also set the failbit if any values in the stream are too large
to be stored in an element of v.
virtual RWvistream&
get(unsigned long* v, size_t N);
Redefined from class RWbistream. Get a vector of unsigned longs and
store them in the array beginning at v, compensating for any differences
in size or endian format between the stream and the current environment
If the restore stops prematurely, store whatever possible in v, and set
the failbit. Also set the failbit if any values in the stream are too
large to be stored in an element of v.
virtual RWvistream&
getString(char* s, size_t N);
Redefined from class RWbistream. Restores a character string from the
input stream and stores 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 the latter, then the failbit of the stream will be set,
and the remaining characters of the string will be extracted from the
stream and thrown away. In either case, the string will be terminated
with a null byte. If the size of the string is too large to be
represented by a variable of type size_t in the current environment, the
badbit of the stream will be set, and no characters will be extracted.
Note that the elements of the string are treated as characters, not
numbers.
virtual RWvistream&
operator>>(char& c);
Page 4
RWeistream(3C++) RWeistream(3C++)
Redefined from class RWbistream. Get the next char from the input stream
and store it in c. Note that c is treated as a character, not a number.
virtual RWvistream&
operator>>(wchar_t& wc);
Redefined from class RWbistream. Get the next wchar_t from the input
stream and store it in wc, compensating for any differences in size or
endian format between the stream and the current environment. Set the
failbit if the value in the stream is too large to be stored in wc.
virtual RWvistream&
operator>>(double& d);
Redefined from class RWbistream. Get the next double from the input
stream and store it in d, compensating for any difference in endian
format between the stream and the current environment.
virtual RWvistream&
operator>>(float& f);
Redefined from class RWbistream. Get the next float from the input
stream and store it in f, compensating for any difference in endian
format between the stream and the current environment.
virtual RWvistream&
operator>>(int& i);
Redefined from class RWbistream. Get the next int from the input stream
and store it in i, compensating for any differences in size or endian
format between the stream and the current environment. Set the failbit
if the value in the stream is too large to be stored in i.
virtual RWvistream&
operator>>(long& l);
Redefined from class RWbistream. Get the next long from the input stream
and store it in l, compensating for any differences in size or endian
format between the stream and the current environment. Set the failbit
if the value in the stream is too large to be stored in l.
virtual RWvistream&
operator>>(short& s);
Redefined from class RWbistream. Get the next short from the input
stream and store it in s, compensating for any differences in size or
Page 5
RWeistream(3C++) RWeistream(3C++)
endian format between the stream and the current environment. Set the
failbit if the value in the stream is too large to be stored in s.
virtual RWvistream&
operator>>(unsigned char& c);
Redefined from class RWbistream. Get the next unsigned char from the
input stream and store it in c. Note that c is treated as a character,
not a number.
virtual RWvistream&
operator>>(unsigned short& s);
Redefined from class RWbistream. Get the next unsigned short from the
input stream and store it in s, compensating for any differences in size
or endian format between the stream and the current environment. Set the
failbit if the value in the stream is too large to be stored in s.
virtual RWvistream&
operator>>(unsigned int& i);
Redefined from class RWbistream. Get the next unsigned int from the
input stream and store it in i, compensating for any differences in size
or endian format between the stream and the current environment. Set the
failbit if the value in the stream is too large to be stored in i.
virtual RWvistream&
operator>>(unsigned long& l);
Redefined from class RWbistream. Get the next unsigned long from the
input stream and store it in l, compensating for any differences in size
or endian format between the stream and the current environment. Set the
failbit if the value in the stream is too large to be stored in l.
RWeostream::EndianstreamEndian();
Return the endian format (RWeostream::BigEndian or
RWeostream::LittleEndian) of numeric values, as represented in the
stream.
size_t
streamSizeofInt();
Return the size of ints, as represented in the stream.
Page 6
RWeistream(3C++) RWeistream(3C++)
size_t
streamSizeofLong();
Return the size of longs, as represented in the stream.
size_t
streamSizeofShort();
Return the size of shorts, as represented in the stream.
size_t
streamSizeofSizeT();
Return the size of size_ts, as represented in the stream.
size_t
streamSizeofWchar();
Returns the size of wchar_ts, as represented in the stream.
Page 7