![]() SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
Specializes the base class RWbistream to restore values previously stored by RWeostream. More...
#include <rw/estream.h>
Public Member Functions | |
| RWeistream (std::istream &str) | |
| RWeistream (std::streambuf *s) | |
| virtual int | get () |
| virtual RWvistream & | get (char &c) |
| virtual RWvistream & | get (char *v, size_t N) |
| virtual RWvistream & | operator>> (char &c) |
| virtual RWvistream & | get (unsigned char &c) |
| virtual RWvistream & | get (unsigned char *v, size_t N) |
| virtual RWvistream & | operator>> (unsigned char &c) |
| virtual RWvistream & | getSizeT (size_t &sz) |
| virtual RWvistream & | operator>> (int &i) |
| virtual RWvistream & | operator>> (short &i) |
| virtual RWvistream & | operator>> (long &i) |
| virtual RWvistream & | operator>> (unsigned int &i) |
| virtual RWvistream & | operator>> (unsigned long &i) |
| virtual RWvistream & | operator>> (unsigned short &i) |
| virtual RWvistream & | operator>> (double &d) |
| virtual RWvistream & | operator>> (float &f) |
| virtual RWvistream & | operator>> (unsigned long long &i) |
| virtual RWvistream & | operator>> (long long &i) |
| virtual RWvistream & | operator>> (long double &) |
| virtual RWvistream & | operator>> (wchar_t &wc) |
| virtual RWvistream & | get (wchar_t &wc) |
| virtual RWvistream & | get (int *v, size_t N) |
| virtual RWvistream & | get (unsigned int *v, size_t N) |
| virtual RWvistream & | get (long *v, size_t N) |
| virtual RWvistream & | get (unsigned 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 (double *v, size_t N) |
| virtual RWvistream & | get (float *v, size_t N) |
| virtual RWvistream & | get (long long *v, size_t N) |
| virtual RWvistream & | get (unsigned long long *v, size_t N) |
| virtual RWvistream & | get (long double *, size_t) |
| virtual RWvistream & | getString (char *s, size_t N) |
| virtual RWvistream & | get (wchar_t *v, size_t N) |
| size_t | streamSizeofShort () |
| size_t | streamSizeofInt () |
| size_t | streamSizeofLong () |
| size_t | streamSizeofWchar () |
| size_t | streamSizeofSizeT () |
| RWeostream::Endian | streamEndian () |
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:
float and double.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.
#include <rw/estream.h> RWeistream estr(cin); // Construct an RWeistream using cin's streambuf
None.
#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; }
| 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.
| RWStreamErr | if the data in s does not describe a valid endian stream. |
| RWeistream::RWeistream | ( | std::streambuf * | s | ) |
Constructs an RWeistream from the std::streambuf s. For DOS, this std::streambuf must have been created in binary mode.
| RWStreamErr | if the data in s does not describe a valid endian stream. |
| virtual RWvistream& RWeistream::get | ( | wchar_t * | v, | |
| size_t | N | |||
| ) | [virtual] |
Gets a vector of wchar_t and stores them in the array beginning at v. If the restore operation stops prematurely because no more data is available on the stream, because an exception is thrown, or for some other reason, get() stores what has already been retrieved from the stream into v and sets the failbit.
L'\n'. Reimplemented from RWbistream.
| virtual RWvistream& RWeistream::get | ( | long double * | , | |
| size_t | ||||
| ) | [inline, virtual] |
| RWInternalErr | is thrown. This function is not supported with endian streams. |
long double 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 no more data is available on the stream, because an exception is thrown, or for some other reason, get() stores what has already been retrieved from the stream into v, and sets the failbit.
unsigned long long type. 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 no more data is available on the stream, because an exception is thrown, or for some other reason, get() stores what has already been retrieved from the stream into v and sets the failbit.
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 no more data is available on the stream, because an exception is thrown, or for some other reason, get() 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 no more data is available on the stream, because an exception is thrown, or for some other reason, get() 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 no more data is available on the stream, because an exception is thrown, or for some other reason, get() 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 no more data is available on the stream, because an exception is thrown, or for some other reason, get() 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 no more data is available on the stream, because an exception is thrown, or for some other reason, get() 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 no more data is available on the stream, because an exception is thrown, or for some other reason, get() 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 no more data is available on the stream, because an exception is thrown, or for some other reason, get() 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 no more data is available on the stream, because an exception is thrown, or for some other reason, get() stores what has already been retrieved from the stream into v and sets the failbit.
Reimplemented from RWbistream.
| virtual RWvistream& RWeistream::get | ( | wchar_t & | wc | ) | [inline, virtual] |
Gets the next wchar_t from the input stream and stores it in wc, compensating for any differences in size or endian format between the stream and the current environment. Sets the failbit if the value in the stream is too large to be stored in wc.
Reimplemented from RWbistream.
| virtual RWvistream& RWeistream::get | ( | unsigned char * | v, | |
| size_t | N | |||
| ) | [inline, virtual] |
Gets a vector of N unsigned char and stores them in the array beginning at v. If the restore operation stops prematurely because no more data is available on the stream, because an exception is thrown, or for some other reason, get() stores what has already been retrieved from the stream into v and sets the failbit.
Reimplemented from RWbistream.
| virtual RWvistream& RWeistream::get | ( | unsigned char & | c | ) | [inline, virtual] |
Gets the next unsigned char from the input stream, returning its value in c.
Reimplemented from RWbistream.
| virtual RWvistream& RWeistream::get | ( | char * | v, | |
| size_t | N | |||
| ) | [inline, virtual] |
Gets a vector of char and stores them in the array beginning at v. If the restore operation stops prematurely because no more data is available on the stream, because an exception is thrown, or for some other reason, get() stores what has already been retrieved from the stream into v and sets the failbit.
Reimplemented from RWbistream.
| virtual RWvistream& RWeistream::get | ( | char & | c | ) | [inline, virtual] |
Gets the next char from the input stream, returning its value in c.
Reimplemented from RWbistream.
| virtual int RWeistream::get | ( | ) | [inline, virtual] |
Gets and returns the next byte from the input stream, returning its value. Returns EOF if the end-of-file is encountered.
Reimplemented from RWbistream.
| virtual RWvistream& RWeistream::getSizeT | ( | size_t & | sz | ) | [virtual] |
Gets the next size_t value from the input stream and stores it in sz, compensating for any differences in size or endian format between the stream and the current environment. Sets the failbit if the value in the stream is too large to be stored in sz.
Reimplemented from RWbistream.
| virtual RWvistream& RWeistream::getString | ( | char * | s, | |
| size_t | N | |||
| ) | [virtual] |
Restores a character string from the input stream that was stored in the output stream with RWvostream::putstring 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 N - 1 characters have been read and the N th character is not the string terminator, then the failbit of the stream is set. In either case, the string is terminated with a null byte.
Reimplemented from RWbistream.
| virtual RWvistream& RWeistream::operator>> | ( | wchar_t & | wc | ) | [virtual] |
Gets the next wchar_t from the input stream and stores it in wc, compensating for any differences in size or endian format between the stream and the current environment. Sets the failbit if the value in the stream is too large to be stored in wc.
Reimplemented from RWbistream.
| virtual RWvistream& RWeistream::operator>> | ( | long double & | ) | [inline, virtual] |
| RWInternalErr | is thrown. This function is not supported with endian streams. |
long double type. Reimplemented from RWbistream.
| virtual RWvistream& RWeistream::operator>> | ( | long long & | i | ) | [virtual] |
Gets the next long long value from the input stream and stores it in i, compensating for any differences in size or endian format between the stream and the current environment. Sets the failbit if the value in the stream is too large to be stored in i.
long long type. Reimplemented from RWbistream.
| virtual RWvistream& RWeistream::operator>> | ( | unsigned long long & | i | ) | [virtual] |
Gets the next unsigned long long value from the input stream and stores it in i, compensating for any differences in size or endian format between the stream and the current environment. Sets the failbit if the value in the stream is too large to be stored in i.
unsigned long long type. Reimplemented from RWbistream.
| virtual RWvistream& RWeistream::operator>> | ( | float & | f | ) | [virtual] |
Gets the next float value from the input stream and stores it in f, compensating for any differences in size or endian format between the stream and the current environment. Sets the failbit if the value in the stream is too large to be stored in f.
Reimplemented from RWbistream.
| virtual RWvistream& RWeistream::operator>> | ( | double & | d | ) | [virtual] |
Gets the next double value from the input stream and stores it in d, compensating for any differences in size or endian format between the stream and the current environment. Sets the failbit if the value in the stream is too large to be stored in d.
Reimplemented from RWbistream.
| virtual RWvistream& RWeistream::operator>> | ( | unsigned short & | i | ) | [virtual] |
Gets the next unsigned short value from the input stream and stores 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.
Reimplemented from RWbistream.
| virtual RWvistream& RWeistream::operator>> | ( | unsigned long & | i | ) | [virtual] |
Gets the next unsigned long value from the input stream and stores 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.
Reimplemented from RWbistream.
| virtual RWvistream& RWeistream::operator>> | ( | unsigned int & | i | ) | [virtual] |
Gets the next unsigned int value from the input stream and stores 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.
Reimplemented from RWbistream.
| virtual RWvistream& RWeistream::operator>> | ( | long & | i | ) | [virtual] |
Gets the next long value from the input stream and stores it in i, compensating for any differences in size or endian format between the stream and the current environment. Sets the failbit if the value in the stream is too large to be stored in i.
Reimplemented from RWbistream.
| virtual RWvistream& RWeistream::operator>> | ( | short & | i | ) | [virtual] |
Gets the next short value from the input stream and stores it in i, compensating for any differences in size or endian format between the stream and the current environment. Sets the failbit if the value in the stream is too large to be stored in i.
Reimplemented from RWbistream.
| virtual RWvistream& RWeistream::operator>> | ( | int & | i | ) | [virtual] |
Gets the next int value from the input stream and stores it in i, compensating for any differences in size or endian format between the stream and the current environment. Sets the failbit if the value in the stream is too large to be stored in i.
Reimplemented from RWbistream.
| virtual RWvistream& RWeistream::operator>> | ( | unsigned char & | c | ) | [inline, virtual] |
Gets the next unsigned char from the input stream, returning its value in c.
Reimplemented from RWbistream.
| virtual RWvistream& RWeistream::operator>> | ( | char & | c | ) | [inline, virtual] |
Gets the next char from the input stream, returning its value in c.
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 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.