Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 .. )

like image 784
Simon Avatar asked Sep 15 '26 16:09

Simon


1 Answers

For future reference - here it is documented how to version:

https://uscilab.github.io/cereal/serialization_functions.html#versioning

like image 77
Simon Avatar answered Sep 18 '26 06:09

Simon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!