mercredi 27 mai 2020

C++11 Cereal Serialization - versioning

I have successfully serialized two members of my class.

    archive(
        cereal::make_nvp("width", m_width),
        cereal::make_nvp("height", m_height),
    );

Now, in a later version my code contains more members and I would like to archive them as well:

    archive(
        cereal::make_nvp("width", m_width),
        cereal::make_nvp("height", m_height),
        cereal::make_nvp("lambda0", m_lambda0),
        cereal::make_nvp("phi1", m_phi1)
    );

However, this crashes as the new members are not present in old archives. As far as I know there is no way of having default values defined for these variables in make_nvp.

But there for sure has to be some kind of versioning so that this default circumstance can be solved? Could someone point me to the documentation of this or even better to some sample code? I can't find anything on there official website. ( But most likely I am just blind .. )

Aucun commentaire:

Enregistrer un commentaire