
On Apr 13, 2004, at 9:42 PM, Robert Ramey wrote:
Making a new archive class is described in the section "New Archives - Implementation". The model for an archive class is:
////////////////////////////////////////////////////////////////////// /// // class trivial_iarchive - read serialized objects from a input text stream class trivial_iarchive
: public boost::archive::common_iarchive<trivial_iarchive> { // permit serialization system priledged access to permit // implementation of inline templates for maximum speed. friend class boost::serialization::load_access;
// member template for loading primitive types. // Override for any types/templates that special treatment template<class T> void load(T & t);
public: ////////////////////////////////////////////////////////// // public interface used by programs that use the // serialization library
// the >> operator template<class T> trivial_iarchive & operator>>(T & t){ boost::serialization::load(* This(), t); return * This(); }
// archives are expected to support this function void load_binary(void *address, size_t count);
};
So in theory one has to implement the two undefined functions.
For each primitive data type, int, float, etc. or any type designated as primitive define a "load" template for function to read them from the file.
For each data type that you want to treat specially - rather than allowing the serialization library to do the job - define an overload for the >> operator.
Just a quick question: what should the default load (I mean template<class T> void load(T & t);) function do? Do I guess correctly that it should never be called and is thus undefined to cause link-time errors? Looking through the documentation I find references to virtual functions:
class trivial_iarchive
// all input archives must be derived from this base class. This base // class defines the virtual functions necessary for the serialization // library to handle special types for the serialization system.
I guess that these are incorrect comments left over from an old version? Matthias