I have a tree structure with a lot of pointers, basically a node of the tree is like this
class Node
{
Node *my_father;
QVector<Node*> my_children;
... a lot of data
}
I need all these pointers to make my job easier while in RAM memory. But now I need to save all the tree structure on disk.. I was thinking about using QDataStream serialization (http://www.developer.nokia.com/Community/Wiki/Qt_Object_Serialization).. but I don’t think this is going to work with pointers.. right?
What would you suggest to save this big structure on disk and re-read it into RAM with pointers working?
Why don’t you use the XML format? It’s by design very easy to use with all structured data, with nested objects, like the tree structure you use. But you don’t want to store pointers in it – just the actual data. (The data stored in your pointers, that describe tree structure will become a XML structure itself, so you don’t need them).
Then you’ll need to recreate the pointers during file read, when you allocate a new children for some node.
BTW sorry for making this answer and not comment but I can’t write question comments yet ;].