RWvistreamRWvios
Member Functions | |||
get() |
getString() |
operator void*() |
operator>>() |
#include <rw/vstream.h>
Class RWvistream is an abstract base class. It provides an interface for format-independent retrieval of fundamental types and arrays of fundamental types. Its counterpart, RWvostream, provides a complementary interface for storage of the fundamental types.
Because the interface of RWvistream and RWvostream is independent of formatting, the user of these classes need not care how variables are actually stored or restored. That is determined in the derived class. Storage can be done in three kinds of formats:
an operating-system independent ASCII format (classes RWpistream and RWpostream)
a binary format (classes RWbistream and RWbostream)
a user-defined format (an interface to a network, for example)
Note that because RWvistream is an abstract base class, there is no way to actually enforce these goals; 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.
#include <rw/vstream.h> void restoreStuff( RWvistream& str) { int i; double d; char string[80]; str >> i; // Restore an int str >> d; // Restore a double // Restore a character string, up to 80 characters long: str.getString(string, sizeof(string)); if(str.fail()) cerr << "Oh, oh, bad news.\n"; }
virtual ~RWvistream();
Virtual destructor. Allows specializing classes to deallocate any resources that they allocated.
virtual RWvistream& operator>>(char& c) = 0;
Gets the next char from the input stream and stores it in c.
virtual RWvistream& operator>>(wchar_t& wc) = 0;
Gets the next wchar_t from the input stream and stores it in wc.
virtual RWvistream& operator>>(double& d) = 0;
Gets the next double from the input stream and stores it in d.
virtual RWvistream& operator>>(float& f) = 0;
Gets the next float from the input stream and stores it in f.
virtual RWvistream& operator>>(int& i) = 0;
Gets the next int from the input stream and stores it in i.
virtual RWvistream& operator>>(long& l) = 0;
Gets the next long from the input stream and stores it in l.
virtual RWvistream& operator>>(short& s) = 0;
Gets the next short from the input stream and stores it in s.
virtual RWvistream& operator>>(unsigned char& c) = 0;
Gets the next unsigned char from the input stream and stores it in c.
virtual RWvistream& operator>>(unsigned short& s) = 0;
Gets the next unsigned short from the input stream and stores it in s.
virtual RWvistream& operator>>(unsigned int& i) = 0;
Gets the next unsigned int from the input stream and stores it in i.
virtual RWvistream& operator>>(unsigned long& l) = 0;
Gets the next unsigned long from the input stream and stores it in l.
operator void*();
Inherited from RWvios.
virtual int get() = 0;
Gets and returns the next byte from the input stream, returning its value. Returns EOF if the end of file is encountered.
virtual RWvistream& get(char& c) = 0;
Gets the next char from the input stream, returning its value in c.
virtual RWvistream& get(wchar_t& wc) = 0;
Gets the next wchar_t from the input stream, returning its value in wc.
virtual RWvistream& get(unsigned char& c) = 0;
Gets the next unsigned char from the input stream, returning its value
in c.
virtual RWvistream& get(char* v, size_t N) = 0;
Gets a vector of chars and stores them in the array beginning at v. If the restore operation stops prematurely, because there are no more data available on the stream, because an exception is thrown, or for some other reason, get stores what was already retrieved from the stream into v, and sets the failbit. Note that get retrieves raw characters and does not perform any conversions on special characters such as \n.
virtual RWvistream& get(wchar_t* v, size_t N) = 0;
Gets a vector of wide characters and stores them in the array beginning at v. If the restore operation stops prematurely, because there are no more data available on the stream, because an exception is thrown, or for some other reason, get stores what was already retrieved from the stream into v, and sets the failbit. Note that get retrieves raw characters and does not perform any conversions on special characters such as \n.
virtual RWvistream& get(double* v, size_t N) = 0;
Gets a vector of N doubles and stores them in the array beginning at v. If the restore operation stops prematurely, because there are no more data available on the stream, because an exception is thrown, or for some other reason, get stores what was already retrieved from the stream into v, and sets the failbit.
virtual RWvistream& get(float* v, size_t N) = 0;
Gets a vector of N floats and stores them in the array beginning at v. If the restore operation stops prematurely, because there are no more data available on the stream, because an exception is thrown, or for some other reason, get stores what was already retrieved from the stream into v, and sets the failbit.
virtual RWvistream& get(int* v, size_t N) = 0;
Gets a vector of N ints and store them in the array beginning at v. If the restore operation stops prematurely, because there are no more data available on the stream, because an exception is thrown, or for some other reason, get stores what was already retrieved from the stream into v, and sets the failbit.
virtual RWvistream& get(long* v, size_t N) = 0;
Gets a vector of N longs and stores them in the array beginning at v. If the restore operation stops prematurely, because there are no more data available on the stream, because an exception is thrown, or for some other reason, get stores what was already retrieved from the stream into v, and sets the failbit.
virtual RWvistream& get(short* v, size_t N) = 0;
Gets a vector of N shorts and stores them in the array beginning at v. If the restore operation stops prematurely, because there are no more data available on the stream, because an exception is thrown, or for some other reason, get stores what was already retrieved from the stream into v, and sets the failbit.
virtual RWvistream& get(unsigned char* v, size_t N) = 0;
Gets a vector of N unsigned chars and stores them in the array beginning at v. If the restore operation stops prematurely, because there are no more data available on the stream, because an exception is thrown, or for some other reason, get stores what was already retrieved from the stream into v, and sets the failbit. Note that this member preserves ASCII numerical codes, not their corresponding character values. If you want to restore a character string, use the function
getString(char*, size_t).
virtual RWvistream& get(unsigned short* v, size_t N) = 0;
Gets a vector of N unsigned shorts and store them in the array beginning at v. If the restore operation stops prematurely because there are 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.
virtual RWvistream& get(unsigned int* v, size_t N) = 0;
Get a vector of N unsigned ints and stored them in the array beginning at v. If the restore operation stops prematurely, because there are no more data available on the stream, because an exception is thrown, or for some other reason, get stores what was already retrieved from the stream into v, and sets the failbit.
virtual RWvistream& get(unsigned long* v, size_t N) = 0;
Gets a vector of N unsigned longs and stores them in the array beginning at v. If the restore operation stops prematurely, because there are no more data available on the stream, because an exception is thrown, or for some other reason, get stores what was already retrieved from the stream into v, and sets the failbit.
virtual RWvistream& getString(char* s, size_t N) = 0;
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 are read and the Nth character is not the string terminator, the failbit of the stream is set. In either case, the string is terminated with a null byte.
virtual RWvistream& getString(wchar_t* ws, size_t N) = 0;
Restores a wide character string from the input stream that was stored to the output stream with RWvostream::putstring, and stores it in the array beginning at ws. The function stops reading at the end of the string or after N-1 characters, whichever comes first. If N-1 characters are read and the Nth character is not the string terminator, the failbit of the stream is set. In either case, the string is terminated with a null byte.
RWvistream& operator>>(RWvistream&, RWCString& str);
Restores a string into str from a virtual stream or RWFile, respectively, replacing the previous contents of str.
RWvistream& operator>>(RWvistream&, RWInteger& x);
Restores an RWInteger into x from a virtual stream or RWFile, respectively, replacing the previous contents of x.
RWvistream& operator>>(RWvistream&, RWTime& t);
Restores an RWTime into t from a virtual stream or RWFile, respectively, replacing the previous contents of t.
RWvistream& operator>>(RWvistream& strm, RWTPtrDeque<T>& coll); RWvistream& operator>>(RWvistream& strm, RWTPtrDlist<T>& coll); RWvistream& operator>>(RWvistream& strm, RWTPtrHashMap<K,T,H,EQ>& coll); RWvistream& operator>>(RWvistream& strm, RWTPtrHashMultiMap<K,T,H,EQ>& coll); RWvistream& operator>>(RWvistream& strm, RWTPtrHashMultiSet<T,H,EQ>& coll); RWvistream& operator>>(RWvistream& strm, RWTPtrHashSet<T,H,EQ>& coll); RWvistream& operator>>(RWvistream& strm, RWTPtrMap<K,T,C>& coll); RWvistream& operator>>(RWvistream& strm, RWTPtrMultiMap<K,T,C>& coll); RWvistream& operator>>(RWvistream& strm, RWTPtrMultiSet<T,C>& coll); RWvistream& operator>>(RWvistream& strm, RWTPtrOrderedVector<T>& coll); RWvistream& operator>>(RWvistream& strm, RWTPtrSet<T,C>& coll); RWvistream& operator>>(RWvistream& strm, RWTPtrSlist<T>& coll); RWvistream& operator>>(RWvistream& strm, RWTPtrSortedDlist<T,C>& coll); RWvistream& operator>>(RWvistream& strm, RWTPtrSortedVector<T,C>& coll); RWvistream& operator>>(RWvistream& strm, RWTValDeque<T>& coll); RWvistream& operator>>(RWvistream& strm, RWTValDlist<T>& coll); RWvistream& operator>>(RWvistream& strm, RWTValHashMap<T,H,EQ>& coll); RWvistream& operator>>(RWvistream& strm, RWTValHashMultiMap<K,T,H,EQ>& coll); RWvistream& operator>>(RWvistream& strm,
RWTValHashMultiSet<T,H,EQ>& coll); RWvistream& operator>>(RWvistream& strm, RWTValHashSet<T,H,EQ>& coll); RWvistream& operator>>(RWvistream& strm, RWTValMap<K,T,C>& coll); RWvistream& operator>>(RWvistream& strm, RWTValMultiMap<T,C>& coll); RWvistream& operator>>(RWvistream& strm, RWTValMultiSet<K,T,C>& coll); RWvistream& operator>>(RWvistream& strm, RWTValOrderedVector<T>& coll); RWvistream& operator>>(RWvistream& strm, RWTValSet<T,C>& coll); RWvistream& operator>>(RWvistream& strm, RWTValSlist<T>& coll); RWvistream& operator>>(RWvistream& strm, RWTValSortedDlist<T,C>& coll); RWvistream& operator>>(RWvistream& strm, RWTValSortedVector<T,C>& coll);
Restores the contents of the collection coll from the input stream strm.
RWvistream& operator>>(RWvistream& strm, RWTPtrDeque<T>*& p); RWvistream& operator>>(RWvistream& strm, RWTPtrDlist<T>*& p); RWvistream& operator>>(RWvistream& strm, RWTPtrHashMap<K,T,H,EQ>*& p); RWvistream& operator>>(RWvistream& strm, RWTPtrHashMultiMap<K,T,H,EQ>*& p); RWvistream& operator>>(RWvistream& strm, RWTPtrHashMultiSet<T,H,EQ>*& p); RWvistream& operator>>(RWvistream& strm, RWTPtrHashSet<T,H,EQ>*& p); RWvistream& operator>>(RWvistream& strm, RWTPtrMap<K,T,C>*& p); RWvistream& operator>>(RWvistream& strm, RWTPtrMultiMap<K,T,C>*& p); RWvistream& operator>>(RWvistream& strm, RWTPtrMultiSet<T,C>*& p); RWvistream& operator>>(RWvistream& strm, RWTPtrOrderedVector<T>*& p); RWvistream& operator>>(RWvistream& strm, RWTPtrSet<T,C>*& p); RWvistream& operator>>(RWvistream& strm, RWTPtrSlist<T>*& p); RWvistream& operator>>(RWvistream& strm, RWTPtrSortedDlist<T,C>*& p); RWvistream& operator>>(RWvistream& strm, RWTPtrSortedVector<T,C>*& p); RWvistream& operator>>(RWvistream& strm, RWTValDeque<T>*& p); RWvistream& operator>>(RWvistream& strm, RWTValDlist<T>*& p); RWvistream& operator>>(RWvistream& strm, RWTValHashMap<T,H,EQ>*& p); RWvistream& operator>>(RWvistream& strm, RWTHashMultiMap<K,T,H,EQ>*& p); RWvistream& operator>>(RWvistream& strm, RWTValHashMultiSet<T,H,EQ>*& p); RWvistream& operator>>(RWvistream& strm, RWTValHashSet<T,H,EQ>*& p); RWvistream& operator>>(RWvistream& strm, RWTValMap<K,T,C>*& p); RWvistream& operator>>(RWvistream& strm, RWTValMultiMap<K,T,C>*& p); RWvistream& operator>>(RWvistream& strm, RWTValMultiSet<T,C>*& p); RWvistream& operator>>(RWvistream& strm, RWTValOrderedVector<T>*& p); RWvistream& operator>>(RWvistream& strm, RWTValSet<T,C>*& p); RWvistream& operator>>(RWvistream& strm, RWTValSlist<T>*& p); RWvistream& operator>>(RWvistream& strm, RWTValSortedDlist<T,C>*& p); RWvistream& operator>>(RWvistream& strm, RWTValSortedVector<T,C>*& p);
Looks at the next object on the input stream strm and either creates a new collection off the heap and sets p to point to it, or sets p to point to a previously read instance. If a collection is created off the heap, you are responsible for deleting it.
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.