8000 Serializing IDs and mapping them back on deserialization · Issue #860 · USCiLab/cereal · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Serializing IDs and mapping them back on deserialization #860
Open
@Placeblock

Description

@Placeblock

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0