Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2003-11-12 14:15:07

JOLY Loic wrote:

> For the first kind of difference, I believe that a specialisation of
> MyClass::serialize for specific archives could do the trick, but
> BOOST_CLASS_IMPLEMENTATION does not in any way that I can see depend on
> the underlying archive class.

Actually this might be doable due the the fact that most of the serialzation
code is generically generated at compile time.

currently there is an text_iarchive class defined in text_iarchive.hpp.
Suppose you define your own variant through derivation network_text_iarchive
in network_text_iarchive.hpp


class my_class
        template<class Archive>
        void serialize(Archive &ar, const unsigned int file_version);

// leverage off include guard
BOOST_CLASS_IMPLEMENTATION(T, boost::serialization::object_serializable)
#error - archive.hpp must be included first !

template<class Archive>
void serialize(Archive &ar, const unsigned int file_version){
        ar & ...

This would only require no single program module include more than one archive
and that the archive header is included before the class ones. This would seem
easy to do in my opinion.

I believe this could be made to work and would implement the behavior you desire.

Of course that's not the same as thinking its a great idea. But I don't see any
problem if that's what you want to do.

Note that I am still working on issues related to derivation from archive classes
included with the library but I hope that these will be addressed in the next

Robert Ramey

Boost list run by bdawes at, gregod at, cpdaniel at, john at