look in

basic_archive.cpp

 

Robert Ramey

"Fred Lupien" <fred.lupien@gmail.com> wrote in message news:32e6d6bf0710241259r1eba133fofb924c86369498c4@mail.gmail.com...
Yea I had thought about this but haven't tried it yet. I am working on this tonight. I have another question that could help me. Is their a documentation available on exactly what is serialized in the archive, the class format and related stuff seem to be serialized as a list of numbers (at least in text archive it appears so, forgive me if I am wrong). What is serialized exactly for each class (beside what the user specifies of course!)?

If found that on a forum but I am not sure how relevant it is (from basic_archive.cpp) :

//////////////////////////////////////////////////////////////////////
//
// class_information is stored as
//
// class_id* // -1 for a null pointer
// if a new class id
// [
// exported key - class name*
// tracking level - always/never
// file version
// ]
//
// if tracking
// [
// object_id
// ]
//
// [ // if a new object id
// data...
// ]
//
// * required only for pointers - optional for objects

Thank you!

On 10/19/07, Robert Ramey <ramey@rrsd.com> wrote:
I've never thought about this, but my first attempt would be something like  the following:
 
template<class Archive>
void load(Archiv &ar , C &c, const unsigned int version){
    if(version < 4>)
        ar >> boost::serialization::base_object<A>(c);
    else
        ar >> boost::serialization::base_object<B>(c);
}
Hello,

      we are currently implementing serialization versioning using boost and I am curious to know if their is a way to support a changing class hierarchy. Let's say C derives from A for a while and then a change requires C to derive from B instead, which derives from A. Is it possible to support such a change provided we know what default values are needed for the new class? I tried and even if don't serialize anything in class C I get stream errors because I believe boost saves some base info for each class. When it tries to reload those value from a old stream, obviously it desynchronizes it because the values are not in the stream. So is their a way around this?

Also is it possible to support the removal of a class. If, for exemple C derives from B which in turn derives from A and suddenly B is removed. Is their a way to deal with this without invalidating all previously saved data?
 
*** I doubt it.  If you want to load old archives, you have know how much to "skip" over.  The only thing that MIGHT be possible
is something like:
template<class Archive>
void load(Archiv &ar , C &c, const unsigned int version){
    if(version < 4>){
        class a; //no longer used
        ar >> a;
        // throw away old data on leaving scope
    }
    else
        ar >> boost::serialization::base_object<B>(c);
}


Thank you for your help!

--
Frédérick Martel-Lupien
Étudiant en Génie Informatique
Université de Sherbrooke
fred.lupien@gmail.com


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users



--
Frédérick Martel-Lupien
Étudiant en Génie Informatique
Université de Sherbrooke
fred.lupien@gmail.com


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users