Add RW_DECLARE_PERSISTABLE to Your Header File
Once you have determined that all necessary class data is accessible, you must add declaration statements to your header files. These statements declare the global functions operator<< and operator>> for your class. The global functions permit storage to and retrieval from RWvistream, RWvostream and RWFile.
The Essential Tools Module provides several macros that make adding these declarations easy. The macro you choose depends upon whether your class is templatized or not, and if it is templatized, how many templatized parameters it has.
*For non-templatized classes, use RW_DECLARE_PERSISTABLE.
RW_DECLARE_PERSISTABLE is a macro found in rw/edefs.h . To use it, add the following lines to your header file (*.h ):
 
#include <rw/edefs.h>
RW_DECLARE_PERSISTABLE(YourClass)
RW_DECLARE_PERSISTABLE(YourClass) will expand to declare the following global functions:
 
RWvostream& operator<<(RWvostream& strm, const YourClass& item);
RWvistream& operator>>(RWvistream& strm, YourClass& obj);
RWvistream& operator>>(RWvistream& strm, YourClass*& pObj);
RWFile& operator<<(RWFile& strm, const YourClass& item);
RWFile& operator>>(RWFile& strm, YourClass& obj);
RWFile& operator>>(RWFile& strm, YourClass*& pObj);
*For templatized classes with a single template parameter T, use the macro RW_DECLARE_PERSISTABLE_TEMPLATE.
RW_DECLARE_PERSISTABLE_TEMPLATE is also found in rw/edefs.h . To use it, add the following lines to your header file (*.h ):
 
#include <rw/edefs.h>
RW_DECLARE_PERSISTABLE_TEMPLATE(YourClass)
The macro RW_DECLARE_PERSISTABLE_TEMPLATE(YourClass) will expand to declare the following global functions:
 
template<class T>
RWvostream& operator<<
(RWvostream& strm, const YourClass<T>& item);
template<class T>
RWvistream& operator>>
(RWvistream& strm, YourClass<T>& obj);
template<class T>
RWvistream& operator>>
(RWvistream& strm, YourClass<T>*& pObj);
template<class T>
RWFile& operator<<(RWFile& strm, const YourClass<T>& item);
template<class T>
RWFile& operator>>(RWFile& strm, YourClass<T>& obj);
template<class T>
RWFile& operator>>(RWFile& strm, YourClass<T>*& pObj);
*For templatized classes with more than one and less than five template parameters, use one of the following macros from rw/edefs.h.:
 
// For YourClass<T1,T2>:
RW_DECLARE_PERSISTABLE_TEMPLATE_2(YourClass)
// For YourClass<T1,T2,T3>:
RW_DECLARE_PERSISTABLE_TEMPLATE_3(YourClass)
// For YourClass<T1,T2,T3,T4>:
RW_DECLARE_PERSISTABLE_TEMPLATE_4(YourClass)
*If you need to persist templatized classes with five or more template parameters, you can write additional macros for RW_DECLARE_PERSISTABLE_TEMPLATE_n. The macros are found in the header file rw/edefs.h.