瀏覽代碼

more flexible xml serialization (xml code is still a mess)

Former-commit-id: d2819f920fa332d5a9133855320d770c269da647
Alec Jacobson 9 年之前
父節點
當前提交
5249914675
共有 3 個文件被更改,包括 368 次插入228 次删除
  1. 224 0
      include/igl/xml/XMLSerializable.h
  2. 77 147
      include/igl/xml/serialize_xml.cpp
  3. 67 81
      include/igl/xml/serialize_xml.h

+ 224 - 0
include/igl/xml/XMLSerializable.h

@@ -0,0 +1,224 @@
+#ifndef IGL_XML_XMLSERIALIZABLE_H
+#define IGL_XML_XMLSERIALIZABLE_H
+
+#include "../igl_inline.h"
+#include "../serialize.h"
+
+#include <tinyxml2.h>
+
+
+// Interface for xml-serializable class see serialize_xml.h
+
+// Pretty sure all of these IGL_INLINE should be inline
+ 
+namespace igl
+{
+  namespace xml
+  {
+    // interface for user defined types
+    struct XMLSerializableBase : public SerializableBase
+    {
+      virtual void Serialize(std::vector<char>& buffer) const = 0;
+      virtual void Deserialize(const std::vector<char>& buffer) = 0;
+      virtual void Serialize(tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element) const = 0;
+      virtual void Deserialize(const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element) = 0;
+    };
+
+    // Convenient interface for user defined types
+    class XMLSerializable: public XMLSerializableBase
+    {
+    private:
+  
+      template <typename T>
+      struct XMLSerializationObject: public XMLSerializableBase
+      {
+        bool Binary;
+        std::string Name;
+        T* Object;
+  
+        void Serialize(std::vector<char>& buffer) const {
+          serialize(*Object,Name,buffer);
+        }
+  
+        void Deserialize(const std::vector<char>& buffer) {
+          deserialize(*Object,Name,buffer);
+        }
+  
+        void Serialize(tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element) const {
+          serialize_xml(*Object,Name,doc,element,Binary);
+        }
+  
+        void Deserialize(const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element) {
+          deserialize_xml(*Object,Name,doc,element);
+        }
+      };
+  
+      mutable bool initialized;
+      mutable std::vector<XMLSerializableBase*> objects;
+  
+    public:
+  
+      // Override this function to add your member variables which should be serialized
+      IGL_INLINE virtual void InitSerialization() = 0;
+  
+      // Following functions can be overridden to handle the specific events.
+      // Return false to prevent the de-/serialization of an object.
+      IGL_INLINE virtual bool PreSerialization() const;
+      IGL_INLINE virtual void PostSerialization() const;
+      IGL_INLINE virtual bool PreDeserialization();
+      IGL_INLINE virtual void PostDeserialization();
+  
+      // Default implementation of XMLSerializableBase interface
+      IGL_INLINE void Serialize(std::vector<char>& buffer) const;
+      IGL_INLINE void Deserialize(const std::vector<char>& buffer);
+      IGL_INLINE void Serialize(tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element) const;
+      IGL_INLINE void Deserialize(const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element);
+  
+      // Default constructor, destructor, assignment and copy constructor
+      IGL_INLINE XMLSerializable();
+      IGL_INLINE XMLSerializable(const XMLSerializable& obj);
+      IGL_INLINE ~XMLSerializable();
+      IGL_INLINE XMLSerializable& operator=(const XMLSerializable& obj);
+  
+      // Use this function to add your variables which should be serialized
+      template <typename T>
+      IGL_INLINE void Add(T& obj,std::string name,bool binary = false);
+    };
+ 
+    // IMPLEMENTATION
+
+    IGL_INLINE bool XMLSerializable::PreSerialization() const
+    { 
+      return true;
+    }
+    
+    IGL_INLINE void XMLSerializable::PostSerialization() const
+    {
+    }
+    
+    IGL_INLINE bool XMLSerializable::PreDeserialization()
+    { 
+      return true;
+    }
+  
+    IGL_INLINE void XMLSerializable::PostDeserialization() 
+    {
+    }
+  
+    IGL_INLINE void XMLSerializable::Serialize(std::vector<char>& buffer) const
+    {
+      if(this->PreSerialization())
+      {
+        if(initialized == false)
+        {
+          objects.clear();
+          (const_cast<XMLSerializable*>(this))->InitSerialization();
+          initialized = true;
+        }
+  
+        for(unsigned int i=0;i<objects.size();i++)
+          objects[i]->Serialize(buffer);
+  
+        this->PostSerialization();
+      }
+    }
+  
+    IGL_INLINE void XMLSerializable::Deserialize(const std::vector<char>& buffer)
+    {
+      if(this->PreDeserialization())
+      {
+        if(initialized == false)
+        {
+          objects.clear();
+          (const_cast<XMLSerializable*>(this))->InitSerialization();
+          initialized = true;
+        }
+  
+        for(unsigned int i=0;i<objects.size();i++)
+          objects[i]->Deserialize(buffer);
+  
+        this->PostDeserialization();
+      }
+    }
+  
+    IGL_INLINE void XMLSerializable::Serialize(tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element) const
+    {
+      if(this->PreSerialization())
+      {
+        if(initialized == false)
+        {
+          objects.clear();
+          (const_cast<XMLSerializable*>(this))->InitSerialization();
+          initialized = true;
+        }
+  
+        for(unsigned int i=0;i<objects.size();i++)
+          objects[i]->Serialize(doc,element);
+  
+        this->PostSerialization();
+      }
+    }
+  
+    IGL_INLINE void XMLSerializable::Deserialize(const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element)
+    {
+      if(this->PreDeserialization())
+      {
+        if(initialized == false)
+        {
+          objects.clear();
+          (const_cast<XMLSerializable*>(this))->InitSerialization();
+          initialized = true;
+        }
+  
+        for(unsigned int i=0;i<objects.size();i++)
+          objects[i]->Deserialize(doc,element);
+  
+        this->PostDeserialization();
+      }
+    }
+  
+    IGL_INLINE XMLSerializable::XMLSerializable()
+    {
+      initialized = false;
+    }
+  
+    IGL_INLINE XMLSerializable::XMLSerializable(const XMLSerializable& obj)
+    {
+      initialized = false;
+      objects.clear();
+    }
+  
+    IGL_INLINE XMLSerializable::~XMLSerializable()
+    {
+      initialized = false;
+      objects.clear();
+    }
+  
+  
+    IGL_INLINE XMLSerializable& XMLSerializable::operator=(const XMLSerializable& obj)
+    {
+      if(this != &obj)
+      {
+        if(initialized)
+        {
+          initialized = false;
+          objects.clear();
+        }
+      }
+      return *this;
+    }
+  
+    template <typename T>
+    IGL_INLINE void XMLSerializable::Add(T& obj,std::string name,bool binary)
+    {
+      XMLSerializationObject<T>* object = new XMLSerializationObject<T>();
+      object->Binary = binary;
+      object->Name = name;
+      object->Object = &obj;
+  
+      objects.push_back(object);
+    }
+    
+  }
+}
+#endif

+ 77 - 147
include/igl/xml/serialize_xml.cpp

@@ -7,20 +7,32 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 
 #include "serialize_xml.h"
+#include "../STR.h"
+#include "../serialize.h"
+
 #include <iterator>
+#include <limits>
+#include <iomanip>
 
 namespace igl
 {
   namespace xml
   {
     template <typename T>
-    IGL_INLINE void serialize_xml(const T& obj,const std::string& filename)
+    IGL_INLINE void serialize_xml(
+      const T& obj,
+      const std::string& filename)
     {
       serialize_xml(obj,"object",filename,false,true);
     }
   
     template <typename T>
-    IGL_INLINE void serialize_xml(const T& obj,const std::string& objectName,const std::string& filename,bool binary,bool overwrite)
+    IGL_INLINE void serialize_xml(
+      const T& obj,
+      const std::string& objectName,
+      const std::string& filename,
+      bool binary,
+      bool overwrite)
     {
       tinyxml2::XMLDocument* doc = new tinyxml2::XMLDocument();
   
@@ -54,9 +66,16 @@ namespace igl
     }
   
     template <typename T>
-    IGL_INLINE void serialize_xml(const T& obj,const std::string& objectName,tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element,bool binary)
+    IGL_INLINE void serialize_xml(
+      const T& obj,
+      const std::string& objectName,
+      tinyxml2::XMLDocument* doc,
+      tinyxml2::XMLElement* element,
+      bool binary)
     {
-      static_assert(serialization_xml::is_serializable<T>::value,"'igl::xml::serialize_xml': type is not serializable");
+      static_assert(
+        serialization_xml::is_serializable<T>::value,
+        "'igl::xml::serialize_xml': type is not serializable");
   
       std::string name(objectName);
       serialization_xml::encodeXMLElementName(name);
@@ -73,7 +92,10 @@ namespace igl
       {
         std::vector<char> buffer;
         serialize(obj,name,buffer);
-        std::string data = serialization_xml::base64_encode(reinterpret_cast<const unsigned char*>(buffer.data()),buffer.size());
+        std::string data = 
+          serialization_xml::base64_encode(
+            reinterpret_cast<const unsigned char*>(
+              buffer.data()),buffer.size());
         
         child->SetAttribute("binary",true);
   
@@ -150,139 +172,7 @@ namespace igl
         }
       }
     }
-  
-    IGL_INLINE bool XMLSerializable::PreSerialization() const
-    { 
-      return true;
-    }
-    
-    IGL_INLINE void XMLSerializable::PostSerialization() const
-    {
-    }
-    
-    IGL_INLINE bool XMLSerializable::PreDeserialization()
-    { 
-      return true;
-    }
-  
-    IGL_INLINE void XMLSerializable::PostDeserialization() 
-    {
-    }
-  
-    IGL_INLINE void XMLSerializable::Serialize(std::vector<char>& buffer) const
-    {
-      if(this->PreSerialization())
-      {
-        if(initialized == false)
-        {
-          objects.clear();
-          (const_cast<XMLSerializable*>(this))->InitSerialization();
-          initialized = true;
-        }
-  
-        for(unsigned int i=0;i<objects.size();i++)
-          objects[i]->Serialize(buffer);
-  
-        this->PostSerialization();
-      }
-    }
-  
-    IGL_INLINE void XMLSerializable::Deserialize(const std::vector<char>& buffer)
-    {
-      if(this->PreDeserialization())
-      {
-        if(initialized == false)
-        {
-          objects.clear();
-          (const_cast<XMLSerializable*>(this))->InitSerialization();
-          initialized = true;
-        }
-  
-        for(unsigned int i=0;i<objects.size();i++)
-          objects[i]->Deserialize(buffer);
-  
-        this->PostDeserialization();
-      }
-    }
-  
-    IGL_INLINE void XMLSerializable::Serialize(tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element) const
-    {
-      if(this->PreSerialization())
-      {
-        if(initialized == false)
-        {
-          objects.clear();
-          (const_cast<XMLSerializable*>(this))->InitSerialization();
-          initialized = true;
-        }
-  
-        for(unsigned int i=0;i<objects.size();i++)
-          objects[i]->Serialize(doc,element);
-  
-        this->PostSerialization();
-      }
-    }
-  
-    IGL_INLINE void XMLSerializable::Deserialize(const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element)
-    {
-      if(this->PreDeserialization())
-      {
-        if(initialized == false)
-        {
-          objects.clear();
-          (const_cast<XMLSerializable*>(this))->InitSerialization();
-          initialized = true;
-        }
-  
-        for(unsigned int i=0;i<objects.size();i++)
-          objects[i]->Deserialize(doc,element);
-  
-        this->PostDeserialization();
-      }
-    }
-  
-    IGL_INLINE XMLSerializable::XMLSerializable()
-    {
-      initialized = false;
-    }
-  
-    IGL_INLINE XMLSerializable::XMLSerializable(const XMLSerializable& obj)
-    {
-      initialized = false;
-      objects.clear();
-    }
-  
-    IGL_INLINE XMLSerializable::~XMLSerializable()
-    {
-      initialized = false;
-      objects.clear();
-    }
-  
-  
-    IGL_INLINE XMLSerializable& XMLSerializable::operator=(const XMLSerializable& obj)
-    {
-      if(this != &obj)
-      {
-        if(initialized)
-        {
-          initialized = false;
-          objects.clear();
-        }
-      }
-      return *this;
-    }
-  
-    template <typename T>
-    IGL_INLINE void XMLSerializable::Add(T& obj,std::string name,bool binary)
-    {
-      XMLSerializationObject<T>* object = new XMLSerializationObject<T>();
-      object->Binary = binary;
-      object->Name = name;
-      object->Object = &obj;
-  
-      objects.push_back(object);
-    }
-  
+
     namespace serialization_xml
     {
       // fundamental types
@@ -510,10 +400,14 @@ namespace igl
           obj.clear();
         }
       }
-  
-      // Eigen types
+
       template<typename T,int R,int C,int P,int MR,int MC>
-      IGL_INLINE void serialize(const Eigen::Matrix<T,R,C,P,MR,MC>& obj,tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element,const std::string& name)
+      IGL_INLINE void serialize(
+        const Eigen::Matrix<T,R,C,P,MR,MC>& obj,
+        const std::string& name,
+        const std::function<std::string(const T &) >& to_string,
+        tinyxml2::XMLDocument* doc,
+        tinyxml2::XMLElement* element)
       {
         tinyxml2::XMLElement* matrix = getElement(doc,element,name.c_str());
   
@@ -523,15 +417,13 @@ namespace igl
         matrix->SetAttribute("rows",rows);
         matrix->SetAttribute("cols",cols);
   
-        char buffer[200];
         std::stringstream ms;
         ms << "\n";
         for(unsigned int r=0;r<rows;r++)
         {
           for(unsigned int c=0;c<cols;c++)
           {
-            tinyxml2::XMLUtil::ToStr(obj(r,c),buffer,200);
-            ms << buffer << ",";
+            ms << to_string(obj(r,c)) << ",";
           }
           ms << "\n";
         }
@@ -543,8 +435,29 @@ namespace igl
         matrix->SetAttribute("matrix",mString.c_str());
       }
   
+      // Eigen types
+      template<typename T,int R,int C,int P,int MR,int MC>
+      IGL_INLINE void serialize(
+        const Eigen::Matrix<T,R,C,P,MR,MC>& obj,
+        tinyxml2::XMLDocument* doc,
+        tinyxml2::XMLElement* element,
+        const std::string& name)
+      {
+        const std::function<std::string(const T &) > to_string = 
+          [](const T & v)->std::string
+          {
+            return
+              STR(std::setprecision(std::numeric_limits<double>::digits10+2)<<v);
+          };
+        serialize(obj,name,to_string,doc,element);
+      }
       template<typename T,int R,int C,int P,int MR,int MC>
-      IGL_INLINE void deserialize(Eigen::Matrix<T,R,C,P,MR,MC>& obj,const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element,const std::string& name)
+      IGL_INLINE void deserialize(
+        const tinyxml2::XMLDocument* doc,
+        const tinyxml2::XMLElement* element,
+        const std::string& name,
+        const std::function<void(const std::string &,T &)> & from_string,
+        Eigen::Matrix<T,R,C,P,MR,MC>& obj)
       {
         const tinyxml2::XMLElement* child = element->FirstChildElement(name.c_str());
         bool initialized = false;
@@ -583,11 +496,13 @@ namespace igl
   
                   // push pack the data if any
                   if(!val.empty())
-                    getAttribute(val.c_str(),obj.coeffRef(r,c));
+                  {
+                    from_string(val,obj.coeffRef(r,c));
+                  }
                 }
   
                 getline(liness,val);
-                getAttribute(val.c_str(),obj.coeffRef(r,cols-1));
+                from_string(val,obj.coeffRef(r,cols-1));
   
                 r++;
               }
@@ -602,6 +517,21 @@ namespace igl
         }
       }
   
+      template<typename T,int R,int C,int P,int MR,int MC>
+      IGL_INLINE void deserialize(
+        Eigen::Matrix<T,R,C,P,MR,MC>& obj,
+        const tinyxml2::XMLDocument* doc,
+        const tinyxml2::XMLElement* element,
+        const std::string& name)
+      {
+        const std::function<void(const std::string &,T &)> & from_string = 
+          [](const std::string & s,T & v)
+          {
+            getAttribute(s.c_str(),v);
+          };
+        deserialize(doc,element,name,from_string,obj);
+      }
+  
       template<typename T,int P,typename I>
       IGL_INLINE void serialize(const Eigen::SparseMatrix<T,P,I>& obj,tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element,const std::string& name)
       {

+ 67 - 81
include/igl/xml/serialize_xml.h

@@ -17,20 +17,20 @@
 
 #include "../igl_inline.h"
 
+#include "XMLSerializable.h"
+
+#include <Eigen/Dense>
+#include <Eigen/Sparse>
+#include <tinyxml2.h>
+
 #include <type_traits>
+#include <functional>
 #include <iostream>
 #include <vector>
 #include <set>
 #include <map>
 #include <memory>
 
-#include <Eigen/Dense>
-#include <Eigen/Sparse>
-
-#include <igl/serialize.h>
-
-#include "tinyxml2.h"
-
 //#define SERIALIZE_XML(x) igl::xml::serialize_xml(x,#x,doc,element);
 //#define DESERIALIZE_XML(x) igl::xml::deserialize_xml(x,#x,,doc,element);
 
@@ -55,9 +55,19 @@ namespace igl
     template <typename T>
     IGL_INLINE void serialize_xml(const T& obj,const std::string& filename);
     template <typename T>
-    IGL_INLINE void serialize_xml(const T& obj,const std::string& objectName,const std::string& filename, bool binary = false,bool overwrite = false);
+    IGL_INLINE void serialize_xml(
+      const T& obj,
+      const std::string& objectName,
+      const std::string& filename, 
+      bool binary = false,
+      bool overwrite = false);
     template <typename T>
-    IGL_INLINE void serialize_xml(const T& obj,const std::string& objectName,tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element,bool binary = false);
+    IGL_INLINE void serialize_xml(
+      const T& obj,
+      const std::string& objectName,
+      tinyxml2::XMLDocument* doc,
+      tinyxml2::XMLElement* element,
+      bool binary = false);
   
     // deserializes the given data from a xml file or doc data back to the provided object
     //
@@ -81,76 +91,6 @@ namespace igl
     template <typename T>
     IGL_INLINE void deserialize_xml(T& obj,const std::string& objectName,const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element);
   
-    // interface for user defined types
-    struct XMLSerializableBase : public SerializableBase
-    {
-      virtual void Serialize(std::vector<char>& buffer) const = 0;
-      virtual void Deserialize(const std::vector<char>& buffer) = 0;
-      virtual void Serialize(tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element) const = 0;
-      virtual void Deserialize(const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element) = 0;
-    };
-  
-    // Convenient interface for user defined types
-    class XMLSerializable: public XMLSerializableBase
-    {
-    private:
-  
-      template <typename T>
-      struct XMLSerializationObject: public XMLSerializableBase
-      {
-        bool Binary;
-        std::string Name;
-        T* Object;
-  
-        void Serialize(std::vector<char>& buffer) const {
-          serialize(*Object,Name,buffer);
-        }
-  
-        void Deserialize(const std::vector<char>& buffer) {
-          deserialize(*Object,Name,buffer);
-        }
-  
-        void Serialize(tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element) const {
-          serialize_xml(*Object,Name,doc,element,Binary);
-        }
-  
-        void Deserialize(const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element) {
-          deserialize_xml(*Object,Name,doc,element);
-        }
-      };
-  
-      mutable bool initialized;
-      mutable std::vector<XMLSerializableBase*> objects;
-  
-    public:
-  
-      // Override this function to add your member variables which should be serialized
-      IGL_INLINE virtual void InitSerialization() = 0;
-  
-      // Following functions can be overridden to handle the specific events.
-      // Return false to prevent the de-/serialization of an object.
-      IGL_INLINE virtual bool PreSerialization() const;
-      IGL_INLINE virtual void PostSerialization() const;
-      IGL_INLINE virtual bool PreDeserialization();
-      IGL_INLINE virtual void PostDeserialization();
-  
-      // Default implementation of XMLSerializableBase interface
-      IGL_INLINE void Serialize(std::vector<char>& buffer) const;
-      IGL_INLINE void Deserialize(const std::vector<char>& buffer);
-      IGL_INLINE void Serialize(tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element) const;
-      IGL_INLINE void Deserialize(const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element);
-  
-      // Default constructor, destructor, assignment and copy constructor
-      IGL_INLINE XMLSerializable();
-      IGL_INLINE XMLSerializable(const XMLSerializable& obj);
-      IGL_INLINE ~XMLSerializable();
-      IGL_INLINE XMLSerializable& operator=(const XMLSerializable& obj);
-  
-      // Use this function to add your variables which should be serialized
-      template <typename T>
-      IGL_INLINE void Add(T& obj,std::string name,bool binary = false);
-    };
-  
     // internal functions
     namespace serialization_xml
     {
@@ -192,10 +132,56 @@ namespace igl
       IGL_INLINE void deserialize(std::map<T1,T2>& obj,const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element,const std::string& name);
   
       // Eigen types
+
+      // Serialize a Dense Eigen Matrix to xml (in the matrix= attribute,
+      // awkward...)
+      //
+      // Inputs:
+      //   obj  MR by MC matrix of T types
+      //   name  name of matrix
+      //   to_string  function converting T to string
+      // Outputs:
+      //   doc  pointer to xml document
+      //   element  pointer to xml element
+      //   
+      template<typename T,int R,int C,int P,int MR,int MC>
+      IGL_INLINE void serialize(
+        const Eigen::Matrix<T,R,C,P,MR,MC>& obj,
+        const std::string& name,
+        const std::function<std::string(const T &) >& to_string,
+        tinyxml2::XMLDocument* doc,
+        tinyxml2::XMLElement* element);
+      // De-Serialize a Dense Eigen Matrix from xml (in the matrix= attribute,
+      // awkward...)
+      //
+      // Inputs:
+      //   doc  pointer to xml document
+      //   element  pointer to xml element
+      //   name  name of matrix
+      //   from_string  function string to T
+      // Outputs:
+      //   obj  MR by MC matrix of T types
+      template<typename T,int R,int C,int P,int MR,int MC>
+      IGL_INLINE void deserialize(
+        const tinyxml2::XMLDocument* doc,
+        const tinyxml2::XMLElement* element,
+        const std::string& name,
+        const std::function<void(const std::string &,T &)> & from_string,
+        Eigen::Matrix<T,R,C,P,MR,MC>& obj);
+  
+      // Legacy APIs
       template<typename T,int R,int C,int P,int MR,int MC>
-      IGL_INLINE void serialize(const Eigen::Matrix<T,R,C,P,MR,MC>& obj,tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element,const std::string& name);
+      IGL_INLINE void serialize(
+        const Eigen::Matrix<T,R,C,P,MR,MC>& obj,
+        tinyxml2::XMLDocument* doc,
+        tinyxml2::XMLElement* element,
+        const std::string& name);
       template<typename T,int R,int C,int P,int MR,int MC>
-      IGL_INLINE void deserialize(Eigen::Matrix<T,R,C,P,MR,MC>& obj,const tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element,const std::string& name);
+      IGL_INLINE void deserialize(
+        Eigen::Matrix<T,R,C,P,MR,MC>& obj,
+        const tinyxml2::XMLDocument* doc,
+        const tinyxml2::XMLElement* element,
+        const std::string& name);
   
       template<typename T,int P,typename I>
       IGL_INLINE void serialize(const Eigen::SparseMatrix<T,P,I>& obj,tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element,const std::string& name);