I am trying to serialize / deserialize a game scene to send / receive a network and save / load from / to disk.
My game engine uses nodes and components, and as such, these are the only objects that require serialization. The scene may look like this:
Root Node - Node - SpecializedComponent - SpecializedComponent - Node - Node - Node - Node - Node - Node - Node - SpecializedComponent - Node
A Node is basically:
class Node { map<String, Node> mChildren; map<String, Component> mComponents; uuid_t mId; Node* mParent; };
A SpecializedComponent is basically:
class SpecializedComponent : public Component { uuid_t mId; Node* mNode; };
I would like to use YAML or JSON for my textual representation. I have Qt, Boost, and any other library that I would like to have at my disposal, so dependencies are not a problem. Actually the nodes are already Q_OBJECTS, so I have a reflection.
Despite the reflection, deserializing this correct return to the C ++ tree structure seems to be a problem.
Optimally, I would like to get an elegant and efficient solution for serializing / deserializing such a structure in both binary and text format.
source share