xml.html 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <link rel='stylesheet' type='text/css' href='../style.css' >
  5. <title>libigl file formats | .xml</title>
  6. </head>
  7. <body class=article_outer>
  8. <div class=article_inner>
  9. <a href=..><img src=../libigl-logo.jpg alt="igl logo" class=center></a>
  10. <h1>.xml - serialization format</h1>
  11. <hr>
  12. <p>
  13. A .xml file contains the serialization of an object data structure generated with the XMLSerializer:
  14. </p>
  15. <p>
  16. The top level elements represent the groups in which the object are organised. The object names are unique within these groups.
  17. </p>
  18. <pre><code>&lt;group1&gt;
  19. &lt;object1 val="value of object 1"/&gt;
  20. &lt;object2 val="value of object 2"/&gt;
  21. &lt;/group1&gt;
  22. &lt;group2&gt;
  23. &lt;object1 val="value of object 1"/&gt;
  24. &lt;/group2&gt;</code></pre>
  25. <p>
  26. An object can be of following type:<br/>
  27. <br/>
  28. Basic types: <b>char, char*, std::string, bool, usigned int, int, float, double</b><br/>
  29. STL containers: <b>std::array, std::vector, std::pair</b><br/>
  30. Eigen types: <b>Eigen::Matrix, Eigen::SparseMatrix</b><br/>
  31. User defined types: <b>XMLSerializable*.</b><br/>
  32. <br/>
  33. There can also be a hierachical structure like vector&lt;int&gt;, this will result in the following serialization:
  34. </p>
  35. <pre><code>&lt;group&gt;
  36. &lt;vector size="3"&gt;
  37. &lt;value0 val="1"/&gt;
  38. &lt;value1 val="2"/&gt;
  39. &lt;value2 val="3"/&gt;
  40. &lt;/vector&gt;
  41. &lt;/group&gt;</code></pre>
  42. <p>An example of a serialization of an instance of the class Test</p>
  43. <pre><code>class Test{
  44. int var1;
  45. vector&ltfloat&gt; vec1;
  46. };</code></pre>
  47. <p> is shown here:</p>
  48. <pre><code>&lt;group&gt;
  49. &lt;Test&gt;
  50. &lt;var1 val="0"&gt;
  51. &lt;vec1 size="2"&gt;
  52. &lt;value0 val="1"/&gt;
  53. &lt;value1 val="2"/&gt;
  54. &lt;/vector&gt;
  55. &lt;/Test&gt;
  56. &lt;/group&gt;</code></pre>
  57. <p>In the following we show the serialization of Eigen matrices.</p>
  58. <p>Eigen::Matrix&lt;int,4,3&gt;:</p>
  59. <pre><code>&lt;group&gt;
  60. &lt;matrix row="4" col="3" matrix="
  61. 1,2,3,
  62. 4,5,6,
  63. 7,8,9,
  64. 10,11,12/&gt;
  65. &lt;/group&gt;</code></pre>
  66. <p>Eigen::SparseMatrix&lt;int&gt; (3x3 identity saved as triplets of the non-zero entries):</p>
  67. <pre><code>&lt;group&gt;
  68. &lt;matrix row="3" col="3" matrix="
  69. 0,0,1,
  70. 1,1,1,
  71. 2,2,1/&gt;
  72. &lt;/group&gt;</code></pre>
  73. <p>See also: <a href=.>file formats</a></p>
  74. </div>
  75. </body>
  76. </html>