Bläddra i källkod

rm old version of xml

Former-commit-id: 4af2074344e34678a2c27a8d312a1162d233e1b4
Alec Jacobson 10 år sedan
förälder
incheckning
64af5b8a83

+ 0 - 259
include/igl/xml/old_version/ReAntTweakBarXMLSerialization.h

@@ -1,259 +0,0 @@
-// 
-// Copyright (C) 2014 Christian Schüller <schuellchr@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-
-#ifndef IGL_REANTTWEAKBAR_XML_SERIALIZATION_H
-#define IGL_REANTTWEAKBAR_XML_SERIALIZATION_H
-#include "../igl_inline.h"
-#include "XMLSerializer.h"
-
-#undef IGL_HEADER_ONLY
-#include <igl/ReAntTweakBar.h>
-
-// Forward declarations
-namespace igl
-{
-  class ReTwBar;
-};
-namespace tinyxml2
-{
-  class XMLDocument;
-};
-
-namespace igl
-{
-  
-//  namespace
-//  {
-  
-//    IGL_INLINE bool save_ReAntTweakBar(::igl::ReTwBar* bar, const char* file_name);
-//    IGL_INLINE bool save_ReAntTweakBar(::igl::ReTwBar* bar, tinyxml2::XMLDocument* doc);
-//    IGL_INLINE bool load_ReAntTweakBar(::igl::ReTwBar* bar, const char *file_name);
-//    IGL_INLINE bool load_ReAntTweakBar(::igl::ReTwBar* bar, tinyxml2::XMLDocument* doc);
-    
-    
-    IGL_INLINE bool save_ReAntTweakBar(::igl::ReTwBar* bar, const char* file_name)
-    {
-      const char * name_chars = TwGetBarName(bar->bar);
-      std::string name = std::string(name_chars) + "_AntTweakBar";
-      
-      const std::vector< ::igl::ReTwRWItem>& rw_items = bar->get_rw_items();
-      for(std::vector< ::igl::ReTwRWItem>::const_iterator it = rw_items.begin(); it != rw_items.end(); it++)
-      {
-        std::string val = bar->get_value_as_string(it->var,it->type);
-        ::igl::XMLSerializer::SaveObject(val,it->name,name,file_name,false);
-      }
-      
-      char var[REANTTWEAKBAR_MAX_CB_VAR_SIZE];
-      // Print all CB variables
-      const std::vector< ::igl::ReTwCBItem>& cb_items = bar->get_cb_items();
-      for(std::vector< ::igl::ReTwCBItem>::const_iterator it = cb_items.begin(); it != cb_items.end(); it++)
-      {
-        TwType type = it->type;
-        //TwSetVarCallback setCallback = it->setCallback;
-        TwGetVarCallback getCallback = it->getCallback;
-        void * clientData = it->clientData;
-        // I'm not sure how to do what I want to do. getCallback needs to be sure
-        // that it can write to var. So var needs to point to a valid and big
-        // enough chunk of memory
-        getCallback(var,clientData);
-        
-        std::string val = bar->get_value_as_string(var,type);
-        ::igl::XMLSerializer::SaveObject(val,it->name,name,file_name,false);
-      }
-      
-      return true;
-    }
-    
-    IGL_INLINE bool save_ReAntTweakBar(::igl::ReTwBar* bar, tinyxml2::XMLDocument* doc)
-    {
-      std::vector<char**> buffer;
-      
-      const char * name_chars = TwGetBarName(bar->bar);
-      std::string name = std::string(name_chars) + "_AntTweakBar";
-      ::igl::XMLSerializer* s = new ::igl::XMLSerializer(name);
-      
-      const std::vector< ::igl::ReTwRWItem>& rw_items = bar->get_rw_items();
-      for(std::vector< ::igl::ReTwRWItem>::const_iterator it = rw_items.begin(); it != rw_items.end(); it++)
-      {
-        std::string val = bar->get_value_as_string(it->var,it->type);
-        char** cval = new char*; // create char* on heap
-        *cval = new char[val.size()+1];
-        buffer.push_back(cval);
-        strcpy(*cval,val.c_str());
-        s->Add(*cval,it->name);
-      }
-      
-      char var[REANTTWEAKBAR_MAX_CB_VAR_SIZE];
-      // Print all CB variables
-      const std::vector< ::igl::ReTwCBItem>& cb_items = bar->get_cb_items();
-      for(std::vector< ::igl::ReTwCBItem>::const_iterator it = cb_items.begin(); it != cb_items.end(); it++)
-      {
-        TwType type = it->type;
-        //TwSetVarCallback setCallback = it->setCallback;
-        TwGetVarCallback getCallback = it->getCallback;
-        void * clientData = it->clientData;
-        // I'm not sure how to do what I want to do. getCallback needs to be sure
-        // that it can write to var. So var needs to point to a valid and big
-        // enough chunk of memory
-        getCallback(var,clientData);
-        
-        std::string val = bar->get_value_as_string(var,type);
-        char** cval = new char*; // create char* on heap
-        *cval = new char[val.size()+1];
-        buffer.push_back(cval);
-        strcpy(*cval,val.c_str());
-        s->Add(*cval,it->name);
-      }
-      
-      s->SaveToXMLDoc(name,doc);
-      
-      // delete pointer buffers
-      for(unsigned int i=0;i<buffer.size();i++)
-      {
-        delete[] *buffer[i];
-        delete buffer[i];
-      }
-      
-      delete s;
-      
-      return true;
-    }
-    
-    IGL_INLINE bool load_ReAntTweakBar(::igl::ReTwBar* bar, const char *file_name)
-    {
-      char type_str[REANTTWEAKBAR_MAX_WORD];
-      char value_str[REANTTWEAKBAR_MAX_WORD];
-      TwType type;
-      
-      const char * name_chars = TwGetBarName(bar->bar);
-      std::string name = std::string(name_chars) + "_AntTweakBar";
-      
-      const std::vector< ::igl::ReTwRWItem>& rw_items = bar->get_rw_items();
-      for(std::vector< ::igl::ReTwRWItem>::const_iterator it = rw_items.begin(); it != rw_items.end(); it++)
-      {
-        char* val;
-        ::igl::XMLSerializer::LoadObject(val,it->name,name,file_name);
-        sscanf(val,"%s %[^\n]",type_str,value_str);
-        
-        if(!bar->type_from_string(type_str,type))
-        {
-          printf("ERROR: %s type not found... Skipping...\n",type_str);
-          continue;
-        }
-        
-        bar->set_value_from_string(it->name.c_str(),type,value_str);
-        delete[] val;
-      }
-      
-      const std::vector< ::igl::ReTwCBItem>& cb_items = bar->get_cb_items();
-      for(std::vector< ::igl::ReTwCBItem>::const_iterator it = cb_items.begin(); it != cb_items.end(); it++)
-      {
-        char* val;
-        ::igl::XMLSerializer::LoadObject(val,it->name,name,file_name);
-        sscanf(val,"%s %[^\n]",type_str,value_str);
-        
-        if(!bar->type_from_string(type_str,type))
-        {
-          printf("ERROR: %s type not found... Skipping...\n",type_str);
-          continue;
-        }
-        
-        bar->set_value_from_string(it->name.c_str(),type,value_str);
-        delete[] val;
-      }
-      
-      return true;
-    }
-    
-    IGL_INLINE bool load_ReAntTweakBar(::igl::ReTwBar* bar, tinyxml2::XMLDocument* doc)
-    {
-      std::map<std::string,char*> variables;
-      std::map<std::string,char*> cbVariables;
-      
-      const char * name_chars = TwGetBarName(bar->bar);
-      std::string name = std::string(name_chars) + "_AntTweakBar";
-      ::igl::XMLSerializer* s = new ::igl::XMLSerializer(name);
-      
-      std::map<std::string,char*>::iterator iter;
-      const std::vector< ::igl::ReTwRWItem>& rw_items = bar->get_rw_items();
-      for(std::vector< ::igl::ReTwRWItem>::const_iterator it = rw_items.begin(); it != rw_items.end(); it++)
-      {
-        variables[it->name] = NULL;
-        iter = variables.find(it->name);
-        s->Add(iter->second,iter->first);
-      }
-      
-      // Add all CB variables
-      const std::vector< ::igl::ReTwCBItem>& cb_items = bar->get_cb_items();
-      for(std::vector< ::igl::ReTwCBItem>::const_iterator it = cb_items.begin(); it != cb_items.end(); it++)
-      {
-        cbVariables[it->name] = NULL;
-        iter = cbVariables.find(it->name);
-        s->Add(iter->second,iter->first);
-      }
-      
-      s->LoadFromXMLDoc(doc);
-      
-      // Set loaded values
-      char type_str[REANTTWEAKBAR_MAX_WORD];
-      char value_str[REANTTWEAKBAR_MAX_WORD];
-      TwType type;
-      
-      for(iter = variables.begin(); iter != variables.end(); iter++)
-      {
-        if(iter->second == NULL)
-        {
-          printf("ERROR: '%s' entry not found... Skipping...\n",iter->first.c_str());
-          continue;
-        }
-        
-        sscanf(iter->second,"%s %[^\n]",type_str,value_str);
-        
-        if(!bar->type_from_string(type_str,type))
-        {
-          printf("ERROR: Type '%s' of '%s' not found... Skipping...\n",type_str,iter->first.c_str());
-          continue;
-        }
-        
-        bar->set_value_from_string(iter->first.c_str(),type,value_str);
-      }
-      
-      for(iter = cbVariables.begin(); iter != cbVariables.end(); iter++)
-      {
-        if(iter->second == NULL)
-        {
-          printf("ERROR: '%s' entry not found... Skipping...\n",iter->first.c_str());
-          continue;
-        }
-
-        sscanf(iter->second,"%s %[^\n]",type_str,value_str);
-        
-        if(!bar->type_from_string(type_str,type))
-        {
-          printf("ERROR: Type '%s' of '%s' not found... Skipping...\n",type_str,iter->first.c_str());
-          continue;
-        }
-        
-        bar->set_value_from_string(iter->first.c_str(),type,value_str);
-      }
-      
-      // delete buffers
-      for(iter = variables.begin(); iter != variables.end(); iter++)
-        delete[] iter->second;
-      
-      for(iter = cbVariables.begin(); iter != cbVariables.end(); iter++)
-        delete[] iter->second;
-      
-      delete s;
-      
-      return true;
-    }
-    
-//  }
-}
-
-#endif

+ 0 - 49
include/igl/xml/old_version/XMLSerializable.h

@@ -1,49 +0,0 @@
-// 
-// Copyright (C) 2014 Christian Schüller <schuellchr@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-/* ------------------------------------------------------------------------------
- Inherit from this abstract class to have full control over the serialization
- of your user defined class.
- ----------------------------------------------------------------------------*/
-#ifndef IGL_XML_SERIALIZABLE_H
-#define IGL_XML_SERIALIZABLE_H
-
-#include <iostream>
-#include <tinyxml2.h>
-
-namespace igl
-{
-  namespace
-  {
-    class XMLSerializable
-    {
-    public:
-      /**
-      * Default name of serializable object
-      */
-      std::string Name;
-
-      /**
-        * This function gets called if the objects were not found during deserialization.
-        * Initialize your objects as you like.
-        */
-      virtual void Init() = 0;
-      /**
-        * Serialize your stuff within this function.
-        * doc is the current serialization xml file. You can use SaveToXMLDoc to add your objects.
-        */
-      virtual bool Serialize(tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element) = 0;
-
-      /**
-        * Deserialize your stuff within this function.
-        * doc is the current serialization xml file. You can use LoadFromXMLDoc to read out your objects.
-        */
-      virtual bool Deserialize(tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element) = 0;
-    };
-  }
-}
-
-#endif

+ 0 - 178
include/igl/xml/old_version/XMLSerialization.h

@@ -1,178 +0,0 @@
-// 
-// Copyright (C) 2014 Christian Schüller <schuellchr@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-// ------------------------------------------------------------------------------
-// Inherit from this class to have the easiest way to serialize your user defined class.
-// 
-// 1) Pass the default name of your class to the base constructor.
-// 2) Override InitSerialization() and add your variables to serialize like:
-// xmlSerializer->Add(var1,"name1");
-// xmlSerializer->Add(var2,"name2");
-//
-// Workaround for Visual Studio run time debugger inspection problem:
-// Copy and implement all the functions, splitting them into a source and header file.
-// Restrictions on Native C++ Expressions (Anonymous Namespaces):
-// http://msdn.microsoft.com/en-us/library/0888kc6a%28VS.80%29.aspx
-// ----------------------------------------------------------------------------*/
-#ifndef IGL_XML_SERIALIZATION_H
-#define IGL_XML_SERIALIZATION_H
-
-#include <igl/xml/old_version/XMLSerializer.h>
-
-namespace igl
-{
-  namespace
-  {
-    class XMLSerializer;
-
-    class XMLSerialization : public igl::XMLSerializable
-    {
-    public:
-      XMLSerializer* xmlSerializer;
-
-      /**
-       * Default implementation of XMLSerializable interface
-       */
-      virtual void Init();
-      virtual bool Serialize(tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element);
-      virtual bool Deserialize(tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element);
-
-      /**
-      * Default constructor, destructor, assignment and copy constructor
-      */
-      XMLSerialization(const std::string& name);
-      ~XMLSerialization();
-      XMLSerialization(const XMLSerialization& obj);
-      XMLSerialization& operator=(const XMLSerialization& obj);
-
-      /**
-      * Function which must be overridden in the subclass if you don't use
-      * heap allocations (new) to create new instances.
-      * It will get called if the assignment operator or copy constructor
-      * is involved to update the references to the new copied data structures
-      *
-      * Add in this function all the variables you want to serialize like:
-      * xmlSerializer->Add(var1);
-      * xmlSerializer->Add(var2);
-      * ...
-      */
-      virtual void InitSerialization();
-
-      /**
-       * Following functions can be overwritten to handle the specific events.
-       * Return false to prevent serialization of object.
-       */
-      virtual bool BeforeSerialization();
-      virtual void AfterSerialization();
-      virtual bool BeforeDeserialization();
-      virtual void AfterDeserialization();
-
-    private:
-      void initXMLSerializer();
-    };
-
-    // Implementation
-
-    void XMLSerialization::Init()
-    {
-    }
-
-    bool XMLSerialization::Serialize(tinyxml2::XMLDocument* doc,tinyxml2::XMLElement* element)
-    {
-      bool serialized = false;
-
-      if(this->BeforeSerialization())
-      {
-        if(xmlSerializer==NULL)
-        {
-          xmlSerializer = new XMLSerializer(Name);
-          this->InitSerialization();
-        }
-        serialized = xmlSerializer->SaveGroupToXMLElement(doc,element,Name);
-        this->AfterSerialization();
-      }
-
-      return serialized;
-    }
-
-    bool XMLSerialization::Deserialize(tinyxml2::XMLDocument* doc,const tinyxml2::XMLElement* element)
-    {
-      bool serialized = false;
-
-      if(this->BeforeDeserialization())
-      {
-        if(xmlSerializer==NULL)
-        {
-          xmlSerializer = new XMLSerializer(Name);
-          this->InitSerialization();
-        }
-        serialized = xmlSerializer->LoadGroupFromXMLElement(Name,doc,element);
-        this->AfterDeserialization();
-      }
-
-      return serialized;
-    }
-
-    void XMLSerialization::InitSerialization()
-    {
-      std::cout<<"You have to override InitSerialization()"<<"\n";
-      //assert(false);
-    }
-
-    XMLSerialization::XMLSerialization(const std::string& name)
-    {
-      Name = name;
-      xmlSerializer = NULL;
-    }
-
-    XMLSerialization::~XMLSerialization()
-    {
-      if(xmlSerializer!=NULL)
-        delete xmlSerializer;
-      xmlSerializer = NULL;
-    }
-
-    XMLSerialization::XMLSerialization(const XMLSerialization& obj)
-    {
-      Name = obj.Name;
-      xmlSerializer = NULL;
-    }
-
-    XMLSerialization& XMLSerialization::operator=(const XMLSerialization& obj)
-    {
-      if(this!=&obj)
-      {
-        Name = obj.Name;
-        if(xmlSerializer!=NULL)
-        {
-          delete xmlSerializer;
-          xmlSerializer = NULL;
-        }
-      }
-      return *this;
-    }
-
-    bool XMLSerialization::BeforeSerialization()
-    {
-      return true;
-    }
-
-    void XMLSerialization::AfterSerialization()
-    {
-    }
-
-    bool XMLSerialization::BeforeDeserialization()
-    {
-      return true;
-    }
-
-    void XMLSerialization::AfterDeserialization()
-    {
-    }
-  }
-}
-
-#endif

+ 0 - 49
include/igl/xml/old_version/XMLSerializationTest.h

@@ -1,49 +0,0 @@
-// 
-// Copyright (C) 2014 Christian Schüller <schuellchr@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-------------------------------------------------------------------------------
- Used to demonstrates howto use the XMLSerialization class.
-----------------------------------------------------------------------------*/
-#ifndef IGL_XML_SERIALIZATION_TEST_H
-#define IGL_XML_SERIALIZATION_TEST_H
-
-#include <igl/xml/XMLSerialization.h>
-
-namespace igl
-{
-
-  class XMLSerializationTest : public ::igl::XMLSerialization
-  {
-  public:
-      
-    int testInt;
-    std::vector<float> testVector;
-      
-    XMLSerializationTest();
-    void InitSerialization();
-      
-    bool Test();
-  };
-
-  XMLSerializerTest::XMLSerializerTest()
-    : XMLSerialization("testObject")
-  {
-  }
-
-  void XMLSerializerTest::InitSerialization()
-  {
-    xmlSerializer->Add(testInt,"testInt");
-    xmlSerializer->Add(testVector,"testVector");
-      
-    testInt = 10;
-      
-    testVector.push_back(1.0001f);
-    testVector.push_back(2.0001f);
-    testVector.push_back(3.0001f);
-  }
-}
-
-#endif

+ 0 - 1
include/igl/xml/old_version/XMLSerializer.h.REMOVED.git-id

@@ -1 +0,0 @@
-172f806cdef073e1613fe0def62c0521976222bd