rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWvistream Class Reference
[Virtual Streams]

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

List of all members.

Public Member Functions

virtual ~RWvistream ()
virtual int eof ()=0
virtual int fail ()=0
virtual int bad ()=0
virtual int good ()=0
virtual int rdstate ()=0
virtual void clear (int v=0)=0
virtual int get ()=0
virtual RWvistreamget (char &c)=0
virtual RWvistreamget (wchar_t &wc)=0
virtual RWvistreamget (unsigned char &c)=0
virtual RWvistreamget (char *v, size_t N)=0
virtual RWvistreamget (long double *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 (double *v, size_t N)=0
virtual RWvistreamget (float *v, size_t N)=0
virtual RWvistreamget (int *v, size_t N)=0
virtual RWvistreamget (long *v, size_t N)=0
virtual RWvistreamget (short *v, size_t N)=0
virtual RWvistreamget (wchar_t *v, size_t N)=0
virtual RWvistreamget (unsigned char *v, size_t N)=0
virtual RWvistreamget (unsigned short *v, size_t N)=0
virtual RWvistreamget (unsigned int *v, size_t N)=0
virtual RWvistreamget (unsigned long *v, size_t N)=0
virtual RWvistreamgetString (char *s, size_t N)=0
virtual RWvistreamgetSizeT (size_t &sz)=0
virtual RWvistreamoperator>> (char &c)=0
virtual RWvistreamoperator>> (long double &d)=0
virtual RWvistreamoperator>> (long long &i)=0
virtual RWvistreamoperator>> (unsigned long long &i)=0
virtual RWvistreamoperator>> (double &d)=0
virtual RWvistreamoperator>> (float &f)=0
virtual RWvistreamoperator>> (int &i)=0
virtual RWvistreamoperator>> (long &i)=0
virtual RWvistreamoperator>> (short &i)=0
virtual RWvistreamoperator>> (wchar_t &wc)=0
virtual RWvistreamoperator>> (unsigned char &c)=0
virtual RWvistreamoperator>> (unsigned short &i)=0
virtual RWvistreamoperator>> (unsigned int &i)=0
virtual RWvistreamoperator>> (unsigned long &i)=0
void version (unsigned v)
unsigned version () const

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

Examples

 #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((RWvistream &)ps);
     // restoreStuff((RWvistream &)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 RWbistream, RWpistream, RWvistreamFromDataInputStream, and RWXDRistream.

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 RWbistream, RWpistream, RWvistreamFromDataInputStream, and RWXDRistream.

virtual int RWvistream::eof (  )  [pure virtual]

Returns a nonzero integer if an EOF is encountered.

Implements RWvios.

Implemented in RWbistream, RWpistream, RWvistreamFromDataInputStream, and RWXDRistream.

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 RWbistream, RWpistream, RWvistreamFromDataInputStream, and RWXDRistream.

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, get() stores whatever has already been retrieved from the stream into v, and sets the failbit.

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

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, get() stores whatever has already been retrieved from the stream into v, and sets the failbit.

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

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, get() stores whatever has already been retrieved from the stream into v, and sets the failbit.

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

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, get() stores whatever has already been retrieved from the stream into v, and sets the failbit.

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

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, get() stores whatever 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 RWbistream, RWeistream, RWpistream, RWvistreamFromDataInputStream, and RWXDRistream.

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, get() stores whatever has already been retrieved from the stream into v, and sets the failbit.

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

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, get() stores whatever has already been retrieved from the stream into v, and sets the failbit.

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

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, get() stores whatever has already been retrieved from the stream into v, and sets the failbit.

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

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, get() stores whatever has already been retrieved from the stream into v, and sets the failbit.

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

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, get() stores whatever has already been retrieved from the stream into v, and sets the failbit.

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

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, get() stores whatever 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 RWbistream, RWeistream, RWpistream, RWvistreamFromDataInputStream, and RWXDRistream.

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, get() stores whatever 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 RWbistream, RWeistream, RWpistream, RWvistreamFromDataInputStream, and RWXDRistream.

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, get() stores whatever 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 RWbistream, RWeistream, RWpistream, RWvistreamFromDataInputStream, and RWXDRistream.

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, get() stores whatever 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 RWbistream, RWeistream, RWpistream, RWvistreamFromDataInputStream, and RWXDRistream.

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 RWbistream, RWeistream, RWpistream, RWvistreamFromDataInputStream, and RWXDRistream.

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 RWbistream, RWeistream, RWpistream, RWvistreamFromDataInputStream, and RWXDRistream.

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

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

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

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 RWbistream, RWeistream, RWpistream, RWvistreamFromDataInputStream, and RWXDRistream.

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 RWbistream, RWeistream, RWpistream, RWvistreamFromDataInputStream, and RWXDRistream.

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 RWbistream, RWeistream, RWpistream, RWvistreamFromDataInputStream, and RWXDRistream.

virtual int RWvistream::good (  )  [pure virtual]

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

Implements RWvios.

Implemented in RWbistream, RWpistream, RWvistreamFromDataInputStream, and RWXDRistream.

virtual RWvistream& RWvistream::operator>> ( unsigned long &  i  )  [pure virtual]

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

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

virtual RWvistream& RWvistream::operator>> ( unsigned int &  i  )  [pure virtual]

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

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

virtual RWvistream& RWvistream::operator>> ( unsigned short &  i  )  [pure virtual]

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

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

virtual RWvistream& RWvistream::operator>> ( unsigned char &  c  )  [pure virtual]

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

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

virtual RWvistream& RWvistream::operator>> ( wchar_t &  wc  )  [pure virtual]

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

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

virtual RWvistream& RWvistream::operator>> ( short &  i  )  [pure virtual]

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

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

virtual RWvistream& RWvistream::operator>> ( long &  i  )  [pure virtual]

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

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

virtual RWvistream& RWvistream::operator>> ( int &  i  )  [pure virtual]

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

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

virtual RWvistream& RWvistream::operator>> ( float &  f  )  [pure virtual]

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

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

virtual RWvistream& RWvistream::operator>> ( double &  d  )  [pure virtual]

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

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

virtual RWvistream& RWvistream::operator>> ( unsigned long long &  i  )  [pure virtual]

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.

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

virtual RWvistream& RWvistream::operator>> ( long long &  i  )  [pure virtual]

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.

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

virtual RWvistream& RWvistream::operator>> ( long double &  d  )  [pure virtual]

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.

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

virtual RWvistream& RWvistream::operator>> ( char &  c  )  [pure virtual]

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

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

virtual int RWvistream::rdstate (  )  [pure virtual]

Returns the current error state.

Implements RWvios.

Implemented in RWbistream, RWpistream, RWvistreamFromDataInputStream, and RWXDRistream.

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.
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.
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© 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.