Tools.h++ Manual
3-4 104011 Tandem Computers Incorporated
3
3.3 Common member functions
Whatever category a class might fall into, they all have very similar 
programming interfaces. This section highlights the common functionality.
Persistence
The following functions are used to store an object of type 
ClassName 
to and 
from an 
RWFile 
and to and from the Tools.h++ virtual streams facility and 
then to restore it later:
RWFile& operator<<(RWFile& file, const
ClassName&);
RWFile& operator>>(RWFile& file, ClassName&);
RWvostream& operator<<(RWvostream& vstream,const
ClassName&);
RWvistream& operator>>(RWvistream& vstream, ClassName&);
Class 
RWFile 
encapsulates ANSI-C file I/O and is discussed in detail in 
Chapter 9, “Using Class RWFile” as well as in Chapter , “Class Reference.” 
Objects saved using 
RWFile 
are saved using a binary format, resulting in 
efficient storage and retrieval to files.
Classes 
RWvistream 
and 
RWvostream 
are abstract base classes used by the 
Tools.h++ virtual streams facility. The final output format is determined by the 
specializing class. For example, 
RWpistream 
and 
RWpostream 
are two classes 
that derive from 
RWvistream 
and 
RWvostream
, respectively, that store and 
retrieve objects using a “portable ASCII format”. The results can be transferred 
between different operating systems. These classes are discussed in more 
detail in Chapter 8, “Virtual Streams,” as well as in Chapter 21, “Class 
Reference.”
It is up to the user to decide whether to store to 
RWFile
’s or virtual streams. 
The former offers the advantage of speed, but limits portability of the results to 
the host machine. The latter is not as fast, but there are specializing classes 
(
RWpistream 
and 
RWpostream
) that allow the results to be moved to any 
machine.










