Tools.h++ Manual

104011 Tandem Computers Incorporated 21-197
21
Example
Public member functions
virtual int get() = 0;
Get and return the next char from the input stream, returning its value.
Returns EOF if end of file is encountered.
virtual RWvistream& get(char& c) = 0;
Get the next char from the input stream, returning its value in
c
.
virtual RWvistream& get(wchar_t& wc) = 0;
Get the next wide char from the input stream, returning its value in
wc
.
virtual RWvistream& get(unsigned char& c) = 0;
Get the next char from the input stream, returning its value in
c
.
virtual RWvistream& get(char* v, size_t N) = 0;
Get a vector of char's and store then in the array beginning at
v
. If the restore
is stopped prematurely, get stores whatever it can in
v
, and sets the failbit.
Note – The vector is treated as a vector of numbers, not characters. If you wish
to restore a character string, use function
getString(char*, size_t)
.
virtual RWvistream& get(wchar_t* v, size_t N) = 0;
Get a vector of wide char ’s and store then in the array beginning at
v
. If the
restore is stopped prematurely,
get
stores whatever it can in
v
, and sets the
failbit.
#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";
}