SourcePro® API Reference Guide

 
List of all members | Public Member Functions | Related Functions
RWvistream Class Referenceabstract

Abstract base class providing an interface for format-independent retrieval of fundamental types and fundamental-type arrays. More...

#include <rw/vstream.h>

Inheritance diagram for RWvistream:
RWvios RWbistream RWpistream RWvistreamFromDataInputStream RWXDRistream RWeistream

Public Member Functions

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 RWvistreamget (char &c)=0
 
virtual RWvistreamget (signed char &c)=0
 
virtual RWvistreamget (unsigned char &c)=0
 
virtual RWvistreamget (wchar_t &wc)=0
 
virtual RWvistreamget (bool &b)=0
 
virtual RWvistreamget (short &i)=0
 
virtual RWvistreamget (unsigned short &i)=0
 
virtual RWvistreamget (int &i)=0
 
virtual RWvistreamget (unsigned int &i)=0
 
virtual RWvistreamget (long &i)=0
 
virtual RWvistreamget (unsigned long &i)=0
 
virtual RWvistreamget (long long &i)=0
 
virtual RWvistreamget (unsigned long long &i)=0
 
virtual RWvistreamget (float &f)=0
 
virtual RWvistreamget (double &d)=0
 
virtual RWvistreamget (long double &d)=0
 
virtual RWvistreamget (char *v, size_t n)=0
 
virtual RWvistreamget (signed char *v, size_t n)=0
 
virtual RWvistreamget (unsigned char *v, size_t n)=0
 
virtual RWvistreamget (wchar_t *v, size_t n)=0
 
virtual RWvistreamget (bool *v, size_t n)=0
 
virtual RWvistreamget (short *v, size_t n)=0
 
virtual RWvistreamget (unsigned short *v, size_t n)=0
 
virtual RWvistreamget (int *v, size_t n)=0
 
virtual RWvistreamget (unsigned int *v, size_t n)=0
 
virtual RWvistreamget (long *v, size_t n)=0
 
virtual RWvistreamget (unsigned long *v, size_t n)=0
 
virtual RWvistreamget (long long *v, size_t n)=0
 
virtual RWvistreamget (unsigned long long *v, size_t n)=0
 
virtual RWvistreamget (float *v, size_t n)=0
 
virtual RWvistreamget (double *v, size_t n)=0
 
virtual RWvistreamget (long double *v, size_t n)=0
 
virtual RWvistreamgetChar (char &c)=0
 
virtual RWvistreamgetChar (signed char &c)=0
 
virtual RWvistreamgetChar (unsigned char &c)=0
 
virtual RWvistreamgetChar (wchar_t &wc)=0
 
virtual RWvistreamgetChars (char *s, size_t n)
 
virtual RWvistreamgetSizeT (size_t &sz)=0
 
virtual RWvistreamgetString (char *s, size_t n)=0
 
virtual int good ()=0
 
virtual int rdstate ()=0
 
void version (unsigned v)
 
unsigned version () const
 
- Public Member Functions inherited from RWvios
 operator void * ()
 

Related Functions

(Note that these are not member functions.)

RWvistreamoperator>> (RWvistream &is, char &c)
 
RWvistreamoperator>> (RWvistream &is, signed char &c)
 
RWvistreamoperator>> (RWvistream &is, unsigned char &c)
 
RWvistreamoperator>> (RWvistream &is, wchar_t &wc)
 
RWvistreamoperator>> (RWvistream &is, bool &b)
 
RWvistreamoperator>> (RWvistream &is, short &i)
 
RWvistreamoperator>> (RWvistream &is, unsigned short &i)
 
RWvistreamoperator>> (RWvistream &is, int &i)
 
RWvistreamoperator>> (RWvistream &is, unsigned int &i)
 
RWvistreamoperator>> (RWvistream &is, long &i)
 
RWvistreamoperator>> (RWvistream &is, unsigned long &i)
 
RWvistreamoperator>> (RWvistream &is, long long &i)
 
RWvistreamoperator>> (RWvistream &is, unsigned long long &i)
 
RWvistreamoperator>> (RWvistream &is, float &f)
 
RWvistreamoperator>> (RWvistream &is, double &d)
 
RWvistreamoperator>> (RWvistream &is, long double &d)
 

Detailed Description

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
#include <rw/vstream.h>
Persistence
None
Example
#include <rw/vstream.h>
#include <rw/bstream.h>
#include <rw/pstream.h>
#include <fstream>
#include <iostream>
void restoreStuff(RWvistream& str)
{
int i;
double d;
char s [80];
str >> i; // Restore an int
str >> d; // Restore a double
// Restore a character string, up to 80 characters long:
str.getString(s, sizeof s);
if (str.fail()) {
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");
RWpistream ps(vf);
RWbistream bs(vf);
// Uncomment the call to storeStuff that matches your stream type
restoreStuff(ps);
// restoreStuff(bs);
return 0;
}

Constructor & Destructor Documentation

virtual RWvistream::~RWvistream ( )
virtual

Empty destructor.

Member Function Documentation

virtual int RWvistream::bad ( )
pure 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 RWvios.

Implemented in RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual void RWvistream::clear ( int  v = 0)
pure virtual

Sets the current error state to v. If v is zero, then this clears the error state.

Implements RWvios.

Implemented in RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual int RWvistream::eof ( )
pure virtual

Returns a nonzero integer if an EOF is encountered.

Implements RWvios.

Implemented in RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual int RWvistream::fail ( )
pure 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 RWvios.

Implemented in RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual int RWvistream::get ( )
pure virtual

Gets and returns the next byte from the input stream, returning its value. Returns EOF if end of file is encountered.

Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual RWvistream& RWvistream::get ( char &  c)
pure virtual

Gets the next char from the input stream, returning its value in c.

Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual RWvistream& RWvistream::get ( signed char &  c)
pure virtual

Gets the next signed char from the input stream, returning its value in c.

Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual RWvistream& RWvistream::get ( unsigned char &  c)
pure virtual

Gets the next unsigned char from the input stream, returning its value in c.

Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual RWvistream& RWvistream::get ( wchar_t &  wc)
pure virtual

Gets the next wchar_t from the input stream, returning its value in wc.

Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual RWvistream& RWvistream::get ( bool &  b)
pure virtual

Gets the next bool from the input stream, returning its value in b.

Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual RWvistream& RWvistream::get ( short &  i)
pure virtual

Gets the next short from the input stream, returning its value in i.

Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual RWvistream& RWvistream::get ( unsigned short &  i)
pure virtual

Gets the next unsigned short from the input stream, returning its value in i.

Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual RWvistream& RWvistream::get ( int &  i)
pure virtual

Gets the next int from the input stream, returning its value in i.

Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual RWvistream& RWvistream::get ( unsigned int &  i)
pure virtual

Gets the next unsigned int from the input stream, returning its value in i.

Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual RWvistream& RWvistream::get ( long &  i)
pure virtual

Gets the next long from the input stream, returning its value in i.

Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual RWvistream& RWvistream::get ( unsigned long &  i)
pure virtual

Gets the next unsigned long from the input stream, returning its value in i.

Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual RWvistream& RWvistream::get ( long long &  i)
pure virtual

Gets the next long long from the input stream, returning its value in i.

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 &  i)
pure virtual

Gets the next unsigned long long from the input stream, returning its value in i.

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 &  f)
pure virtual

Gets the next float from the input stream, returning its value in f.

Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual RWvistream& RWvistream::get ( double &  d)
pure virtual

Gets the next double from the input stream, returning its value in d.

Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual RWvistream& RWvistream::get ( long double &  d)
pure virtual

Gets the next long double from the input stream, returning its value in d.

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::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::getChar ( char &  c)
pure virtual

Gets the next char from the input stream, returning its value in c. c is treated as a character.

Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual RWvistream& RWvistream::getChar ( signed char &  c)
pure virtual

Gets the next signed char from the input stream, returning its value in c. c is treated as a character.

Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual RWvistream& RWvistream::getChar ( unsigned char &  c)
pure virtual

Gets the next unsigned char from the input stream, returning its value in c. c is treated as a character.

Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual RWvistream& RWvistream::getChar ( wchar_t &  wc)
pure virtual

Gets the next wchar_t from the input stream, returning its value in wc. wc is treated as a character.

Implemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual RWvistream& RWvistream::getChars ( char *  s,
size_t  n 
)
inlinevirtual

Restores n char from the input stream into the array beginning at s. The function stops reading after n char. The resulting buffer is not null terminated. s is treated as a character string.

Note
This function delegates to get(char*, size_t) if not overridden.

Reimplemented in RWeistream, RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual RWvistream& RWvistream::getSizeT ( size_t &  sz)
pure virtual

Gets the next size_t value from the input stream, returning its value in sz.

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.

virtual int RWvistream::good ( )
pure virtual

Returns a nonzero integer if no error bits have been set.

Implements RWvios.

Implemented in RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

virtual int RWvistream::rdstate ( )
pure virtual

Returns the current error state.

Implements RWvios.

Implemented in RWXDRistream, RWpistream, RWbistream, and RWvistreamFromDataInputStream.

void RWvistream::version ( unsigned  v)
inline

Changes the value of the version number to v.

Note
The version number can be used to determine how objects should be deserialized from the underlying stream. Attempts to deserialize data that was serialized using a different version cannot be expected to work.
unsigned RWvistream::version ( ) const
inline

Returns the value of the version number.

Note
The default version number is the maximum supported version that this stream can read.

Friends And Related Function Documentation

RWvistream & operator>> ( RWvistream is,
char &  c 
)
related

Gets the next char from the input stream and stores it in c.

RWvistream & operator>> ( RWvistream is,
signed char &  c 
)
related

Gets the next signed char from the input stream and stores it in c.

RWvistream & operator>> ( RWvistream is,
unsigned char &  c 
)
related

Gets the next unsigned char from the input stream and stores it in c.

RWvistream & operator>> ( RWvistream is,
wchar_t &  wc 
)
related

Gets the next wchar_t from the input stream and stores it in wc.

RWvistream & operator>> ( RWvistream is,
bool &  b 
)
related

Gets the next bool from the input stream and stores it in b.

RWvistream & operator>> ( RWvistream is,
short &  i 
)
related

Gets the next short from the input stream and stores it in i.

RWvistream & operator>> ( RWvistream is,
unsigned short &  i 
)
related

Gets the next unsigned short from the input stream and stores it in i.

RWvistream & operator>> ( RWvistream is,
int &  i 
)
related

Gets the next int from the input stream and stores it in i.

RWvistream & operator>> ( RWvistream is,
unsigned int &  i 
)
related

Gets the next unsigned int from the input stream and stores it in i.

RWvistream & operator>> ( RWvistream is,
long &  i 
)
related

Gets the next long from the input stream and stores it in i.

RWvistream & operator>> ( RWvistream is,
unsigned long &  i 
)
related

Gets the next unsigned long from the input stream and stores it in i.

RWvistream & operator>> ( RWvistream is,
long long &  i 
)
related

Gets the next long long from the input stream and stores it in i.

Note
This operator function is available only if your compiler supports the long long type.
RWvistream & operator>> ( RWvistream is,
unsigned long long &  i 
)
related

Gets the next unsigned long long from the input stream and stores it in i.

Note
This operator function is available only if your compiler supports the unsigned long long type.
RWvistream & operator>> ( RWvistream is,
float &  f 
)
related

Gets the next float from the input stream and stores it in f.

RWvistream & operator>> ( RWvistream is,
double &  d 
)
related

Gets the next double from the input stream and stores it in d.

RWvistream & operator>> ( RWvistream is,
long double &  d 
)
related

Gets the next long double from the input stream and stores it in d.

Note
This operator function is available only if your compiler supports the long double type.

Copyright © 2022 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.