title: Dump and restore a tree data structure to/from a file
body: <p>I have a n-ary tree data structure with a specific set of classes. The data structure goes through a set of transformations say 1 to n. At the end of the above transformations, the final tree is the output result which gets used to retrieve information.  </p>
  
  <p>Is there a way that I can (binary) dump the tree after every correct transformation. The dump will reflect the state of the tree after the previous transformation. Thus, if any transformation goes wrong, I can restore the dump in memory w/o going through the correct transformation again. It's similar to the <strong><em>Checkpoint functionality that GDB</em></strong> provides to save the snapshot of the program's state.  </p>
  
  <ul>
  <li>I looked at NoSQL databases like MongoDB, CouchDB, Redis etc but they are primarily key-value datastores(Redis) or store the information in document-type structure w/o storing the associations/relationships between the nodes in a tree(MongoDB). </li>
  <li>I also looked at Neo4j graph database, which is a great tool for representing graph-like structures. </li>
  </ul>
  
  <p><a href="https://stackoverflow.com/a/6005242/355722">Redis-dump</a>, <a href="https://stackoverflow.com/a/17881285/355722">Neo4j-dump</a> and <a href="http://docs.mongodb.org/manual/reference/program/mongodump/" rel="nofollow noreferrer">MongoDB-dump</a> are available but I am not able to decide which one to pick among these. Which of the above would be easier to populate as the dump creation and restore time should not be large.</p>
  
  <p>I wanted to know the opinion and feedback from fellow programmers who have faced this problem 
   and how did they solve it. What would be the best way of doing this?  </p>
  
  <p>P.S. My existing implementation is in C++. Let me know if anything is unclear and I'll try to explain it in a better way.</p>