Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when opening old version class with variant #843

Open
AdiFogel opened this issue Nov 20, 2024 · 0 comments
Open

Issue when opening old version class with variant #843

AdiFogel opened this issue Nov 20, 2024 · 0 comments

Comments

@AdiFogel
Copy link

AdiFogel commented Nov 20, 2024

I have a type that is defined as:
using PropertiesVariant = sdbusplus::utility::dedup_variant_t<
bool,
std::string>;
using BootOptionDataType =
std::map<std::string, BootOptionDbus::PropertiesVariant>;
using BootOptionsType = std::map<std::string, BootOptionDataType>;

The BootOption maps the property name to its value. The value can be a string of an unknown size and a boolean.
The class has been changed and an additional boolean value has been added. The type actually did not change, because it still a variant of string and boolean.
With the use of versioning, I'm trying to open the binary file, that has the basic class with a code that supports the extended type.
deserialize:
std::ifstream is(path.c_str(), std::ios::in | std::ios::binary);
cereal::BinaryInputArchive iarchive(is);
iarchive(entry);

Load:
Manager::BootOptionsType bootOptionsValues;
archive(bootOptionsValues);

But I'm getting this error:
"Failed cereal to serialize: Invalid 'index' selector when deserializing std::variant"

What is the correct type definition for handling this serialization?
Is there a way that I will be able to deserialize the old file?

Any guidance or insights would be greatly appreciated!

@AdiFogel AdiFogel changed the title Issue when opening old version class Issue when opening old version class with variant Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant