SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
Restores variables stored in binary format by RWbostream. More...
#include <rw/bstream.h>
Public Member Functions | |
RWbistream (std::istream &str) | |
RWbistream (std::streambuf *s) | |
virtual | ~RWbistream () |
virtual int | eof () |
virtual int | fail () |
virtual int | bad () |
virtual int | good () |
virtual int | rdstate () |
virtual void | clear (int v=0) |
operator void * () | |
virtual int | get () |
virtual RWvistream & | get (char &c) |
virtual RWvistream & | get (wchar_t &wc) |
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 (long double *, 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 (double *v, size_t N) |
virtual RWvistream & | get (float *v, size_t N) |
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 (wchar_t *v, size_t N) |
virtual RWvistream & | getString (char *s, size_t N) |
virtual RWvistream & | getSizeT (size_t &sz) |
virtual RWvistream & | operator>> (char &c) |
virtual RWvistream & | operator>> (long double &d) |
virtual RWvistream & | operator>> (long long &i) |
virtual RWvistream & | operator>> (unsigned long long &i) |
virtual RWvistream & | operator>> (double &d) |
virtual RWvistream & | operator>> (float &f) |
virtual RWvistream & | operator>> (int &i) |
virtual RWvistream & | operator>> (long &i) |
virtual RWvistream & | operator>> (short &i) |
virtual RWvistream & | operator>> (wchar_t &wc) |
virtual RWvistream & | operator>> (unsigned char &c) |
virtual RWvistream & | operator>> (unsigned int &i) |
virtual RWvistream & | operator>> (unsigned long &i) |
virtual RWvistream & | operator>> (unsigned short &i) |
Class RWbistream specializes the abstract base class RWvistream to restore variables stored in binary format by RWbostream.
You can think of it as a binary veneer over an associated std::streambuf. Because the RWbistream retains no information about the state of its associated std::streambuf, its use can be freely exchanged with other users of the std::streambuf (such as an std::istream or std::ifstream).
RWbistream can be interrogated as to the stream state using member functions good(), bad(), eof(), and so on.
#include <rw/bstream.h> RWbistream bstr(std::cin); // Construct an RWbistream using cin's streambuf
None
#include <iostream> #include <fstream> #include <rw/bstream.h> int main() { // Open an input file std::ifstream fstr ("data.dat"); // Construct RWbistream from it RWbistream bstr (fstr); int i; float f; double d; // Restore an int that was stored in binary if(!(bstr >> i)) { std::cout << "Run bostream.exe first!\n"; } else { // Restore a float & double bstr >> 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; }
Program output:
An integer, a float and a double sent out on an RWbostream!
RWbistream::RWbistream | ( | std::istream & | str | ) |
Constructs an RWbistream using the std::streambuf associated with the std::istream str. For DOS, the std::streambuf must have been opened in binary mode.
RWbistream::RWbistream | ( | std::streambuf * | s | ) |
Constructs an RWbistream from the std::streambuf s. For DOS, this std::streambuf must have been opened in binary mode.
virtual RWbistream::~RWbistream | ( | ) | [virtual] |
Empty destructor.
virtual int RWbistream::bad | ( | ) | [inline, virtual] |
Returns a nonzero integer if the bad bit has been set. Normally this indicates that a severe error has occurred from which recovery is probably impossible.
Implements RWvistream.
virtual void RWbistream::clear | ( | int | v = 0 |
) | [inline, virtual] |
Sets the current error state to v. If v is zero, then this clears the error state.
Implements RWvistream.
virtual int RWbistream::eof | ( | ) | [inline, virtual] |
Returns a nonzero integer if an EOF
is encountered.
Implements RWvistream.
virtual int RWbistream::fail | ( | ) | [inline, virtual] |
Returns a nonzero integer if the failed or bad bit has been set. Normally, this indicates that some storage or retrieval has failed, but that the stream is still in a usable state.
Implements RWvistream.
virtual RWvistream& RWbistream::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 there is no more data 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'
. Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::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, get() stores what has already been retrieved from the stream into v, and sets the failbit.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::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, get() stores what has already been retrieved from the stream into v, and sets the failbit.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::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, get() stores what has already been retrieved from the stream into v, and sets the failbit.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::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, get() stores what has already been retrieved from the stream into v, and sets the failbit.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::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, get() stores what has already been retrieved from the stream into v, and sets the failbit.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::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, get() stores what has already been retrieved from the stream into v, and sets the failbit.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::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, get() stores what has already been retrieved from the stream into v, and sets the failbit.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::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, get() stores what has already been retrieved from the stream into v, and sets the failbit.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::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, get() stores what has already been retrieved from the stream into v, and sets the failbit.
unsigned long long
type. Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::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, get() stores what has already been retrieved from the stream into v, and sets the failbit.
long long
type. Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::get | ( | long double * | , | |
size_t | N | |||
) | [virtual] |
Gets a vector of N long 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, get() stores what has already been retrieved from the stream into v, and sets the failbit.
long double
type. Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::get | ( | unsigned char * | v, | |
size_t | N | |||
) | [virtual] |
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, get() stores what has already been retrieved from the stream into v, and sets the failbit.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::get | ( | char * | v, | |
size_t | N | |||
) | [virtual] |
Gets a vector of 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, get() stores what has already been retrieved from the stream into v, and sets the failbit.
'\n'
. Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::get | ( | unsigned char & | c | ) | [virtual] |
Gets the next unsigned char
from the input stream, returning its value in c.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::get | ( | wchar_t & | wc | ) | [virtual] |
Gets the next wchar_t
from the input stream, returning its value in wc.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::get | ( | char & | c | ) | [virtual] |
Gets the next char
from the input stream, returning its value in c.
Implements RWvistream.
Reimplemented in RWeistream.
virtual int RWbistream::get | ( | ) | [virtual] |
Gets the next byte from the input stream, returning its value. Returns EOF
if end of file is encountered.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::getSizeT | ( | size_t & | sz | ) | [virtual] |
Gets the next size_t
value from the input stream, returning its value in sz.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::getString | ( | char * | s, | |
size_t | N | |||
) | [virtual] |
Restores a character string from the input stream that was stored to 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.
Implements RWvistream.
Reimplemented in RWeistream.
virtual int RWbistream::good | ( | ) | [inline, virtual] |
Returns a nonzero integer if no error bits have been set.
Implements RWvistream.
RWbistream::operator void * | ( | ) | [inline] |
virtual RWvistream& RWbistream::operator>> | ( | unsigned short & | i | ) | [virtual] |
Gets the next unsigned short
from the input stream and stores it in i.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::operator>> | ( | unsigned long & | i | ) | [virtual] |
Gets the next unsigned long
from the input stream and stores it in i.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::operator>> | ( | unsigned int & | i | ) | [virtual] |
Gets the next unsigned int
from the input stream and stores it in i.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::operator>> | ( | unsigned char & | c | ) | [virtual] |
Gets the next unsigned char
from the input stream and stores it in c.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::operator>> | ( | wchar_t & | wc | ) | [virtual] |
Gets the next wchar_t
from the input stream and stores it in wc.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::operator>> | ( | short & | i | ) | [virtual] |
Gets the next short
from the input stream and stores it in i.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::operator>> | ( | long & | i | ) | [virtual] |
Gets the next long
from the input stream and stores it in i.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::operator>> | ( | int & | i | ) | [virtual] |
Gets the next int
from the input stream and stores it in i.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::operator>> | ( | float & | f | ) | [virtual] |
Gets the next float
from the input stream and stores it in f.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::operator>> | ( | double & | d | ) | [virtual] |
Gets the next double
from the input stream and stores it in d.
Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::operator>> | ( | unsigned long long & | i | ) | [virtual] |
Gets the next unsigned long long
from the input stream and stores it in i.
unsigned long long
type. Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::operator>> | ( | long long & | i | ) | [virtual] |
Gets the next long long
from the input stream and stores it in i.
long long
type. Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::operator>> | ( | long double & | d | ) | [virtual] |
Gets the next long double
from the input stream and stores it in d.
long double
type. Implements RWvistream.
Reimplemented in RWeistream.
virtual RWvistream& RWbistream::operator>> | ( | char & | c | ) | [virtual] |
Gets the next char
from the input stream and stores it in c.
Implements RWvistream.
Reimplemented in RWeistream.
virtual int RWbistream::rdstate | ( | ) | [inline, virtual] |
Returns the current error state.
Implements RWvistream.
© 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.