Description
I have two structs like that:
struct Inner {
uint32_t id;
// Some other data...
};
struct Outer {
Inner *node;
template <class Archive>
void serialize(Archive &archive) {
archive(node->id);
}
};
Now I have a bunch of Outer and Inner Objects.
When serializing the Outer objec
5655
ts, I just serialize the ID of the Inner.
The Serialization of the Inner Objects happens elsewhere.
Now I deserialize the Inner Objects to a map like std::map<uint32_t, Inner*>
.
Then I want to deserialize the Outer Objects using Cereal. When deserializing an Outer object, I want to read the ID, look the already deserialized Inner Object up in the map and store it inside the Outer Node. For this I thought an implementation of the load method as mentioned in the documentation could work. This means when deserializing the Outer object I need to have accesss to this map. I do not want the Map to be static. Is there another way to give the deserializer this "context"? Are there other ways to acomplish my goal? Maybe my approach is totally wrong?
Appreciate your time, have a great day :)