Abstract base class providing an interface for format-independent retrieval of fundamental types and fundamental-type arrays.
More...
|
virtual | ~RWvistream () |
|
virtual int | bad ()=0 |
|
virtual void | clear (int v=0)=0 |
|
virtual int | eof ()=0 |
|
virtual int | fail ()=0 |
|
virtual int | get ()=0 |
|
virtual RWvistream & | get (char &c)=0 |
|
virtual RWvistream & | get (signed char &c)=0 |
|
virtual RWvistream & | get (unsigned char &c)=0 |
|
virtual RWvistream & | get (wchar_t &wc)=0 |
|
virtual RWvistream & | get (bool &b)=0 |
|
virtual RWvistream & | get (short &i)=0 |
|
virtual RWvistream & | get (unsigned short &i)=0 |
|
virtual RWvistream & | get (int &i)=0 |
|
virtual RWvistream & | get (unsigned int &i)=0 |
|
virtual RWvistream & | get (long &i)=0 |
|
virtual RWvistream & | get (unsigned long &i)=0 |
|
virtual RWvistream & | get (long long &i)=0 |
|
virtual RWvistream & | get (unsigned long long &i)=0 |
|
virtual RWvistream & | get (float &f)=0 |
|
virtual RWvistream & | get (double &d)=0 |
|
virtual RWvistream & | get (long double &d)=0 |
|
virtual RWvistream & | get (char *v, size_t n)=0 |
|
virtual RWvistream & | get (signed char *v, size_t n)=0 |
|
virtual RWvistream & | get (unsigned char *v, size_t n)=0 |
|
virtual RWvistream & | get (wchar_t *v, size_t n)=0 |
|
virtual RWvistream & | get (bool *v, size_t n)=0 |
|
virtual RWvistream & | get (short *v, size_t n)=0 |
|
virtual RWvistream & | get (unsigned short *v, size_t n)=0 |
|
virtual RWvistream & | get (int *v, size_t n)=0 |
|
virtual RWvistream & | get (unsigned int *v, size_t n)=0 |
|
virtual RWvistream & | get (long *v, size_t n)=0 |
|
virtual RWvistream & | get (unsigned long *v, size_t n)=0 |
|
virtual RWvistream & | get (long long *v, size_t n)=0 |
|
virtual RWvistream & | get (unsigned long long *v, size_t n)=0 |
|
virtual RWvistream & | get (float *v, size_t n)=0 |
|
virtual RWvistream & | get (double *v, size_t n)=0 |
|
virtual RWvistream & | get (long double *v, size_t n)=0 |
|
virtual RWvistream & | getChar (char &c)=0 |
|
virtual RWvistream & | getChar (signed char &c)=0 |
|
virtual RWvistream & | getChar (unsigned char &c)=0 |
|
virtual RWvistream & | getChar (wchar_t &wc)=0 |
|
virtual RWvistream & | getChars (char *s, size_t n) |
|
virtual RWvistream & | getSizeT (size_t &sz)=0 |
|
virtual RWvistream & | getString (char *s, size_t n)=0 |
|
virtual int | good ()=0 |
|
virtual int | rdstate ()=0 |
|
void | version (unsigned v) |
|
unsigned | version () const |
|
| operator void * () |
|
|
(Note that these are not member functions.)
|
RWvistream & | operator>> (RWvistream &is, char &c) |
|
RWvistream & | operator>> (RWvistream &is, signed char &c) |
|
RWvistream & | operator>> (RWvistream &is, unsigned char &c) |
|
RWvistream & | operator>> (RWvistream &is, wchar_t &wc) |
|
RWvistream & | operator>> (RWvistream &is, bool &b) |
|
RWvistream & | operator>> (RWvistream &is, short &i) |
|
RWvistream & | operator>> (RWvistream &is, unsigned short &i) |
|
RWvistream & | operator>> (RWvistream &is, int &i) |
|
RWvistream & | operator>> (RWvistream &is, unsigned int &i) |
|
RWvistream & | operator>> (RWvistream &is, long &i) |
|
RWvistream & | operator>> (RWvistream &is, unsigned long &i) |
|
RWvistream & | operator>> (RWvistream &is, long long &i) |
|
RWvistream & | operator>> (RWvistream &is, unsigned long long &i) |
|
RWvistream & | operator>> (RWvistream &is, float &f) |
|
RWvistream & | operator>> (RWvistream &is, double &d) |
|
RWvistream & | operator>> (RWvistream &is, long double &d) |
|
Class RWvistream is an abstract base class that provides an interface for format-independent retrieval of fundamental types, and arrays of fundamental types. Its counterpart, RWvostream, provides a complementary interface for the storage of the fundamental types.
Because the interface of RWvistream and RWvostream is independent of formatting, your application need not be concerned with how variables are actually stored or restored – functionality that is the responsibility of whatever derived class you choose. For instance, you could use an operating-system independent US-ASCII format (classes RWpistream and RWpostream), a binary format (classes RWbistream and RWbostream), or define your own format (such as an interface to a network).
- Note
- Because this is an abstract base class, these design goals cannot be enforced; rather, the description here is merely the model of how a class derived from RWvistream and RWvostream should act.
See class RWvostream for additional explanations and examples of format-independent stream storage.
- Synopsis
- Persistence
- None
- Example
#include <rw/vstream.h>
#include <rw/bstream.h>
#include <rw/pstream.h>
#include <fstream>
#include <iostream>
{
int i;
double d;
char s [80];
str >> i;
str >> d;
std::cerr << "Restoration failed.\n\n";
return;
}
std::cout << "Int : " << i << "\n";
std::cout << "Double : " << d << "\n";
std::cout << "Char array : \"" << s << "\"\n";
}
int main()
{
std::ifstream vf("vfile.dat");
restoreStuff(ps);
return 0;
}
virtual RWvistream& RWvistream::get |
( |
char * |
v, |
|
|
size_t |
n |
|
) |
| |
|
pure virtual |
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'
.
Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.
virtual RWvistream& RWvistream::get |
( |
signed char * |
v, |
|
|
size_t |
n |
|
) |
| |
|
pure virtual |
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.
Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.
virtual RWvistream& RWvistream::get |
( |
unsigned char * |
v, |
|
|
size_t |
n |
|
) |
| |
|
pure 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, stores what has already been retrieved from the stream into v, and sets the failbit.
Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.
virtual RWvistream& RWvistream::get |
( |
wchar_t * |
v, |
|
|
size_t |
n |
|
) |
| |
|
pure 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'
.
Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.
virtual RWvistream& RWvistream::get |
( |
bool * |
v, |
|
|
size_t |
n |
|
) |
| |
|
pure virtual |
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.
Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.
virtual RWvistream& RWvistream::get |
( |
short * |
v, |
|
|
size_t |
n |
|
) |
| |
|
pure 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.
Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.
virtual RWvistream& RWvistream::get |
( |
unsigned short * |
v, |
|
|
size_t |
n |
|
) |
| |
|
pure 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.
Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.
virtual RWvistream& RWvistream::get |
( |
int * |
v, |
|
|
size_t |
n |
|
) |
| |
|
pure 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.
Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.
virtual RWvistream& RWvistream::get |
( |
unsigned int * |
v, |
|
|
size_t |
n |
|
) |
| |
|
pure 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.
Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.
virtual RWvistream& RWvistream::get |
( |
long * |
v, |
|
|
size_t |
n |
|
) |
| |
|
pure 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.
Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.
virtual RWvistream& RWvistream::get |
( |
unsigned long * |
v, |
|
|
size_t |
n |
|
) |
| |
|
pure 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.
Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.
virtual RWvistream& RWvistream::get |
( |
long long * |
v, |
|
|
size_t |
n |
|
) |
| |
|
pure 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.
Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.
virtual RWvistream& RWvistream::get |
( |
unsigned long long * |
v, |
|
|
size_t |
n |
|
) |
| |
|
pure 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.
Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.
virtual RWvistream& RWvistream::get |
( |
float * |
v, |
|
|
size_t |
n |
|
) |
| |
|
pure 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.
Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.
virtual RWvistream& RWvistream::get |
( |
double * |
v, |
|
|
size_t |
n |
|
) |
| |
|
pure 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.
Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.
virtual RWvistream& RWvistream::get |
( |
long double * |
v, |
|
|
size_t |
n |
|
) |
| |
|
pure 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, 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 double
type.
Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.
virtual RWvistream& RWvistream::getString |
( |
char * |
s, |
|
|
size_t |
n |
|
) |
| |
|
pure 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.
Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.