Boost logo

Boost Users :

From: Robert Bielik (robert.bielik_at_[hidden])
Date: 2008-02-01 04:57:28


I need to update the version certain objects in my structure, but I cannot get the version
number incremented.

Scenario:

I have a class MyClass which have several entries of InternalClass objects (which is the one
I want a new version of):

class MyClass
{
    ...
    template<class Archive>
    void serialize(Archive & ar, const unsigned int version)
    {
       ar & BOOST_SERIALIZATION("MyInternals", m_vector_of_internal_class_objects);
    }

    std::vector<InternalClass> m_vector_of_internal_class_objects;

    class InternalClass
    {
       template<class Archive>
       void save(Archive & ar, const unsigned int version) const
       {
          ar & BOOST_SERIALIZATION("data", m_data);
       }

       template<class Archive>
       void load(Archive & ar, const unsigned int version)
       {
          if (version == 0)
          {
             old_data_t tmp;
             ar & BOOST_SERIALIZATION("data", tmp);
             m_data = convertToNewData(tmp);
          }
          else
          {
             BOOST_CHECK(version == 1);
             ar & BOOST_SERIALIZATION("data", m_data);
          }
       }
       BOOST_SERIALIZATION_SPLIT_MEMBER()

       new_data_t m_data;
    }
}

Then in the body (.cpp) I define:

BOOST_CLASS_VERSION(MyClass::InternalClass, boost::serialization::object_class_info)
BOOST_CLASS_VERSION(MyClass::InternalClass, 1)

But when saving to the XML archive file, I still get version="0" for the InternalClass objects (?)

/R


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net