title: How can I store a generic tree in a file?
body: <p>I have a generic tree implementation written in C++ that can store any type (int, float, string, etc.) </p>
  
  <pre><code>template&lt;class T&gt; class Tree {
  public:
  // Class interface
  private:
  T node;
  std::list&lt;Tree&lt;T&gt;*&gt;* children;
  };
  </code></pre>
  
  <p>and I have a program (written in C++) that take as input a source tree and give in output another tree based on a set of rules (stored in a file).</p>
  
  <pre><code>Any instance of class A become an instance of class X
  Any instance of class B become an instance of class Y
  Any instance of class C become an instance of class Z
  </code></pre>
  
  <p>For example, suppose I have this input tree A(B(C)) (the node A has B as child and B has C as child). Based on the file of rule my program give me this tree X(Y(Z)). My question is: How can I save in a file the set of rules? How can I store the tree type in this file? I'm thinking to use XML for store the rules, like this</p>
  
  <pre><code>&lt;translationUnit&gt;
    &lt;from&gt;
      &lt;A&gt;
        &lt;B&gt;
          &lt;C&gt;&lt;/C&gt;
        &lt;/B&gt;
      &lt;/A&gt;
    &lt;/from&gt;
    &lt;to&gt;
      &lt;X&gt;
        &lt;Y&gt;
          &lt;Z&gt;&lt;/Z&gt;
        &lt;/Y&gt;
      &lt;/X&gt;
    &lt;to&gt;
  &lt;/translationUnit&gt;
  </code></pre>
  
  <p>but how can I store the class type?</p>