浏览代码

Update usage of TinyXML to use TinyXML2

Lukas Aldershaab 4 年之前
父节点
当前提交
9a795e89f3

+ 6 - 5
Engine/lib/collada/include/dae/daeTinyXMLPlugin.h

@@ -20,8 +20,9 @@
 #include <dae/daeURI.h>
 #include <dae/daeIOPluginCommon.h>
 
-class TiXmlDocument;
-class TiXmlElement;
+#ifndef TINYXML2_INCLUDED
+#include <tinyxml2.h>
+#endif
 
 class daeTinyXMLPlugin : public daeIOPluginCommon
 {
@@ -60,12 +61,12 @@ public:
 	virtual DLLSPEC daeString getOption( daeString option );
 	
 private:
-	TiXmlDocument*  m_doc;
-	std::list<TiXmlElement*>  m_elements;
+   tinyxml2::XMLDocument*  m_doc;
+	std::list<tinyxml2::XMLElement*>  m_elements;
 
 	virtual daeElementRef readFromFile(const daeURI& uri);
 	virtual daeElementRef readFromMemory(daeString buffer, const daeURI& baseUri);
-	daeElementRef readElement(TiXmlElement* tinyXmlElement, daeElement* parentElement);
+	daeElementRef readElement(tinyxml2::XMLElement* tinyXmlElement, daeElement* parentElement);
 
 	void writeElement( daeElement* element ); 
 	void writeAttribute( daeMetaAttribute* attr, daeElement* element );

+ 13 - 15
Engine/lib/collada/src/dae/daeTinyXMLPlugin.cpp

@@ -24,7 +24,7 @@
 #endif
 
 #include <string>
-#include <tinyxml.h>
+#include <tinyxml2.h>
 #include <dae.h>
 #include <dom.h>
 #include <dae/daeMetaElement.h>
@@ -36,7 +36,7 @@
 using namespace std;
 
 namespace {
-	daeInt getCurrentLineNumber(TiXmlElement* element) {
+	daeInt getCurrentLineNumber(tinyxml2::XMLElement* element) {
 		return -1;
 	}
 }
@@ -65,7 +65,7 @@ daeElementRef daeTinyXMLPlugin::readFromFile(const daeURI& uri) {
 	string file = cdom::uriToNativePath(uri.str());
 	if (file.empty())
 		return NULL;
-	TiXmlDocument doc;
+	tinyxml2::XMLDocument doc;
 	doc.LoadFile(file.c_str());
 	if (!doc.RootElement()) {
 		daeErrorHandler::get()->handleError((std::string("Failed to open ") + uri.str() +
@@ -76,7 +76,7 @@ daeElementRef daeTinyXMLPlugin::readFromFile(const daeURI& uri) {
 }
 
 daeElementRef daeTinyXMLPlugin::readFromMemory(daeString buffer, const daeURI& baseUri) {
-	TiXmlDocument doc;
+   tinyxml2::XMLDocument doc;
 	doc.Parse(buffer);
 	if (!doc.RootElement()) {
 		daeErrorHandler::get()->handleError("Failed to open XML document from memory buffer in "
@@ -86,9 +86,9 @@ daeElementRef daeTinyXMLPlugin::readFromMemory(daeString buffer, const daeURI& b
 	return readElement(doc.RootElement(), NULL);
 }
 
-daeElementRef daeTinyXMLPlugin::readElement(TiXmlElement* tinyXmlElement, daeElement* parentElement) {
+daeElementRef daeTinyXMLPlugin::readElement(tinyxml2::XMLElement* tinyXmlElement, daeElement* parentElement) {
 	std::vector<attrPair> attributes;
-	for (TiXmlAttribute* attrib = tinyXmlElement->FirstAttribute(); attrib != NULL; attrib = attrib->Next())
+	for (const tinyxml2::XMLAttribute* attrib = tinyXmlElement->FirstAttribute(); attrib != NULL; attrib = attrib->Next())
 		attributes.push_back(attrPair(attrib->Name(), attrib->Value()));
 		
 	daeElementRef element = beginReadElement(parentElement, tinyXmlElement->Value(),
@@ -102,7 +102,7 @@ daeElementRef daeTinyXMLPlugin::readElement(TiXmlElement* tinyXmlElement, daeEle
 		readElementText(element, tinyXmlElement->GetText(), getCurrentLineNumber(tinyXmlElement));
   
   // Recurse children
-  for (TiXmlElement* child = tinyXmlElement->FirstChildElement(); child != NULL; child = child->NextSiblingElement())
+  for (tinyxml2::XMLElement* child = tinyXmlElement->FirstChildElement(); child != NULL; child = child->NextSiblingElement())
     element->placeElement(readElement(child, element));
 
 	return element;
@@ -136,13 +136,11 @@ daeInt daeTinyXMLPlugin::write(const daeURI& name, daeDocument *document, daeBoo
 		fclose(tempfd);
 	}
 	
-  m_doc = new TiXmlDocument(name.getURI());
+  m_doc = new tinyxml2::XMLDocument();
   if (m_doc)
   {
-    m_doc->SetTabSize(4);
-
-   	TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" );  
-	  m_doc->LinkEndChild( decl ); 
+    tinyxml2::XMLDeclaration* decl = m_doc->NewDeclaration("xml version=\"1.0\"");
+	 m_doc->LinkEndChild( decl ); 
 
     writeElement(document->getDomRoot());
 
@@ -158,12 +156,12 @@ void daeTinyXMLPlugin::writeElement( daeElement* element )
 	daeMetaElement* _meta = element->getMeta();
   if (!_meta->getIsTransparent() ) 
   {
-		TiXmlElement* tiElm = new TiXmlElement( element->getElementName() );  
+		tinyxml2::XMLElement* tiElm = m_doc->NewElement( element->getElementName() );  
         
 		if (m_elements.empty() == true) {
 				m_doc->LinkEndChild(tiElm);
 			} else {
-			TiXmlElement* first = m_elements.front();
+			tinyxml2::XMLElement* first = m_elements.front();
 			first->LinkEndChild(tiElm);
 		}
 		m_elements.push_front(tiElm);
@@ -200,7 +198,7 @@ void daeTinyXMLPlugin::writeValue( daeElement* element )
 		attr->memoryToString(element, buffer);
 		std::string s = buffer.str();
 		if (!s.empty())
-			m_elements.front()->LinkEndChild( new TiXmlText(buffer.str().c_str()) );
+			m_elements.front()->LinkEndChild( m_doc->NewText(buffer.str().c_str()) );
 	}
 }
 

+ 6 - 6
Engine/source/Verve/Core/Persistence/VPersistence.cpp

@@ -34,7 +34,7 @@ namespace VPersistence
     //-----------------------------------------------------------------------------
 
     template <>
-    bool write( TiXmlElement *pElement, VController *pObject )
+    bool write( tinyxml2::XMLElement *pElement, VController *pObject )
     {
         // Write Properties.
         if ( !writeProperties( pElement, pObject ) )
@@ -53,7 +53,7 @@ namespace VPersistence
     }
 
     template <>
-    bool read( TiXmlElement *pElement, VController *pObject )
+    bool read( tinyxml2::XMLElement *pElement, VController *pObject )
     {
         // Read Properties.
         if ( !readProperties( pElement, pObject ) )
@@ -87,10 +87,10 @@ namespace VPersistence
     //-----------------------------------------------------------------------------
 
     template <>
-    bool write( TiXmlElement *pElement, VObject *pObject )
+    bool write( tinyxml2::XMLElement *pElement, VObject *pObject )
     {
         // Create Element.
-        TiXmlElement *objectElement = new TiXmlElement( "VObject" );
+        tinyxml2::XMLElement *objectElement = pElement->GetDocument()->NewElement( "VObject" );
         pElement->LinkEndChild( objectElement );
 
         // Attributes.
@@ -107,7 +107,7 @@ namespace VPersistence
     }
 
     template <>
-    bool read( TiXmlElement *pElement, VObject *pObject )
+    bool read( tinyxml2::XMLElement *pElement, VObject *pObject )
     {
         // Read Properties.
         if ( !readProperties( pElement, pObject ) )
@@ -134,4 +134,4 @@ namespace VPersistence
         // Valid Read.
         return true;
     }
-}
+}

+ 19 - 18
Engine/source/Verve/Core/Persistence/VPersistence.h

@@ -24,7 +24,7 @@
 #define _VT_VPERSISTENCE_H_
 
 #ifndef TINYXML_INCLUDED
-#include "tinyxml/tinyxml.h"
+#include "tinyxml/tinyxml2.h"
 #endif
 
 #ifndef _SIMOBJECT_H_
@@ -34,6 +34,7 @@
 #ifndef _VT_VOBJECT_H_
 #include "Verve/Core/VObject.h"
 #endif
+#include "persistence/taml/fsTinyXml.h"
 
 //-----------------------------------------------------------------------------
 
@@ -48,17 +49,17 @@ namespace VPersistence
 
     //-------------------------------------------------------------------------
 
-    template <class T> bool write( TiXmlElement *pElement, T *pObject );
+    template <class T> bool write( tinyxml2::XMLElement *pElement, T *pObject );
     
     template <class T> bool writeFile( const char* pFileName, T *pObject )
     {
         // Create Doc.
-        TiXmlDocument xmlDocument;
-        TiXmlDeclaration *xmlDeclaration = new TiXmlDeclaration( "1.0", "", "" );
+        VfsXMLDocument xmlDocument;
+        tinyxml2::XMLDeclaration *xmlDeclaration = xmlDocument.NewDeclaration();
         xmlDocument.LinkEndChild( xmlDeclaration );
 
         // Create Root.
-        TiXmlElement *xmlRoot = new TiXmlElement( "VerveControllerSequence" );
+        tinyxml2::XMLElement *xmlRoot = xmlDocument.NewElement( "VerveControllerSequence" );
         xmlDocument.LinkEndChild( xmlRoot );
 
         // Write Version.
@@ -76,13 +77,13 @@ namespace VPersistence
     };
 
     
-    template <class T> bool writeProperties( TiXmlElement *pElement, T *pObject )
+    template <class T> bool writeProperties( tinyxml2::XMLElement *pElement, T *pObject )
     {
         const AbstractClassRep::FieldList &fieldList = pObject->getFieldList();
         const AbstractClassRep::Field     *field     = NULL;
 
         // Create Property Root.
-        TiXmlElement *propertyRoot = new TiXmlElement( "Properties" );
+        tinyxml2::XMLElement *propertyRoot = pElement->GetDocument()->NewElement( "Properties" );
         pElement->LinkEndChild( propertyRoot );
 
         const S32 fieldCount = fieldList.size();
@@ -111,10 +112,10 @@ namespace VPersistence
             if ( fieldValue )
             {
                 // Create Element.
-                TiXmlElement *propertyElement = new TiXmlElement( fieldName );  
+                tinyxml2::XMLElement *propertyElement = pElement->GetDocument()->NewElement( fieldName );  
 
                 // Apply Value.
-                propertyElement->InsertEndChild( TiXmlText( fieldValue ) );
+                propertyElement->InsertNewText( fieldValue );
 
                 // Add.
                 propertyRoot->LinkEndChild( propertyElement );
@@ -125,7 +126,7 @@ namespace VPersistence
         return true;
     };
 
-    template <class T> bool writeObjects( TiXmlElement *pElement, T *pObject )
+    template <class T> bool writeObjects( tinyxml2::XMLElement *pElement, T *pObject )
     {
         for ( ITreeNode *node = pObject->mChildNode; node != NULL; node = node->mSiblingNextNode )
         {
@@ -143,18 +144,18 @@ namespace VPersistence
 
     //-------------------------------------------------------------------------
     
-    template <class T> bool read( TiXmlElement *pElement, T *pObject );
+    template <class T> bool read( tinyxml2::XMLElement *pElement, T *pObject );
     
     template <class T> bool readFile( const char* pFileName, T *pObject )
     {
-        TiXmlDocument xmlDocument;
+        VfsXMLDocument xmlDocument;
         if ( !xmlDocument.LoadFile( pFileName ) )
         {
             Con::errorf( "VPersistence::readFile() - Unable to load file '%s'.", pFileName );
             return false;
         }
 
-        TiXmlElement *rootElement = xmlDocument.RootElement();
+        tinyxml2::XMLElement *rootElement = xmlDocument.RootElement();
         if ( !rootElement )
         {
             Con::errorf( "VPersistence::readFile() - Invalid Document '%s'.", pFileName );
@@ -179,12 +180,12 @@ namespace VPersistence
         return true;
     };
 
-    template <class T> bool readProperties( TiXmlElement *pElement, T *pObject )
+    template <class T> bool readProperties( tinyxml2::XMLElement *pElement, T *pObject )
     {
-        TiXmlElement *propertyRoot = pElement->FirstChildElement( "Properties" );
+        tinyxml2::XMLElement *propertyRoot = pElement->FirstChildElement( "Properties" );
         if ( propertyRoot )
         {
-            for ( TiXmlElement *child = propertyRoot->FirstChildElement(); child != NULL; child = child->NextSiblingElement() )
+            for ( tinyxml2::XMLElement *child = propertyRoot->FirstChildElement(); child != NULL; child = child->NextSiblingElement() )
             {
                 // Get Field Data.
                 const char *fieldName  = child->Value();
@@ -211,9 +212,9 @@ namespace VPersistence
         return true;
     };
 
-    template <class T> bool readObjects( TiXmlElement *pElement, T *pObject )
+    template <class T> bool readObjects( tinyxml2::XMLElement *pElement, T *pObject )
     {
-        for ( TiXmlElement *child = pElement->FirstChildElement( "VObject" ); child != NULL; child = child->NextSiblingElement( "VObject" ) )
+        for ( tinyxml2::XMLElement *child = pElement->FirstChildElement( "VObject" ); child != NULL; child = child->NextSiblingElement( "VObject" ) )
         {
             // Get Object Type.
             const char *type = child->Attribute( "Type" );

+ 7 - 7
Engine/source/Verve/Core/VController.cpp

@@ -606,10 +606,10 @@ void VController::sort( void )
 // Write the DataTable out to a TinyXML document.
 // 
 //-----------------------------------------------------------------------------
-bool VController::writeDataTable( TiXmlElement *pElement )
+bool VController::writeDataTable( tinyxml2::XMLElement *pElement )
 {
     // Create Data Table Root.
-    TiXmlElement *dataTableRoot = new TiXmlElement( "DataTable" );
+    tinyxml2::XMLElement *dataTableRoot = pElement->GetDocument()->NewElement( "DataTable" );
     pElement->LinkEndChild( dataTableRoot );
 
     for ( VDataTable::VDataMap::Iterator itr = mDataTable.mDataMap.begin(); itr != mDataTable.mDataMap.end(); ++itr )
@@ -618,11 +618,11 @@ bool VController::writeDataTable( TiXmlElement *pElement )
         VDataTable::sDataItem *data = &itr->value;
 
         // Create Element.
-        TiXmlElement *dataElement = new TiXmlElement( "DataItem" );  
+        tinyxml2::XMLElement* dataElement = pElement->GetDocument()->NewElement( "DataItem" );
 
         // Apply Attributes.
         dataElement->SetAttribute( "Type",  VDataTable::getDataTypeDescription( data->Type ) );
-        dataElement->SetAttribute( "Name",  data->FieldName );
+        dataElement->SetAttribute( "Name",  data->FieldName.c_str() );
         dataElement->SetAttribute( "Value", getDataField( StringTable->insert( data->FieldName.c_str() ), NULL ) );
 
         // Add.
@@ -645,12 +645,12 @@ bool VController::writeDataTable( TiXmlElement *pElement )
 // Read the DataTable from a TinyXML document.
 // 
 //-----------------------------------------------------------------------------
-bool VController::readDataTable( TiXmlElement *pElement )
+bool VController::readDataTable( tinyxml2::XMLElement *pElement )
 {
-    TiXmlElement *dataTableRoot = pElement->FirstChildElement( "DataTable" );
+    tinyxml2::XMLElement *dataTableRoot = pElement->FirstChildElement( "DataTable" );
     if ( dataTableRoot )
     {
-        for ( TiXmlElement *child = dataTableRoot->FirstChildElement(); child != NULL; child = child->NextSiblingElement() )
+        for ( tinyxml2::XMLElement *child = dataTableRoot->FirstChildElement(); child != NULL; child = child->NextSiblingElement() )
         {
             // Get Field Data.
             const char *fieldType  = child->Attribute( "Type" );

+ 3 - 3
Engine/source/Verve/Core/VController.h

@@ -198,11 +198,11 @@ public:
 
     // Saving.
 
-    bool            writeDataTable( TiXmlElement *pElement );
+    bool            writeDataTable( tinyxml2::XMLElement *pElement );
 
     // Reading.
 
-    bool            readDataTable( TiXmlElement *pElement );
+    bool            readDataTable( tinyxml2::XMLElement *pElement );
 
     // Console Declaration.
 
@@ -243,4 +243,4 @@ protected:
 
 //-----------------------------------------------------------------------------
 
-#endif // _VT_VCONTROLLER_H_
+#endif // _VT_VCONTROLLER_H_

+ 1 - 5
Engine/source/Verve/Core/VObject.h

@@ -45,10 +45,6 @@
 #include "Verve/Core/VTreeNode.h"
 #endif
 
-#ifndef TINYXML_INCLUDED
-#include "tinyxml/tinyxml.h"
-#endif
-
 //-----------------------------------------------------------------------------
 class VController;
 //-----------------------------------------------------------------------------
@@ -123,4 +119,4 @@ public:
 
 //-----------------------------------------------------------------------------
 
-#endif // _VT_VOBJECT_H_
+#endif // _VT_VOBJECT_H_

+ 85 - 70
Engine/source/console/SimXMLDocument.cpp

@@ -20,7 +20,7 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#include "tinyxml/tinyxml.h"
+#include "tinyxml/tinyxml2.h"
 
 //-----------------------------------------------------------------------------
 // Console implementation of STL map.
@@ -176,7 +176,7 @@ bool SimXMLDocument::onAdd()
 
    if(!m_qDocument)
    {
-      m_qDocument = new fsTiXmlDocument();
+      m_qDocument = new VfsXMLDocument();
    }
    return true;
 }
@@ -253,7 +253,7 @@ bool SimXMLDocument::saveFile(const char* rFileName)
 // -----------------------------------------------------------------------------
 bool SimXMLDocument::saveToString(String& str)
 {
-   TiXmlPrinter printer;
+   tinyxml2::XMLPrinter printer;
    bool ret = m_qDocument->Accept( &printer );
    if (ret)
       str = printer.CStr();
@@ -313,7 +313,7 @@ const char* SimXMLDocument::getErrorDesc(void) const
    {
       return StringTable->insert("No document");
    }
-   return m_qDocument->ErrorDesc();
+   return m_qDocument->ErrorStr();
 }
 
 DefineEngineMethod( SimXMLDocument, getErrorDesc, const char*, (),,
@@ -346,16 +346,16 @@ bool SimXMLDocument::pushFirstChildElement(const char* rName)
    m_CurrentAttribute = 0;
 
    // Push the first element found under the current element of the given name
-   fsTiXmlElement* pElement;
+   tinyxml2::XMLElement* pElement;
    if(!m_paNode.empty())
    {
       const S32 iLastElement = m_paNode.size() - 1;
-      fsTiXmlElement* pNode = m_paNode[iLastElement];
+      tinyxml2::XMLNode* pNode = m_paNode[iLastElement];
       if(!pNode)
       {
          return false;
       }
-      pElement = (fsTiXmlElement*) pNode->FirstChildElement(rName);
+      pElement = pNode->FirstChildElement(rName);
    }
    else
    {
@@ -363,7 +363,7 @@ bool SimXMLDocument::pushFirstChildElement(const char* rName)
       {
          return false;
       }
-      pElement = (fsTiXmlElement*)m_qDocument->FirstChildElement(rName);
+      pElement = m_qDocument->FirstChildElement(rName);
    }
 
    if(!pElement)
@@ -410,22 +410,22 @@ bool SimXMLDocument::pushChildElement(S32 index)
    m_CurrentAttribute = 0;
 
    // Push the first element found under the current element of the given name
-   fsTiXmlElement* pElement;
+   tinyxml2::XMLElement* pElement;
    if(!m_paNode.empty())
    {
       const S32 iLastElement = m_paNode.size() - 1;
-      fsTiXmlElement* pNode = m_paNode[iLastElement];
+      tinyxml2::XMLNode* pNode = m_paNode[iLastElement];
       if(!pNode)
       {
          return false;
       }
-      pElement = (fsTiXmlElement*) pNode->FirstChildElement();
+      pElement = pNode->FirstChildElement();
       for( S32 i = 0; i < index; i++ )
       {
          if( !pElement )
             return false;
 
-         pElement = (fsTiXmlElement*)pElement->NextSiblingElement();
+         pElement = pElement->NextSiblingElement();
       }
    }
    else
@@ -434,13 +434,13 @@ bool SimXMLDocument::pushChildElement(S32 index)
       {
          return false;
       }
-      pElement = (fsTiXmlElement*)m_qDocument->FirstChildElement();
+      pElement = m_qDocument->FirstChildElement();
       for( S32 i = 0; i < index; i++ )
       {
          if( !pElement )
             return false;
 
-         pElement = (fsTiXmlElement*)pElement->NextSiblingElement();
+         pElement = pElement->NextSiblingElement();
       }
    }
 
@@ -474,13 +474,13 @@ bool SimXMLDocument::nextSiblingElement(const char* rName)
       return false;
    }
    const S32 iLastElement = m_paNode.size() - 1;
-   fsTiXmlElement*& pElement = m_paNode[iLastElement];
+   tinyxml2::XMLNode*& pElement = m_paNode[iLastElement];
    if(!pElement)
    {
       return false;
    }
 
-   pElement = (fsTiXmlElement*)pElement->NextSiblingElement(rName);
+   pElement = pElement->NextSiblingElement(rName);
    if(!pElement)
    {
       return false;
@@ -508,7 +508,7 @@ const char* SimXMLDocument::elementValue()
       return StringTable->EmptyString();
    }
    const S32 iLastElement = m_paNode.size() - 1;
-   fsTiXmlElement* pNode = m_paNode[iLastElement];
+   tinyxml2::XMLNode* pNode = m_paNode[iLastElement];
    if(!pNode)
    {
       return StringTable->EmptyString();
@@ -549,7 +549,7 @@ const char* SimXMLDocument::attribute(const char* rAttribute)
       return StringTable->EmptyString();
    }
    const S32 iLastElement = m_paNode.size() - 1;
-   fsTiXmlElement* pNode = m_paNode[iLastElement];
+   tinyxml2::XMLElement* pNode = m_paNode[iLastElement]->ToElement();
    if(!pNode)
    {
       return StringTable->EmptyString();
@@ -600,7 +600,7 @@ bool SimXMLDocument::attributeExists(const char* rAttribute)
       return false;
    }
    const S32 iLastElement = m_paNode.size() - 1;
-   fsTiXmlElement* pNode = m_paNode[iLastElement];
+   tinyxml2::XMLElement* pNode = m_paNode[iLastElement]->ToElement();
    if(!pNode)
    {
       return false;
@@ -633,14 +633,14 @@ const char* SimXMLDocument::firstAttribute()
       return StringTable->EmptyString();
    }
    const S32 iLastElement = m_paNode.size() - 1;
-   fsTiXmlElement* pNode = m_paNode[iLastElement];
+   tinyxml2::XMLElement* pNode = m_paNode[iLastElement]->ToElement();
    if(!pNode)
    {
       return StringTable->EmptyString();
    }
 
    // Gets its first attribute, if any
-   m_CurrentAttribute = (fsTiXmlAttribute*)pNode->FirstAttribute();
+   m_CurrentAttribute = pNode->FirstAttribute();
    if(!m_CurrentAttribute)
    {
       return StringTable->EmptyString();
@@ -670,14 +670,18 @@ const char* SimXMLDocument::lastAttribute()
       return StringTable->EmptyString();
    }
    const S32 iLastElement = m_paNode.size() - 1;
-   fsTiXmlElement* pNode = m_paNode[iLastElement];
+   tinyxml2::XMLElement* pNode = m_paNode[iLastElement]->ToElement();
    if(!pNode)
    {
       return StringTable->EmptyString();
    }
 
    // Gets its last attribute, if any
-   m_CurrentAttribute = (fsTiXmlAttribute*)pNode->LastAttribute();
+   m_CurrentAttribute = pNode->FirstAttribute();
+   while (m_CurrentAttribute->Next() != NULL)
+   {
+      m_CurrentAttribute = m_CurrentAttribute->Next();
+   }
    if(!m_CurrentAttribute)
    {
       return StringTable->EmptyString();
@@ -708,7 +712,7 @@ const char* SimXMLDocument::nextAttribute()
    }
 
    // Gets its next attribute, if any
-   m_CurrentAttribute = (fsTiXmlAttribute*)m_CurrentAttribute->Next();
+   m_CurrentAttribute = m_CurrentAttribute->Next();
    if(!m_CurrentAttribute)
    {
       return StringTable->EmptyString();
@@ -733,13 +737,29 @@ DefineEngineMethod( SimXMLDocument, nextAttribute, const char*, (),,
 // -----------------------------------------------------------------------------
 const char* SimXMLDocument::prevAttribute()
 {
+   // Get the current element
+   if (m_paNode.empty())
+   {
+      return StringTable->EmptyString();
+   }
+   const S32 iLastElement = m_paNode.size() - 1;
+   tinyxml2::XMLElement* pNode = m_paNode[iLastElement]->ToElement();
+   if (!pNode)
+   {
+      return StringTable->EmptyString();
+   }
+
    if(!m_CurrentAttribute)
    {
       return StringTable->EmptyString();
    }
 
    // Gets its next attribute, if any
-   m_CurrentAttribute = (fsTiXmlAttribute*)m_CurrentAttribute->Previous();
+   while (m_CurrentAttribute != NULL && m_CurrentAttribute->Next() != m_CurrentAttribute)
+   {
+      m_CurrentAttribute = m_CurrentAttribute->Next();
+   }
+   
    if(!m_CurrentAttribute)
    {
       return StringTable->EmptyString();
@@ -769,7 +789,7 @@ void SimXMLDocument::setAttribute(const char* rAttribute, const char* rVal)
    }
 
    const S32 iLastElement = m_paNode.size() - 1;
-   fsTiXmlElement* pElement = m_paNode[iLastElement];
+   tinyxml2::XMLElement* pElement = m_paNode[iLastElement]->ToElement();
    if(!pElement)
    {
       return;
@@ -801,13 +821,13 @@ void SimXMLDocument::setObjectAttributes(const char* objectID)
       return;
 
    const S32 iLastElement = m_paNode.size() - 1;
-   fsTiXmlElement* pElement = m_paNode[iLastElement];
+   tinyxml2::XMLElement* pElement = m_paNode[iLastElement]->ToElement();
    if(!pElement)
       return;
 
    char textbuf[1024];
-   fsTiXmlElement field( "Field" );
-   fsTiXmlElement group( "FieldGroup" );
+   tinyxml2::XMLElement* field = m_qDocument->NewElement("Field");
+   tinyxml2::XMLElement* group = m_qDocument->NewElement("FieldGroup");
    pElement->SetAttribute( "Name", pObject->getName() );
 
 
@@ -847,13 +867,13 @@ void SimXMLDocument::setObjectAttributes(const char* objectID)
          if( !pObject->writeField( itr->pFieldname, textbuf ) )
             continue;
 
-         field.SetValue( "Property" );
-         field.SetAttribute( "name",  itr->pFieldname );
+         field->SetValue( "Property" );
+         field->SetAttribute( "name",  itr->pFieldname );
          if( cbt != NULL )
-            field.SetAttribute( "type", cbt->getTypeName() );
+            field->SetAttribute( "type", cbt->getTypeName() );
          else
-            field.SetAttribute( "type", "TypeString" );
-         field.SetAttribute( "data", textbuf );
+            field->SetAttribute( "type", "TypeString" );
+         field->SetAttribute( "data", textbuf );
 
          pElement->InsertEndChild( field );
 
@@ -918,23 +938,21 @@ DefineEngineMethod( SimXMLDocument, setObjectAttributes, void, ( const char* obj
 // -----------------------------------------------------------------------------
 void SimXMLDocument::pushNewElement(const char* rName)
 {    
-   fsTiXmlElement cElement( rName );
-   fsTiXmlElement* pStackTop = 0;
+   tinyxml2::XMLElement* cElement = m_qDocument->NewElement( rName );
+   tinyxml2::XMLNode* pStackTop = 0;
    if(m_paNode.empty())
    {
-      pStackTop = dynamic_cast<fsTiXmlElement*>
-         (m_qDocument->InsertEndChild( cElement ) );
+      pStackTop = m_qDocument->InsertEndChild(cElement);
    }
    else
    {
       const S32 iFinalElement = m_paNode.size() - 1;
-      fsTiXmlElement* pNode = m_paNode[iFinalElement];
+      tinyxml2::XMLNode *pNode = m_paNode[iFinalElement];
       if(!pNode)
       {
          return;
       }
-      pStackTop = dynamic_cast<fsTiXmlElement*>
-         (pNode->InsertEndChild( cElement ));
+      pStackTop = pNode->InsertEndChild( cElement );
    }
    if(!pStackTop)
    {
@@ -962,13 +980,12 @@ DefineEngineMethod( SimXMLDocument, pushNewElement, void, ( const char* name ),,
 // New element is placed on top of element stack.
 // -----------------------------------------------------------------------------
 void SimXMLDocument::addNewElement(const char* rName)
-{    
-   fsTiXmlElement cElement( rName );
-   fsTiXmlElement* pStackTop = 0;
+{
+   tinyxml2::XMLElement* cElement = m_qDocument->NewElement(rName);
+   tinyxml2::XMLNode* pStackTop = 0;
    if(m_paNode.empty())
    {
-      pStackTop = dynamic_cast<fsTiXmlElement*>
-         (m_qDocument->InsertEndChild( cElement ));
+      pStackTop = m_qDocument->InsertEndChild( cElement );
       if(!pStackTop)
       {
          return;
@@ -980,8 +997,7 @@ void SimXMLDocument::addNewElement(const char* rName)
    const S32 iParentElement = m_paNode.size() - 2;
    if(iParentElement < 0)
    {
-      pStackTop = dynamic_cast<fsTiXmlElement*>
-         (m_qDocument->InsertEndChild( cElement ));
+      pStackTop = m_qDocument->InsertEndChild( cElement );
       if(!pStackTop)
       {
          return;
@@ -991,13 +1007,12 @@ void SimXMLDocument::addNewElement(const char* rName)
    }
    else
    {
-      fsTiXmlElement* pNode = m_paNode[iParentElement];
+      tinyxml2::XMLNode* pNode = m_paNode[iParentElement];
       if(!pNode)
       {
          return;
       }   
-      pStackTop = dynamic_cast<fsTiXmlElement*>
-         (pNode->InsertEndChild( cElement ));
+      pStackTop = pNode->InsertEndChild( cElement );
       if(!pStackTop)
       {
          return;
@@ -1030,7 +1045,7 @@ DefineEngineMethod( SimXMLDocument, addNewElement, void, ( const char* name ),,
 // -----------------------------------------------------------------------------
 void SimXMLDocument::addHeader(void)
 {
-   fsTiXmlDeclaration cDeclaration("1.0", "utf-8", "yes");
+   tinyxml2::XMLDeclaration* cDeclaration = m_qDocument->NewDeclaration("xml version=\"1.0\" encoding=\"UTF-8\" standalone =\"yes\"");
    m_qDocument->InsertEndChild(cDeclaration);
 }
 
@@ -1058,8 +1073,8 @@ DefineEngineMethod( SimXMLDocument, addHeader, void, (),,
 
 void SimXMLDocument::addComment(const char* comment)
 {
-   fsTiXmlComment cComment;
-   cComment.SetValue(comment);
+   tinyxml2::XMLComment* cComment = m_qDocument->NewComment(comment);
+   cComment->SetValue(comment);
    m_qDocument->InsertEndChild(cComment);
 }
 
@@ -1094,12 +1109,12 @@ const char* SimXMLDocument::readComment( S32 index )
    if(!m_paNode.empty())
    {
       const S32 iLastElement = m_paNode.size() - 1;
-      fsTiXmlElement* pNode = m_paNode[iLastElement];
+      tinyxml2::XMLNode* pNode = m_paNode[iLastElement];
       if(!pNode)
       {
          return "";
       }
-      TiXmlNode* node = pNode->FirstChild();
+      tinyxml2::XMLNode* node = pNode->FirstChild();
       for( S32 i = 0; i < index; i++ )
       {
          if( !node )
@@ -1110,7 +1125,7 @@ const char* SimXMLDocument::readComment( S32 index )
 
       if( node )
       {
-         TiXmlComment* comment = node->ToComment();
+         tinyxml2::XMLComment* comment = node->ToComment();
          if( comment )
             return comment->Value();
       }
@@ -1121,7 +1136,7 @@ const char* SimXMLDocument::readComment( S32 index )
       {
          return "";
       }
-      TiXmlNode* node = m_qDocument->FirstChild();
+      tinyxml2::XMLNode* node = m_qDocument->FirstChild();
       for( S32 i = 0; i < index; i++ )
       {
          if( !node )
@@ -1132,7 +1147,7 @@ const char* SimXMLDocument::readComment( S32 index )
 
       if( node )
       {
-         TiXmlComment* comment = node->ToComment();
+         tinyxml2::XMLComment* comment = node->ToComment();
          if( comment )
             return comment->Value();
       }
@@ -1162,11 +1177,11 @@ void SimXMLDocument::addText(const char* text)
       return;
 
    const S32 iFinalElement = m_paNode.size() - 1;
-   fsTiXmlElement* pNode = m_paNode[iFinalElement];
+   tinyxml2::XMLNode* pNode = m_paNode[iFinalElement];
    if(!pNode)
       return;
 
-   fsTiXmlText cText(text);
+   tinyxml2::XMLText* cText = m_qDocument->NewText(text);
    pNode->InsertEndChild( cText );
 }
 
@@ -1207,14 +1222,14 @@ const char* SimXMLDocument::getText()
       return "";
 
    const S32 iFinalElement = m_paNode.size() - 1;
-   TiXmlNode* pNode = m_paNode[iFinalElement];
+   tinyxml2::XMLNode* pNode = m_paNode[iFinalElement];
    if(!pNode)
       return "";
 
    if(!pNode->FirstChild())
       return "";
 
-   fsTiXmlText* text = (fsTiXmlText*)pNode->FirstChild()->ToText();
+   tinyxml2::XMLText* text = pNode->FirstChild()->ToText();
    if( !text )
       return "";
 
@@ -1267,18 +1282,18 @@ void SimXMLDocument::removeText()
       return;
 
    const S32 iFinalElement = m_paNode.size() - 1;
-   fsTiXmlElement* pNode = m_paNode[iFinalElement];
+   tinyxml2::XMLNode* pNode = m_paNode[iFinalElement];
    if(!pNode)
       return;
 
    if( !pNode->FirstChild() )
       return;
 
-   fsTiXmlText* text = (fsTiXmlText*)pNode->FirstChild()->ToText();
+   tinyxml2::XMLText* text = pNode->FirstChild()->ToText();
    if( !text )
       return;
 
-   pNode->RemoveChild(text);
+   pNode->DeleteChild(text);
 }
 
 DefineEngineMethod( SimXMLDocument, removeText, void, (),,
@@ -1303,11 +1318,11 @@ void SimXMLDocument::addData(const char* text)
       return;
 
    const S32 iFinalElement = m_paNode.size() - 1;
-   fsTiXmlElement* pNode = m_paNode[iFinalElement];
+   tinyxml2::XMLNode* pNode = m_paNode[iFinalElement];
    if(!pNode)
       return;
 
-   fsTiXmlText cText(text);
+   tinyxml2::XMLText* cText = m_qDocument->NewText(text);
    pNode->InsertEndChild( cText );
 }
 
@@ -1349,14 +1364,14 @@ const char* SimXMLDocument::getData()
       return "";
 
    const S32 iFinalElement = m_paNode.size() - 1;
-   TiXmlNode* pNode = m_paNode[iFinalElement];
+   tinyxml2::XMLNode* pNode = m_paNode[iFinalElement];
    if(!pNode)
       return "";
 
    if( !pNode->FirstChild() )
       return "";
 
-   TiXmlText* text = pNode->FirstChild()->ToText();
+   tinyxml2::XMLText* text = pNode->FirstChild()->ToText();
    if( !text )
       return "";
 

+ 7 - 8
Engine/source/console/SimXMLDocument.h

@@ -35,11 +35,10 @@
 #include "core/util/tVector.h"
 #endif // _TVECTOR_H_
 
-
-class fsTiXmlDocument;
-class fsTiXmlElement;
-class fsTiXmlAttribute;
-
+#ifndef TINYXML2_INCLUDED
+#include <tinyxml2.h>
+#endif // TINYXML2_INCLUDED
+#include "persistence/taml/fsTinyXml.h"
 
 class SimXMLDocument: public SimObject
 {
@@ -136,11 +135,11 @@ class SimXMLDocument: public SimObject
       
    private:
       // Document.
-      fsTiXmlDocument* m_qDocument;
+      VfsXMLDocument* m_qDocument;
       // Stack of nodes.
-      Vector<fsTiXmlElement*> m_paNode;
+      Vector<tinyxml2::XMLNode*> m_paNode;
      // The current attribute
-      fsTiXmlAttribute* m_CurrentAttribute;
+      const tinyxml2::XMLAttribute* m_CurrentAttribute;
 
    public:
       DECLARE_CONOBJECT(SimXMLDocument);

+ 2 - 2
Engine/source/console/consoleObject.h

@@ -52,7 +52,7 @@
    #include "console/simObjectRef.h"
 #endif
 #ifndef TINYXML_INCLUDED
-   #include "tinyxml.h"
+   #include "tinyxml2.h"
 #endif
 
 /// @file
@@ -208,7 +208,7 @@ public:
    typedef ConsoleBaseType Parent;
 
    /// Allows the writing of a custom TAML schema.
-   typedef void(*WriteCustomTamlSchema)(const AbstractClassRep* pClassRep, TiXmlElement* pParentElement);
+   typedef void(*WriteCustomTamlSchema)(const AbstractClassRep* pClassRep, tinyxml2::XMLElement* pParentElement);
 
    /// @name 'Tructors
    /// @{

+ 111 - 599
Engine/source/persistence/taml/fsTinyXml.cpp

@@ -21,13 +21,16 @@
 //-----------------------------------------------------------------------------
 
 #include "fsTinyXml.h"
+
+#include <cassert>
+
 #include "console/console.h"
 
-bool fsTiXmlDocument::LoadFile( const char * pFilename, TiXmlEncoding encoding )
+bool VfsXMLDocument::LoadFile(const char* pFilename)
 {
    // Expand the file-path.
    char filenameBuffer[1024];
-   Con::expandScriptFilename( filenameBuffer, sizeof(filenameBuffer), pFilename );
+   Con::expandScriptFilename(filenameBuffer, sizeof(filenameBuffer), pFilename);
 
    FileStream stream;
 
@@ -38,15 +41,15 @@ bool fsTiXmlDocument::LoadFile( const char * pFilename, TiXmlEncoding encoding )
 #endif
 
    // File open for read?
-   if ( !stream.open( filenameBuffer, Torque::FS::File::Read ) )
+   if (!stream.open(filenameBuffer, Torque::FS::File::Read))
    {
       // No, so warn.
-      Con::warnf("TamlXmlParser::parse() - Could not open filename '%s' for parse.", filenameBuffer );
+      Con::warnf("TamlXmlParser::parse() - Could not open filename '%s' for parse.", filenameBuffer);
       return false;
    }
 
    // Load document from stream.
-   if ( !LoadFile( stream ) )
+   if (!LoadFile(stream))
    {
       // Warn!
       Con::warnf("TamlXmlParser: Could not load Taml XML file from stream.");
@@ -58,7 +61,7 @@ bool fsTiXmlDocument::LoadFile( const char * pFilename, TiXmlEncoding encoding )
    return true;
 }
 
-bool fsTiXmlDocument::SaveFile( const char * pFilename ) const
+bool VfsXMLDocument::SaveFile(const char* pFilename)
 {
    // Expand the file-name into the file-path buffer.
    char filenameBuffer[1024];
@@ -67,10 +70,10 @@ bool fsTiXmlDocument::SaveFile( const char * pFilename ) const
    FileStream stream;
 
    // File opened?
-   if ( !stream.open( filenameBuffer, Torque::FS::File::Write ) )
+   if (!stream.open(filenameBuffer, Torque::FS::File::Write))
    {
       // No, so warn.
-      Con::warnf("Taml::writeFile() - Could not open filename '%s' for write.", filenameBuffer );
+      Con::warnf("Taml::writeFile() - Could not open filename '%s' for write.", filenameBuffer);
       return false;
    }
 
@@ -80,10 +83,80 @@ bool fsTiXmlDocument::SaveFile( const char * pFilename ) const
    return ret;
 }
 
-bool fsTiXmlDocument::LoadFile( FileStream &stream, TiXmlEncoding encoding )
+void VfsXMLDocument::ClearError()
+{
+   _errorID = tinyxml2::XML_SUCCESS;
+   _errorLineNum = 0;
+   _errorStr.Reset();
+
+   tinyxml2::XMLDocument::ClearError();
+}
+
+void VfsXMLDocument::SetError(tinyxml2::XMLError error, int lineNum, const char* format, ...)
+{
+   TIXMLASSERT(error >= 0 && error < tinyxml2::XML_ERROR_COUNT);
+   _errorID = error;
+   _errorLineNum = lineNum;
+   _errorStr.Reset();
+
+   const size_t BUFFER_SIZE = 1000;
+   char* buffer = new char[BUFFER_SIZE];
+
+   TIXMLASSERT(sizeof(error) <= sizeof(int));
+   dSprintf(buffer, BUFFER_SIZE, "Error=%s ErrorID=%d (0x%x) Line number=%d", ErrorIDToName(error), int(error), int(error), lineNum);
+
+   if (format) {
+      size_t len = strlen(buffer);
+      dSprintf(buffer + len, BUFFER_SIZE - len, ": ");
+      len = strlen(buffer);
+
+      va_list va;
+      va_start(va, format);
+      dSprintf(buffer + len, BUFFER_SIZE - len, format, va);
+      va_end(va);
+   }
+   _errorStr.SetStr(buffer);
+   delete[] buffer;
+}
+
+VfsXMLPrinter::VfsXMLPrinter(FileStream& stream, bool compact, int depth)
+   : XMLPrinter(NULL, compact, depth),
+     m_Stream(stream)
+{
+}
+
+VfsXMLPrinter::~VfsXMLPrinter()
+{
+   m_Stream.flush();
+   m_Stream.close();
+}
+
+void VfsXMLPrinter::Print(const char* format, ...)
+{
+   va_list     va;
+   va_start(va, format);
+
+   m_Stream.writeFormattedBuffer(format, va);
+
+   va_end(va);
+}
+
+void VfsXMLPrinter::Write(const char* data, size_t size)
+{
+   m_Stream.write(size, data);
+}
+
+void VfsXMLPrinter::Putc(char ch)
+{
+   m_Stream.write(static_cast<U8>(ch));
+}
+
+bool VfsXMLDocument::LoadFile(FileStream& stream)
 {
    // Delete the existing data:
    Clear();
+   // Clear shadowed error
+   ClearError();
    //TODO: Can't clear location, investigate if this gives issues.
    //doc.location.Clear();
 
@@ -91,9 +164,9 @@ bool fsTiXmlDocument::LoadFile( FileStream &stream, TiXmlEncoding encoding )
    long length = stream.getStreamSize();
 
    // Strange case, but good to handle up front.
-   if ( length <= 0 )
+   if (length <= 0)
    {
-      SetError( TiXmlDocument::TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
+      SetError(tinyxml2::XML_ERROR_EMPTY_DOCUMENT, 0, 0);
       return false;
    }
 
@@ -118,12 +191,13 @@ bool fsTiXmlDocument::LoadFile( FileStream &stream, TiXmlEncoding encoding )
    }
    */
 
-   char* buf = new char[ length+1 ];
+   char* buf = new char[length + 1];
    buf[0] = 0;
 
-   if ( !stream.read( length, buf ) ) {
+   if (!stream.read(length, buf))
+   {
       delete [] buf;
-      SetError( TiXmlDocument::TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN );
+      SetError(tinyxml2::XML_ERROR_FILE_COULD_NOT_BE_OPENED, 0, 0);
       return false;
    }
 
@@ -138,610 +212,48 @@ bool fsTiXmlDocument::LoadFile( FileStream &stream, TiXmlEncoding encoding )
    //                * CR+LF: DEC RT-11 and most other early non-Unix, non-IBM OSes, CP/M, MP/M, DOS, OS/2, Microsoft Windows, Symbian OS
    //                * CR:    Commodore 8-bit machines, Apple II family, Mac OS up to version 9 and OS-9
 
-   const char* p = buf;        // the read head
-   char* q = buf;                        // the write head
+   const char* p = buf; // the read head
+   char* q = buf; // the write head
    const char CR = 0x0d;
    const char LF = 0x0a;
 
    buf[length] = 0;
-   while( *p ) {
-      assert( p < (buf+length) );
-      assert( q <= (buf+length) );
-      assert( q <= p );
+   while (*p)
+   {
+      assert(p < (buf+length));
+      assert(q <= (buf+length));
+      assert(q <= p);
 
-      if ( *p == CR ) {
+      if (*p == CR)
+      {
          *q++ = LF;
          p++;
-         if ( *p == LF ) {                // check for CR+LF (and skip LF)
+         if (*p == LF)
+         {
+            // check for CR+LF (and skip LF)
             p++;
          }
       }
-      else {
+      else
+      {
          *q++ = *p++;
       }
    }
-   assert( q <= (buf+length) );
+   assert(q <= (buf+length));
    *q = 0;
 
-   Parse( buf, 0, encoding );
+   Parse(buf, length);
 
    delete [] buf;
    return !Error();
 }
 
-bool fsTiXmlDocument::SaveFile( FileStream &stream ) const
-{
-   if ( useMicrosoftBOM ) 
-   {
-      const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
-      const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
-      const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
-
-      stream.write( TIXML_UTF_LEAD_0 );
-      stream.write( TIXML_UTF_LEAD_1 );
-      stream.write( TIXML_UTF_LEAD_2 );
-   }
-   Print( stream, 0 );
-   return true;
-}
-
-void fsTiXmlDocument::Print( FileStream& stream, int depth ) const
-{
-   for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() )
-   {
-      //AttemptPrintTiNode(const_cast<TiXmlNode*>(node), stream, depth);
-      dynamic_cast<const fsTiXmlNode*>(node)->Print( stream, depth );
-      stream.writeText( "\n" );
-   }
-}
-
-void fsTiXmlAttribute::Print( FileStream& stream, int depth, TIXML_STRING* str ) const
-{
-   TIXML_STRING n, v;
-
-   TiXmlString val = TiXmlString(Value());
-
-   EncodeString( NameTStr(), &n );
-   EncodeString( val, &v );
-
-   for ( int i=0; i< depth; i++ ) {
-      stream.writeText( "    " );
-   }
-
-   if (val.find ('\"') == TIXML_STRING::npos) {
-      const char* pValue = v.c_str();
-      char buffer[4096];
-      const S32 length = dSprintf(buffer, sizeof(buffer), "%s=\"%s\"", n.c_str(), pValue);
-      stream.write(length, buffer);
-      if ( str ) {
-         (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\"";
-      }
-   }
-   else {
-      char buffer[4096];
-      const S32 length = dSprintf(buffer, sizeof(buffer), "%s='%s'", n.c_str(), v.c_str());
-      stream.write(length, buffer);
-      if ( str ) {
-         (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'";
-      }
-   }
-}
-
-void fsTiXmlDeclaration::Print(FileStream& stream, int depth, TiXmlString* str) const
-{
-   stream.writeStringBuffer( "<?xml " );
-   if ( str )	 (*str) += "<?xml ";
-
-   if ( !version.empty() ) {
-      stream.writeFormattedBuffer( "version=\"%s\" ", version.c_str ());
-      if ( str ) { (*str) += "version=\""; (*str) += version; (*str) += "\" "; }
-   }
-   if ( !encoding.empty() ) {
-      stream.writeFormattedBuffer( "encoding=\"%s\" ", encoding.c_str ());
-      if ( str ) { (*str) += "encoding=\""; (*str) += encoding; (*str) += "\" "; }
-   }
-   if ( !standalone.empty() ) {
-      stream.writeFormattedBuffer( "standalone=\"%s\" ", standalone.c_str ());
-      if ( str ) { (*str) += "standalone=\""; (*str) += standalone; (*str) += "\" "; }
-   }
-   stream.writeStringBuffer( "?>" );
-   if ( str )	 (*str) += "?>";
-}
-
-void fsTiXmlElement::Print(FileStream& stream, int depth) const
-{
-   int i;
-   for ( i=0; i<depth; i++ ) {
-      stream.writeStringBuffer( "    " );
-   }
-
-   stream.writeFormattedBuffer( "<%s", value.c_str() );
-
-   const TiXmlAttribute* attrib;
-   for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() )
-   {
-      stream.writeStringBuffer( "\n" );
-      dynamic_cast<const fsTiXmlAttribute*>(attrib)->Print( stream, depth+1 );
-   }
-
-   // There are 3 different formatting approaches:
-   // 1) An element without children is printed as a <foo /> node
-   // 2) An element with only a text child is printed as <foo> text </foo>
-   // 3) An element with children is printed on multiple lines.
-   TiXmlNode* node;
-   if ( !firstChild )
-   {
-      stream.writeStringBuffer( " />" );
-   }
-   else if ( firstChild == lastChild && firstChild->ToText() )
-   {
-      stream.writeStringBuffer( ">" );
-      dynamic_cast<const fsTiXmlNode*>(firstChild)->Print( stream, depth + 1 );
-      stream.writeFormattedBuffer( "</%s>", value.c_str() );
-   }
-   else
-   {
-      stream.writeStringBuffer( ">" );
-
-      for ( node = firstChild; node; node=node->NextSibling() )
-      {
-         if ( !node->ToText() )
-         {
-            stream.writeStringBuffer( "\n" );
-         }
-         dynamic_cast<const fsTiXmlNode*>(node)->Print( stream, depth+1 );
-      }
-      stream.writeStringBuffer( "\n" );
-      for( i=0; i<depth; ++i ) {
-         stream.writeStringBuffer( "    " );
-      }
-      stream.writeFormattedBuffer( "</%s>", value.c_str() );
-   }
-}
-
-void fsTiXmlComment::Print(FileStream& stream, int depth) const
+bool VfsXMLDocument::SaveFile(FileStream& stream)
 {
-   for ( int i=0; i<depth; i++ )
-   {
-      stream.writeStringBuffer( "    " );
-   }
-   stream.writeFormattedBuffer( "<!--%s-->", value.c_str() );
-}
-
-void fsTiXmlText::Print(FileStream& stream, int depth) const
-{ 
-   if ( cdata )
-   {
-      int i;
-      stream.writeStringBuffer( "\n" );
-      for ( i=0; i<depth; i++ ) {
-         stream.writeStringBuffer( "    " );
-      }
-      stream.writeFormattedBuffer( "<![CDATA[%s]]>\n", value.c_str() );	// unformatted output
-   }
-   else
-   {
-      TIXML_STRING buffer;
-      EncodeString( value, &buffer );
-      stream.writeFormattedBuffer( "%s", buffer.c_str() );
-   }
-}
-
-void fsTiXmlUnknown::Print(FileStream& stream, int depth) const
-{
-   for ( int i=0; i<depth; i++ )
-      stream.writeStringBuffer( "    " );
-
-   stream.writeFormattedBuffer( "<%s>", value.c_str() );
-}
-
-static TiXmlNode* TiNodeIdentify( TiXmlNode* parent, const char* p, TiXmlEncoding encoding )
-{
-   	TiXmlNode* returnNode = 0;
-
-	p = TiXmlNode::SkipWhiteSpace( p, encoding );
-	if( !p || !*p || *p != '<' )
-	{
-		return 0;
-	}
-
-	p = TiXmlNode::SkipWhiteSpace( p, encoding );
-
-	if ( !p || !*p )
-	{
-		return 0;
-	}
-
-	// What is this thing? 
-	// - Elements start with a letter or underscore, but xml is reserved.
-	// - Comments: <!--
-	// - Decleration: <?xml
-	// - Everthing else is unknown to tinyxml.
-	//
-
-	const char* xmlHeader = { "<?xml" };
-	const char* commentHeader = { "<!--" };
-	const char* dtdHeader = { "<!" };
-	const char* cdataHeader = { "<![CDATA[" };
-
-	if ( TiXmlNode::StringEqual( p, xmlHeader, true, encoding ) )
-	{
-		#ifdef DEBUG_PARSER
-			TIXML_LOG( "XML parsing Declaration\n" );
-		#endif
-		returnNode = new fsTiXmlDeclaration();
-	}
-	else if ( TiXmlNode::StringEqual( p, commentHeader, false, encoding ) )
-	{
-		#ifdef DEBUG_PARSER
-			TIXML_LOG( "XML parsing Comment\n" );
-		#endif
-		returnNode = new fsTiXmlComment();
-	}
-	else if ( TiXmlNode::StringEqual( p, cdataHeader, false, encoding ) )
-	{
-		#ifdef DEBUG_PARSER
-			TIXML_LOG( "XML parsing CDATA\n" );
-		#endif
-		TiXmlText* text = new fsTiXmlText( "" );
-		text->SetCDATA( true );
-		returnNode = text;
-	}
-	else if ( TiXmlNode::StringEqual( p, dtdHeader, false, encoding ) )
-	{
-		#ifdef DEBUG_PARSER
-			TIXML_LOG( "XML parsing Unknown(1)\n" );
-		#endif
-		returnNode = new fsTiXmlUnknown();
-	}
-	else if (    TiXmlNode::IsAlpha( *(p+1), encoding )
-			  || *(p+1) == '_' )
-	{
-		#ifdef DEBUG_PARSER
-			TIXML_LOG( "XML parsing Element\n" );
-		#endif
-		returnNode = new fsTiXmlElement( "" );
-	}
-	else
-	{
-		#ifdef DEBUG_PARSER
-			TIXML_LOG( "XML parsing Unknown(2)\n" );
-		#endif
-		returnNode = new fsTiXmlUnknown();
-	}
-
-	if ( returnNode )
-	{
-		// Set the parent, so it can report errors
-		returnNode->parent = parent;
-	}
-	return returnNode;
-}
-
-TiXmlNode* fsTiXmlDocument::Identify(  const char* p, TiXmlEncoding encoding )
-{
-   return TiNodeIdentify(this, p, encoding);
-}
-
-TiXmlNode* fsTiXmlElement::Identify(  const char* p, TiXmlEncoding encoding )
-{
-   return TiNodeIdentify(this, p, encoding);
-}
-
-const char* fsTiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
-{
-	p = SkipWhiteSpace( p, encoding );
-	TiXmlDocument* document = GetDocument();
-
-	if ( !p || !*p )
-	{
-		if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, 0, 0, encoding );
-		return 0;
-	}
-
-	if ( data )
-	{
-		data->Stamp( p, encoding );
-		location = data->Cursor();
-	}
-
-	if ( *p != '<' )
-	{
-		if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, p, data, encoding );
-		return 0;
-	}
-
-	p = SkipWhiteSpace( p+1, encoding );
-
-	// Read the name.
-	const char* pErr = p;
-
-    p = ReadName( p, &value, encoding );
-	if ( !p || !*p )
-	{
-		if ( document )	document->SetError( TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, pErr, data, encoding );
-		return 0;
-	}
-
-    TIXML_STRING endTag ("</");
-	endTag += value;
-
-	// Check for and read attributes. Also look for an empty
-	// tag or an end tag.
-	while ( p && *p )
-	{
-		pErr = p;
-		p = SkipWhiteSpace( p, encoding );
-		if ( !p || !*p )
-		{
-			if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding );
-			return 0;
-		}
-		if ( *p == '/' )
-		{
-			++p;
-			// Empty tag.
-			if ( *p  != '>' )
-			{
-				if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY, p, data, encoding );		
-				return 0;
-			}
-			return (p+1);
-		}
-		else if ( *p == '>' )
-		{
-			// Done with attributes (if there were any.)
-			// Read the value -- which can include other
-			// elements -- read the end tag, and return.
-			++p;
-			p = ReadValue( p, data, encoding );		// Note this is an Element method, and will set the error if one happens.
-			if ( !p || !*p ) {
-				// We were looking for the end tag, but found nothing.
-				// Fix for [ 1663758 ] Failure to report error on bad XML
-				if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
-				return 0;
-			}
-
-			// We should find the end tag now
-			// note that:
-			// </foo > and
-			// </foo> 
-			// are both valid end tags.
-			if ( StringEqual( p, endTag.c_str(), false, encoding ) )
-			{
-				p += endTag.length();
-				p = SkipWhiteSpace( p, encoding );
-				if ( p && *p && *p == '>' ) {
-					++p;
-					return p;
-				}
-				if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
-				return 0;
-			}
-			else
-			{
-				if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
-				return 0;
-			}
-		}
-		else
-		{
-			// Try to read an attribute:
-			TiXmlAttribute* attrib = new fsTiXmlAttribute();
-			if ( !attrib )
-			{
-				return 0;
-			}
-
-			attrib->SetDocument( document );
-			pErr = p;
-			p = attrib->Parse( p, data, encoding );
-
-			if ( !p || !*p )
-			{
-				if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding );
-				delete attrib;
-				return 0;
-			}
-
-			// Handle the strange case of double attributes:
-			#ifdef TIXML_USE_STL
-			TiXmlAttribute* node = attributeSet.Find( attrib->NameTStr() );
-			#else
-			TiXmlAttribute* node = attributeSet.Find( attrib->Name() );
-			#endif
-			if ( node )
-			{
-				if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding );
-				delete attrib;
-				return 0;
-			}
-
-			attributeSet.Add( attrib );
-		}
-	}
-	return p;
-}
-
-/*
-TiXmlNode* fsTiXmlNode::Identify(char const* p, TiXmlEncoding encoding)
-{	
-TiXmlNode* returnNode = 0;
-
-p = TiXmlBase::SkipWhiteSpace( p, encoding );
-if( !p || !*p || *p != '<' )
-{
-return 0;
-}
-
-p = TiXmlBase::SkipWhiteSpace( p, encoding );
-
-if ( !p || !*p )
-{
-return 0;
-}
-
-// What is this thing? 
-// - Elements start with a letter or underscore, but xml is reserved.
-// - Comments: <!--
-// - Decleration: <?xml
-// - Everthing else is unknown to tinyxml.
-//
-
-const char* xmlHeader = { "<?xml" };
-const char* commentHeader = { "<!--" };
-const char* dtdHeader = { "<!" };
-const char* cdataHeader = { "<![CDATA[" };
-
-if ( TiXmlBase::StringEqual( p, xmlHeader, true, encoding ) )
-{
-#ifdef DEBUG_PARSER
-TIXML_LOG( "XML parsing Declaration\n" );
-#endif
-returnNode = new fsTiXmlDeclaration();
-}
-else if ( TiXmlBase::StringEqual( p, commentHeader, false, encoding ) )
-{
-#ifdef DEBUG_PARSER
-TIXML_LOG( "XML parsing Comment\n" );
-#endif
-returnNode = new fsTiXmlComment();
-}
-else if ( TiXmlBase::StringEqual( p, cdataHeader, false, encoding ) )
-{
-#ifdef DEBUG_PARSER
-TIXML_LOG( "XML parsing CDATA\n" );
-#endif
-fsTiXmlText* text = new fsTiXmlText( "" );
-text->SetCDATA( true );
-returnNode = text;
-}
-else if ( TiXmlBase::StringEqual( p, dtdHeader, false, encoding ) )
-{
-#ifdef DEBUG_PARSER
-TIXML_LOG( "XML parsing Unknown(1)\n" );
-#endif
-returnNode = new fsTiXmlUnknown();
-}
-else if (    TiXmlBase::IsAlpha( *(p+1), encoding )
-|| *(p+1) == '_' )
-{
-#ifdef DEBUG_PARSER
-TIXML_LOG( "XML parsing Element\n" );
-#endif
-returnNode = new fsTiXmlElement( "" );
-}
-else
-{
-#ifdef DEBUG_PARSER
-TIXML_LOG( "XML parsing Unknown(2)\n" );
-#endif
-returnNode = new fsTiXmlUnknown();
-}
-
-if ( returnNode )
-{
-// Set the parent, so it can report errors
-returnNode->parent = this;
-}
-return returnNode;
-}
-
-const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
-const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
-const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
-
-char const* fsTiXmlDocument::Parse(char const* p, TiXmlParsingData* prevData, TiXmlEncoding encoding)
-{
-ClearError();
-
-// Parse away, at the document level. Since a document
-// contains nothing but other tags, most of what happens
-// here is skipping white space.
-if ( !p || !*p )
-{
-SetError( TiXmlBase::TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
-return 0;
-}
-
-// Note that, for a document, this needs to come
-// before the while space skip, so that parsing
-// starts from the pointer we are given.
-location.Clear();
-if ( prevData )
-{
-location.row = prevData->Cursor().row;
-location.col = prevData->Cursor().col;
-}
-else
-{
-location.row = 0;
-location.col = 0;
-}
-TiXmlParsingData data( p, TabSize(), location.row, location.col );
-location = data.Cursor();
-
-if ( encoding == TIXML_ENCODING_UNKNOWN )
-{
-// Check for the Microsoft UTF-8 lead bytes.
-const unsigned char* pU = (const unsigned char*)p;
-if (	*(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0
-&& *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1
-&& *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 )
-{
-encoding = TIXML_ENCODING_UTF8;
-useMicrosoftBOM = true;
-}
-}
-
-p = TiXmlBase::SkipWhiteSpace( p, encoding );
-if ( !p )
-{
-SetError( TiXmlBase::TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
-return 0;
-}
-
-while ( p && *p )
-{
-TiXmlNode* node = fsTiXmlNode::Identify( p, encoding );
-if ( node )
-{
-p = node->Parse( p, &data, encoding );
-LinkEndChild( node );
-}
-else
-{
-break;
-}
-
-// Did we get encoding info?
-if (    encoding == TIXML_ENCODING_UNKNOWN
-&& node->ToDeclaration() )
-{
-TiXmlDeclaration* dec = node->ToDeclaration();
-const char* enc = dec->Encoding();
-assert( enc );
-
-if ( *enc == 0 )
-encoding = TIXML_ENCODING_UTF8;
-else if ( TiXmlBase::StringEqual( enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN ) )
-encoding = TIXML_ENCODING_UTF8;
-else if ( TiXmlBase::StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) )
-encoding = TIXML_ENCODING_UTF8;	// incorrect, but be nice
-else 
-encoding = TIXML_ENCODING_LEGACY;
-}
-
-p = TiXmlBase::SkipWhiteSpace( p, encoding );
-}
-
-// Was this empty?
-if ( !firstChild ) {
-SetError( TiXmlBase::TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding );
-return 0;
-}
-
-// All is well.
-return p;
+   // Clear any error from the last save, otherwise it will get reported
+   // for *this* call.
+   ClearError();
+   VfsXMLPrinter printer(stream, false, 0);
+   Print(&printer);
+   return !Error();
 }
-*/

+ 62 - 180
Engine/source/persistence/taml/fsTinyXml.h

@@ -25,7 +25,7 @@
 
 
 #ifndef TINYXML_INCLUDED
-#include "tinyxml/tinyxml.h"
+#include "tinyxml/tinyxml2.h"
 #endif
 
 #include "platform/platform.h"
@@ -34,215 +34,97 @@
 #include "core/stream/fileStream.h"
 #endif
 
-class fsTiXmlNode
+class VfsXMLPrinter : public tinyxml2::XMLPrinter
 {
 public:
-   virtual void Print( FileStream& stream, int depth ) const = 0;
-};
-
-class fsTiXmlDocument : public TiXmlDocument, public fsTiXmlNode
-{
-public:
-   bool LoadFile( FileStream &stream, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
-   bool SaveFile( FileStream &stream ) const;
-	/// Load a file using the given filename. Returns true if successful.
-	bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
-	/// Save a file using the given filename. Returns true if successful.
-	bool SaveFile( const char * filename ) const;
-   virtual void Print( FileStream& stream, int depth ) const;
-
-   virtual TiXmlNode* Clone() const
-   {
-	   TiXmlDocument* clone = new fsTiXmlDocument();
-	   if ( !clone )
-		   return 0;
+   VfsXMLPrinter(FileStream& stream, bool compact = false, int depth = 0);
+   ~VfsXMLPrinter() override;
 
-	   CopyTo( clone );
-	   return clone;
-   }
-   TiXmlNode* Identify( const char* p, TiXmlEncoding encoding );
-};
-
-class fsTiXmlAttribute : public TiXmlAttribute, public fsTiXmlNode
-{
-public:
-   virtual void Print( FileStream& stream, int depth, TIXML_STRING* str ) const;
-   virtual void Print( FileStream& stream, int depth) const
-   {
-      Print(stream, depth, 0);
-   }
+   void Print(const char* format, ...) override;
+   void Write(const char* data, size_t size) override;
+   void Putc(char ch) override;
+   FileStream& m_Stream;
 };
 
-class fsTiXmlDeclaration : public TiXmlDeclaration, public fsTiXmlNode
+class VfsXMLDocument : public tinyxml2::XMLDocument
 {
 public:
-   fsTiXmlDeclaration(){};
-	fsTiXmlDeclaration(	const char* _version,
-						const char* _encoding,
-                  const char* _standalone ) : TiXmlDeclaration(_version, _encoding, _standalone) { }
+   bool LoadFile(FileStream& stream);
+   bool SaveFile(FileStream& stream);
+   /// Load a file using the given filename. Returns true if successful.
+   bool LoadFile(const char* filename);
+   /// Save a file using the given filename. Returns true if successful.
+   bool SaveFile(const char* filename);
 
-   virtual void Print( FileStream& stream, int depth, TIXML_STRING* str ) const;
-   virtual void Print( FileStream& stream, int depth) const
-   {
-      Print(stream, depth, 0);
-   }
+   /// Clears the error flags.
+   void ClearError();
 
-   virtual TiXmlNode* Clone() const
-   {
-	   fsTiXmlDeclaration* clone = new fsTiXmlDeclaration();
 
-	   if ( !clone )
-		   return 0;
+   tinyxml2::XMLError _errorID;
+   mutable tinyxml2::StrPair _errorStr;
+   int _errorLineNum;
 
-	   CopyTo( clone );
-	   return clone;
-   }
-};
+   // Create a parallel SetError implementation since it is private in tinyxml2
+   void SetError(tinyxml2::XMLError error, int lineNum, const char* format, ...);
 
-class fsTiXmlElement : public TiXmlElement, public fsTiXmlNode
-{
-public:
-   fsTiXmlElement(const char* in_value) : TiXmlElement(in_value) { }
-
-   virtual void Print( FileStream& stream, int depth ) const;
-
-   virtual TiXmlNode* Clone() const
+   /// Return true if there was an error parsing the document.
+   bool Error() const
    {
-	   TiXmlElement* clone = new fsTiXmlElement( Value() );
-	   if ( !clone )
-		   return 0;
-
-	   CopyTo( clone );
-	   return clone;
+      return _errorID != tinyxml2::XML_SUCCESS || XMLDocument::Error();
    }
 
-   void SetAttribute( const char* name, const char * _value )
+   /// Return the errorID.
+   tinyxml2::XMLError ErrorID() const
    {
-      TiXmlAttribute* attrib = attributeSet.Find( name );
-      if(!attrib)
+      if (XMLDocument::Error())
       {
-         attrib = new fsTiXmlAttribute();
-		   attributeSet.Add( attrib );
-		   attrib->SetName( name );
+         return XMLDocument::ErrorID();
       }
-	   if ( attrib ) {
-		   attrib->SetValue( _value );
-	   }
-   }
-   void SetAttribute( const char * name, int _value)
-   {
-	   TiXmlAttribute* attrib = attributeSet.Find( name );
-      if(!attrib)
+      else
       {
-         attrib = new fsTiXmlAttribute();
-		   attributeSet.Add( attrib );
-		   attrib->SetName( name );
+         return _errorID;
       }
-	   if ( attrib ) {
-		   attrib->SetIntValue(_value);
-	   }
    }
-   TiXmlNode* Identify( const char* p, TiXmlEncoding encoding );
-   virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
-};
 
-class fsTiXmlComment : public TiXmlComment, public fsTiXmlNode
-{
-public:
-   virtual void Print( FileStream& stream, int depth ) const;
-
-   virtual TiXmlNode* Clone() const
+   const char* ErrorName() const
    {
-	   TiXmlComment* clone = new fsTiXmlComment();
-
-	   if ( !clone )
-		   return 0;
-
-	   CopyTo( clone );
-	   return clone;
+      if (XMLDocument::Error())
+      {
+         return XMLDocument::ErrorName();
+      }
+      else
+      {
+         return ErrorIDToName(_errorID);
+      }
    }
-};
 
-class fsTiXmlText : public TiXmlText, public fsTiXmlNode
-{
-public:
-   fsTiXmlText (const char * initValue ) : TiXmlText(initValue) { }
-   virtual void Print( FileStream& stream, int depth ) const;
-
-   virtual TiXmlNode* Clone() const
+   /** Returns a "long form" error description. A hopefully helpful
+       diagnostic with location, line number, and/or additional info.
+   */
+   const char* ErrorStr() const
    {
-	   TiXmlText* clone = 0;
-	   clone = new fsTiXmlText( "" );
-
-	   if ( !clone )
-		   return 0;
-
-	   CopyTo( clone );
-	   return clone;
+      if (XMLDocument::Error())
+      {
+         return XMLDocument::ErrorStr();
+      }
+      else
+      {
+         return _errorStr.Empty() ? "" : _errorStr.GetStr();
+      }
    }
-};
-
-class fsTiXmlUnknown : public TiXmlUnknown, public fsTiXmlNode
-{
-public:
-   virtual void Print( FileStream& stream, int depth ) const;
 
-   virtual TiXmlNode* Clone() const
+   /// Return the line where the error occurred, or zero if unknown.
+   int ErrorLineNum() const
    {
-	   TiXmlUnknown* clone = new fsTiXmlUnknown();
-
-	   if ( !clone )
-		   return 0;
-
-	   CopyTo( clone );
-	   return clone;
+      if (XMLDocument::Error())
+      {
+         return XMLDocument::ErrorLineNum();
+      }
+      else
+      {
+         return _errorLineNum;
+      }
    }
 };
 
-static bool AttemptPrintTiNode(class fsTiXmlDocument* node, FileStream& stream, int depth)
-{
-   fsTiXmlDocument* fsDoc = dynamic_cast<fsTiXmlDocument*>(node);
-   if(fsDoc != NULL)
-   {
-      fsDoc->Print(stream, depth);
-      return true;
-   }
-   fsTiXmlUnknown* fsUnk = dynamic_cast<fsTiXmlUnknown*>(node);
-   if(fsUnk != NULL)
-   {
-      fsUnk->Print(stream, depth);
-      return true;
-   }
-   fsTiXmlText* fsTxt = dynamic_cast<fsTiXmlText*>(node);
-   if(fsTxt != NULL)
-   {
-      fsTxt->Print(stream, depth);
-      return true;
-   }
-   fsTiXmlComment* fsCom = dynamic_cast<fsTiXmlComment*>(node);
-   if(fsCom != NULL)
-   {
-      fsCom->Print(stream, depth);
-      return true;
-   }
-   fsTiXmlElement* fsElm = dynamic_cast<fsTiXmlElement*>(node);
-   if(fsElm != NULL)
-   {
-      fsElm->Print(stream, depth);
-      return true;
-   }
-   fsTiXmlDeclaration* fsDec = dynamic_cast<fsTiXmlDeclaration*>(node);
-   if(fsDec != NULL)
-   {
-      fsDec->Print(stream, depth);
-      return true;
-   }
-   fsTiXmlAttribute* fsAtt = dynamic_cast<fsTiXmlAttribute*>(node);
-   if(fsAtt != NULL)
-   {
-      fsAtt->Print(stream, depth);
-      return true;
-   }
-   return false;
-}
 #endif //_FSTINYXML_H_

+ 77 - 75
Engine/source/persistence/taml/taml.cpp

@@ -1056,14 +1056,14 @@ ImplementEnumType(_TamlFormatMode,
       }*/
 
       // Create document.
-      TiXmlDocument schemaDocument;
+      tinyxml2::XMLDocument schemaDocument;
 
       // Add declaration.
-      TiXmlDeclaration schemaDeclaration("1.0", "iso-8859-1", "no");
+      tinyxml2::XMLDeclaration* schemaDeclaration = schemaDocument.NewDeclaration("xml version=\"1.0\" encoding=\"iso-8859-1\" standalone =\"no\"");
       schemaDocument.InsertEndChild(schemaDeclaration);
 
       // Add schema element.
-      TiXmlElement* pSchemaElement = new TiXmlElement("xs:schema");
+      tinyxml2::XMLElement* pSchemaElement = schemaDocument.NewElement("xs:schema");
       pSchemaElement->SetAttribute("xmlns:xs", "http://www.w3.org/2001/XMLSchema");
       schemaDocument.LinkEndChild(pSchemaElement);
 
@@ -1084,156 +1084,156 @@ ImplementEnumType(_TamlFormatMode,
       // *************************************************************
 
       // Vector2.
-      TiXmlComment* pVector2Comment = new TiXmlComment("Vector2 Console Type");
+      tinyxml2::XMLComment* pVector2Comment = schemaDocument.NewComment("Vector2 Console Type");
       pSchemaElement->LinkEndChild(pVector2Comment);
-      TiXmlElement* pVector2TypeElement = new TiXmlElement("xs:simpleType");
+      tinyxml2::XMLElement* pVector2TypeElement = schemaDocument.NewElement("xs:simpleType");
       pVector2TypeElement->SetAttribute("name", "Vector2_ConsoleType");
       pSchemaElement->LinkEndChild(pVector2TypeElement);
-      TiXmlElement* pVector2ElementA = new TiXmlElement("xs:restriction");
+      tinyxml2::XMLElement* pVector2ElementA = schemaDocument.NewElement("xs:restriction");
       pVector2ElementA->SetAttribute("base", "xs:string");
       pVector2TypeElement->LinkEndChild(pVector2ElementA);
-      TiXmlElement* pVector2ElementB = new TiXmlElement("xs:pattern");
+      tinyxml2::XMLElement* pVector2ElementB = schemaDocument.NewElement("xs:pattern");
       pVector2ElementB->SetAttribute("value", "([-]?(\\b[0-9]+)?\\.)?[0-9]+\\b ([-]?(\\b[0-9]+)?\\.)?[0-9]+\\b");
       pVector2ElementA->LinkEndChild(pVector2ElementB);
 
       // Point2F.
-      TiXmlComment* pPoint2FComment = new TiXmlComment("Point2F Console Type");
+      tinyxml2::XMLComment* pPoint2FComment = schemaDocument.NewComment("Point2F Console Type");
       pSchemaElement->LinkEndChild(pPoint2FComment);
-      TiXmlElement* pPoint2FTypeElement = new TiXmlElement("xs:simpleType");
+      tinyxml2::XMLElement* pPoint2FTypeElement = schemaDocument.NewElement("xs:simpleType");
       pPoint2FTypeElement->SetAttribute("name", "Point2F_ConsoleType");
       pSchemaElement->LinkEndChild(pPoint2FTypeElement);
-      TiXmlElement* pPoint2FElementA = new TiXmlElement("xs:restriction");
+      tinyxml2::XMLElement* pPoint2FElementA = schemaDocument.NewElement("xs:restriction");
       pPoint2FElementA->SetAttribute("base", "xs:string");
       pPoint2FTypeElement->LinkEndChild(pPoint2FElementA);
-      TiXmlElement* pPoint2FElementB = new TiXmlElement("xs:pattern");
+      tinyxml2::XMLElement* pPoint2FElementB = schemaDocument.NewElement("xs:pattern");
       pPoint2FElementB->SetAttribute("value", "([-]?(\\b[0-9]+)?\\.)?[0-9]+\\b ([-]?(\\b[0-9]+)?\\.)?[0-9]+\\b");
       pPoint2FElementA->LinkEndChild(pPoint2FElementB);
 
       // Point2I.
-      TiXmlComment* pPoint2IComment = new TiXmlComment("Point2I Console Type");
+      tinyxml2::XMLComment* pPoint2IComment = schemaDocument.NewComment("Point2I Console Type");
       pSchemaElement->LinkEndChild(pPoint2IComment);
-      TiXmlElement* pPoint2ITypeElement = new TiXmlElement("xs:simpleType");
+      tinyxml2::XMLElement* pPoint2ITypeElement = schemaDocument.NewElement("xs:simpleType");
       pPoint2ITypeElement->SetAttribute("name", "Point2I_ConsoleType");
       pSchemaElement->LinkEndChild(pPoint2ITypeElement);
-      TiXmlElement* pPoint2IElementA = new TiXmlElement("xs:restriction");
+      tinyxml2::XMLElement* pPoint2IElementA = schemaDocument.NewElement("xs:restriction");
       pPoint2IElementA->SetAttribute("base", "xs:string");
       pPoint2ITypeElement->LinkEndChild(pPoint2IElementA);
-      TiXmlElement* pPoint2IElementB = new TiXmlElement("xs:pattern");
+      tinyxml2::XMLElement* pPoint2IElementB = schemaDocument.NewElement("xs:pattern");
       pPoint2IElementB->SetAttribute("value", "[-]?[0-9]* [-]?[0-9]*");
       pPoint2IElementA->LinkEndChild(pPoint2IElementB);
 
       // b2AABB.
-      TiXmlComment* pb2AABBComment = new TiXmlComment("b2AABB Console Type");
+      tinyxml2::XMLComment* pb2AABBComment = schemaDocument.NewComment("b2AABB Console Type");
       pSchemaElement->LinkEndChild(pb2AABBComment);
-      TiXmlElement* pb2AABBTypeElement = new TiXmlElement("xs:simpleType");
+      tinyxml2::XMLElement* pb2AABBTypeElement = schemaDocument.NewElement("xs:simpleType");
       pb2AABBTypeElement->SetAttribute("name", "b2AABB_ConsoleType");
       pSchemaElement->LinkEndChild(pb2AABBTypeElement);
-      TiXmlElement* pb2AABBElementA = new TiXmlElement("xs:restriction");
+      tinyxml2::XMLElement* pb2AABBElementA = schemaDocument.NewElement("xs:restriction");
       pb2AABBElementA->SetAttribute("base", "xs:string");
       pb2AABBTypeElement->LinkEndChild(pb2AABBElementA);
-      TiXmlElement* pb2AABBElementB = new TiXmlElement("xs:pattern");
+      tinyxml2::XMLElement* pb2AABBElementB = schemaDocument.NewElement("xs:pattern");
       pb2AABBElementB->SetAttribute("value", "([-]?(\\b[0-9]+)?\\.)?[0-9]+\\b ([-]?(\\b[0-9]+)?\\.)?[0-9]+\\b ([-]?(\\b[0-9]+)?\\.)?[0-9]+\\b ([-]?(\\b[0-9]+)?\\.)?[0-9]+\\b");
       pb2AABBElementA->LinkEndChild(pb2AABBElementB);
 
       // RectI.
-      TiXmlComment* pRectIComment = new TiXmlComment("RectI Console Type");
+      tinyxml2::XMLComment* pRectIComment = schemaDocument.NewComment("RectI Console Type");
       pSchemaElement->LinkEndChild(pRectIComment);
-      TiXmlElement* pRectITypeElement = new TiXmlElement("xs:simpleType");
+      tinyxml2::XMLElement* pRectITypeElement = schemaDocument.NewElement("xs:simpleType");
       pRectITypeElement->SetAttribute("name", "RectI_ConsoleType");
       pSchemaElement->LinkEndChild(pRectITypeElement);
-      TiXmlElement* pRectIElementA = new TiXmlElement("xs:restriction");
+      tinyxml2::XMLElement* pRectIElementA = schemaDocument.NewElement("xs:restriction");
       pRectIElementA->SetAttribute("base", "xs:string");
       pRectITypeElement->LinkEndChild(pRectIElementA);
-      TiXmlElement* pRectIElementB = new TiXmlElement("xs:pattern");
+      tinyxml2::XMLElement* pRectIElementB = schemaDocument.NewElement("xs:pattern");
       pRectIElementB->SetAttribute("value", "[-]?[0-9]* [-]?[0-9]* [-]?[0-9]* [-]?[0-9]*");
       pRectIElementA->LinkEndChild(pRectIElementB);
 
       // RectF.
-      TiXmlComment* pRectFComment = new TiXmlComment("RectF Console Type");
+      tinyxml2::XMLComment* pRectFComment = schemaDocument.NewComment("RectF Console Type");
       pSchemaElement->LinkEndChild(pRectFComment);
-      TiXmlElement* pRectFTypeElement = new TiXmlElement("xs:simpleType");
+      tinyxml2::XMLElement* pRectFTypeElement = schemaDocument.NewElement("xs:simpleType");
       pRectFTypeElement->SetAttribute("name", "RectF_ConsoleType");
       pSchemaElement->LinkEndChild(pRectFTypeElement);
-      TiXmlElement* pRectFElementA = new TiXmlElement("xs:restriction");
+      tinyxml2::XMLElement* pRectFElementA = schemaDocument.NewElement("xs:restriction");
       pRectFElementA->SetAttribute("base", "xs:string");
       pRectFTypeElement->LinkEndChild(pRectFElementA);
-      TiXmlElement* pRectFElementB = new TiXmlElement("xs:pattern");
+      tinyxml2::XMLElement* pRectFElementB = schemaDocument.NewElement("xs:pattern");
       pRectFElementB->SetAttribute("value", "(\\b[-]?(b[0-9]+)?\\.)?[0-9]+\\b");
       pRectFElementA->LinkEndChild(pRectFElementB);
 
       // AssetId.
-      TiXmlComment* pAssetIdComment = new TiXmlComment("AssetId Console Type");
+      tinyxml2::XMLComment* pAssetIdComment = schemaDocument.NewComment("AssetId Console Type");
       pSchemaElement->LinkEndChild(pAssetIdComment);
-      TiXmlElement* pAssetIdTypeElement = new TiXmlElement("xs:simpleType");
+      tinyxml2::XMLElement* pAssetIdTypeElement = schemaDocument.NewElement("xs:simpleType");
       pAssetIdTypeElement->SetAttribute("name", "AssetId_ConsoleType");
       pSchemaElement->LinkEndChild(pAssetIdTypeElement);
-      TiXmlElement* pAssetIdElementA = new TiXmlElement("xs:restriction");
+      tinyxml2::XMLElement* pAssetIdElementA = schemaDocument.NewElement("xs:restriction");
       pAssetIdElementA->SetAttribute("base", "xs:string");
       pAssetIdTypeElement->LinkEndChild(pAssetIdElementA);
-      TiXmlElement* pAssetIdElementB = new TiXmlElement("xs:pattern");
+      tinyxml2::XMLElement* pAssetIdElementB = schemaDocument.NewElement("xs:pattern");
       dSprintf(buffer, sizeof(buffer), "(%s)?\\b[a-zA-Z0-9]+\\b%s\\b[a-zA-Z0-9]+\\b", ASSET_ID_FIELD_PREFIX, ASSET_SCOPE_TOKEN);
       pAssetIdElementB->SetAttribute("value", buffer);
       pAssetIdElementA->LinkEndChild(pAssetIdElementB);
 
       // Color Enums.
-      TiXmlComment* pColorEnumsComment = new TiXmlComment("Color Enums");
+      tinyxml2::XMLComment* pColorEnumsComment = schemaDocument.NewComment("Color Enums");
       pSchemaElement->LinkEndChild(pColorEnumsComment);
-      TiXmlElement* pColorEnumsTypeElement = new TiXmlElement("xs:simpleType");
+      tinyxml2::XMLElement* pColorEnumsTypeElement = schemaDocument.NewElement("xs:simpleType");
       pColorEnumsTypeElement->SetAttribute("name", "Color_Enums");
       pSchemaElement->LinkEndChild(pColorEnumsTypeElement);
-      TiXmlElement* pColorEnumsRestrictionElement = new TiXmlElement("xs:restriction");
+      tinyxml2::XMLElement* pColorEnumsRestrictionElement = schemaDocument.NewElement("xs:restriction");
       pColorEnumsRestrictionElement->SetAttribute("base", "xs:string");
       pColorEnumsTypeElement->LinkEndChild(pColorEnumsRestrictionElement);
       const S32 ColorEnumsCount = StockColor::getCount();
       for (S32 index = 0; index < ColorEnumsCount; ++index)
       {
          // Add enumeration element.
-         TiXmlElement* pColorEnumsAttributeEnumerationElement = new TiXmlElement("xs:enumeration");
+         tinyxml2::XMLElement* pColorEnumsAttributeEnumerationElement = schemaDocument.NewElement("xs:enumeration");
          pColorEnumsAttributeEnumerationElement->SetAttribute("value", StockColor::getColorItem(index)->getColorName());
          pColorEnumsRestrictionElement->LinkEndChild(pColorEnumsAttributeEnumerationElement);
       }
 
       // LinearColorF.
-      TiXmlComment* pColorFValuesComment = new TiXmlComment("LinearColorF Values");
+      tinyxml2::XMLComment* pColorFValuesComment = schemaDocument.NewComment("LinearColorF Values");
       pSchemaElement->LinkEndChild(pColorFValuesComment);
-      TiXmlElement* pColorFValuesTypeElement = new TiXmlElement("xs:simpleType");
+      tinyxml2::XMLElement* pColorFValuesTypeElement = schemaDocument.NewElement("xs:simpleType");
       pColorFValuesTypeElement->SetAttribute("name", "ColorF_Values");
       pSchemaElement->LinkEndChild(pColorFValuesTypeElement);
-      TiXmlElement* pColorFValuesElementA = new TiXmlElement("xs:restriction");
+      tinyxml2::XMLElement* pColorFValuesElementA = schemaDocument.NewElement("xs:restriction");
       pColorFValuesElementA->SetAttribute("base", "xs:string");
       pColorFValuesTypeElement->LinkEndChild(pColorFValuesElementA);
-      TiXmlElement* pColorFValuesElementB = new TiXmlElement("xs:pattern");
+      tinyxml2::XMLElement* pColorFValuesElementB = schemaDocument.NewElement("xs:pattern");
       pColorFValuesElementB->SetAttribute("value", "([-]?(\\b[0-9]+)?\\.)?[0-9]+\\b ([-]?(\\b[0-9]+)?\\.)?[0-9]+\\b ([-]?(\\b[0-9]+)?\\.)?[0-9]+\\b ([-]?(\\b[0-9]+)?\\.)?[0-9]+\\b");
       pColorFValuesElementA->LinkEndChild(pColorFValuesElementB);
 
-      TiXmlComment* pColorFComment = new TiXmlComment("LinearColorF Console Type");
+      tinyxml2::XMLComment* pColorFComment = schemaDocument.NewComment("LinearColorF Console Type");
       pSchemaElement->LinkEndChild(pColorFComment);
-      TiXmlElement* pColorFTypeElement = new TiXmlElement("xs:simpleType");
+      tinyxml2::XMLElement* pColorFTypeElement = schemaDocument.NewElement("xs:simpleType");
       pColorFTypeElement->SetAttribute("name", "ColorF_ConsoleType");
       pSchemaElement->LinkEndChild(pColorFTypeElement);
-      TiXmlElement* pColorFUnionElement = new TiXmlElement("xs:union");
+      tinyxml2::XMLElement* pColorFUnionElement = schemaDocument.NewElement("xs:union");
       pColorFUnionElement->SetAttribute("memberTypes", "ColorF_Values Color_Enums");
       pColorFTypeElement->LinkEndChild(pColorFUnionElement);
 
       // ColorI.
-      TiXmlComment* pColorIValuesComment = new TiXmlComment("ColorI Values");
+      tinyxml2::XMLComment* pColorIValuesComment = schemaDocument.NewComment("ColorI Values");
       pSchemaElement->LinkEndChild(pColorIValuesComment);
-      TiXmlElement* pColorIValuesTypeElement = new TiXmlElement("xs:simpleType");
+      tinyxml2::XMLElement* pColorIValuesTypeElement = schemaDocument.NewElement("xs:simpleType");
       pColorIValuesTypeElement->SetAttribute("name", "ColorI_Values");
       pSchemaElement->LinkEndChild(pColorIValuesTypeElement);
-      TiXmlElement* pColorIValuesElementA = new TiXmlElement("xs:restriction");
+      tinyxml2::XMLElement* pColorIValuesElementA = schemaDocument.NewElement("xs:restriction");
       pColorIValuesElementA->SetAttribute("base", "xs:string");
       pColorIValuesTypeElement->LinkEndChild(pColorIValuesElementA);
-      TiXmlElement* pColorIValuesElementB = new TiXmlElement("xs:pattern");
+      tinyxml2::XMLElement* pColorIValuesElementB = schemaDocument.NewElement("xs:pattern");
       pColorIValuesElementB->SetAttribute("value", "[-]?[0-9]* [-]?[0-9]* [-]?[0-9]* [-]?[0-9]*");
       pColorIValuesElementA->LinkEndChild(pColorIValuesElementB);
 
-      TiXmlComment* pColorIComment = new TiXmlComment("ColorI Console Type");
+      tinyxml2::XMLComment* pColorIComment = schemaDocument.NewComment("ColorI Console Type");
       pSchemaElement->LinkEndChild(pColorIComment);
-      TiXmlElement* pColorITypeElement = new TiXmlElement("xs:simpleType");
+      tinyxml2::XMLElement* pColorITypeElement = schemaDocument.NewElement("xs:simpleType");
       pColorITypeElement->SetAttribute("name", "ColorI_ConsoleType");
       pSchemaElement->LinkEndChild(pColorITypeElement);
-      TiXmlElement* pColorIUnionElement = new TiXmlElement("xs:union");
+      tinyxml2::XMLElement* pColorIUnionElement = schemaDocument.NewElement("xs:union");
       pColorIUnionElement->SetAttribute("memberTypes", "ColorI_Values Color_Enums");
       pColorITypeElement->LinkEndChild(pColorIUnionElement);
 
@@ -1242,12 +1242,12 @@ ImplementEnumType(_TamlFormatMode,
       // *************************************************************
 
       // Generate the engine type elements.
-      TiXmlComment* tComment = new TiXmlComment("Type Elements");
+      tinyxml2::XMLComment* tComment = schemaDocument.NewComment("Type Elements");
       pSchemaElement->LinkEndChild(tComment);
       for (AbstractClassRep* pType = pRootType; pType != NULL; pType = pType->getNextClass())
       {
          // Add type.
-         TiXmlElement* pTypeElement = new TiXmlElement("xs:element");
+         tinyxml2::XMLElement* pTypeElement = schemaDocument.NewElement("xs:element");
          pTypeElement->SetAttribute("name", pType->getClassName());
          dSprintf(buffer, sizeof(buffer), "%s_Type", pType->getClassName());
          pTypeElement->SetAttribute("type", buffer);
@@ -1261,17 +1261,17 @@ ImplementEnumType(_TamlFormatMode,
       {
          // Add complex type comment.
          dSprintf(buffer, sizeof(buffer), " %s Type ", pType->getClassName());
-         TiXmlComment* ctComment = new TiXmlComment(buffer);
+         tinyxml2::XMLComment* ctComment = schemaDocument.NewComment(buffer);
          pSchemaElement->LinkEndChild(ctComment);
 
          // Add complex type.
-         TiXmlElement* pComplexTypeElement = new TiXmlElement("xs:complexType");
+         tinyxml2::XMLElement* pComplexTypeElement = schemaDocument.NewElement("xs:complexType");
          dSprintf(buffer, sizeof(buffer), "%s_Type", pType->getClassName());
          pComplexTypeElement->SetAttribute("name", buffer);
          pSchemaElement->LinkEndChild(pComplexTypeElement);
 
          // Add sequence.
-         TiXmlElement* pSequenceElement = new TiXmlElement("xs:sequence");
+         tinyxml2::XMLElement* pSequenceElement = schemaDocument.NewElement("xs:sequence");
          pComplexTypeElement->LinkEndChild(pSequenceElement);
 
          // Fetch container child class.
@@ -1281,7 +1281,7 @@ ImplementEnumType(_TamlFormatMode,
          if (pContainerChildClass != NULL)
          {
             // Yes, so add choice element.
-            TiXmlElement* pChoiceElement = new TiXmlElement("xs:choice");
+            tinyxml2::XMLElement* pChoiceElement = schemaDocument.NewElement("xs:choice");
             pChoiceElement->SetAttribute("minOccurs", 0);
             pChoiceElement->SetAttribute("maxOccurs", "unbounded");
             pSequenceElement->LinkEndChild(pChoiceElement);
@@ -1299,12 +1299,12 @@ ImplementEnumType(_TamlFormatMode,
                childGroupItr = childGroups.insertUnique(pContainerChildClass, StringTable->insert(buffer));
 
                // Add the group.
-               TiXmlElement* pChildrenGroupElement = new TiXmlElement("xs:group");
+               tinyxml2::XMLElement* pChildrenGroupElement = schemaDocument.NewElement("xs:group");
                pChildrenGroupElement->SetAttribute("name", buffer);
                pSchemaElement->LinkEndChild(pChildrenGroupElement);
 
                // Add choice element.
-               TiXmlElement* pChildreGroupChoiceElement = new TiXmlElement("xs:choice");
+               tinyxml2::XMLElement* pChildreGroupChoiceElement = schemaDocument.NewElement("xs:choice");
                pChildrenGroupElement->LinkEndChild(pChildreGroupChoiceElement);
 
                // Add choice members.
@@ -1315,7 +1315,7 @@ ImplementEnumType(_TamlFormatMode,
                      continue;
 
                   // Add choice member.
-                  TiXmlElement* pChildrenMemberElement = new TiXmlElement("xs:element");
+                  tinyxml2::XMLElement* pChildrenMemberElement = schemaDocument.NewElement("xs:element");
                   pChildrenMemberElement->SetAttribute("name", pChoiceType->getClassName());
                   dSprintf(buffer, sizeof(buffer), "%s_Type", pChoiceType->getClassName());
                   pChildrenMemberElement->SetAttribute("type", buffer);
@@ -1325,7 +1325,7 @@ ImplementEnumType(_TamlFormatMode,
             }
 
             // Reference the child group.
-            TiXmlElement* pChoiceGroupReferenceElement = new TiXmlElement("xs:group");
+            tinyxml2::XMLElement* pChoiceGroupReferenceElement = schemaDocument.NewElement("xs:group");
             pChoiceGroupReferenceElement->SetAttribute("ref", childGroupItr->value);
             pChoiceGroupReferenceElement->SetAttribute("minOccurs", 0);
             pChoiceElement->LinkEndChild(pChoiceGroupReferenceElement);
@@ -1346,7 +1346,7 @@ ImplementEnumType(_TamlFormatMode,
          }
 
          // Generate field attribute group.
-         TiXmlElement* pFieldAttributeGroupElement = new TiXmlElement("xs:attributeGroup");
+         tinyxml2::XMLElement* pFieldAttributeGroupElement = schemaDocument.NewElement("xs:attributeGroup");
          dSprintf(buffer, sizeof(buffer), "%s_Fields", pType->getClassName());
          pFieldAttributeGroupElement->SetAttribute("name", buffer);
          pSchemaElement->LinkEndChild(pFieldAttributeGroupElement);
@@ -1374,7 +1374,7 @@ ImplementEnumType(_TamlFormatMode,
                continue;
 
             // Add attribute element.
-            TiXmlElement* pAttributeElement = new TiXmlElement("xs:attribute");
+            tinyxml2::XMLElement* pAttributeElement = schemaDocument.NewElement("xs:attribute");
             pAttributeElement->SetAttribute("name", field.pFieldname);
 
             // Handle the console type appropriately.
@@ -1385,11 +1385,11 @@ ImplementEnumType(_TamlFormatMode,
             if ( fieldType == TypeEnum )
             {
             // Yes, so add attribute type.
-            TiXmlElement* pAttributeSimpleTypeElement = new TiXmlElement( "xs:simpleType" );
+            tinyxml2::XMLElement* pAttributeSimpleTypeElement = schemaDocument.NewElement( "xs:simpleType" );
             pAttributeElement->LinkEndChild( pAttributeSimpleTypeElement );
 
             // Add restriction element.
-            TiXmlElement* pAttributeRestrictionElement = new TiXmlElement( "xs:restriction" );
+            tinyxml2::XMLElement* pAttributeRestrictionElement = schemaDocument.NewElement( "xs:restriction" );
             pAttributeRestrictionElement->SetAttribute( "base", "xs:string" );
             pAttributeSimpleTypeElement->LinkEndChild( pAttributeRestrictionElement );
 
@@ -1400,7 +1400,7 @@ ImplementEnumType(_TamlFormatMode,
             for( S32 index = 0; index < enumCount; ++index )
             {
             // Add enumeration element.
-            TiXmlElement* pAttributeEnumerationElement = new TiXmlElement( "xs:enumeration" );
+            tinyxml2::XMLElement* pAttributeEnumerationElement = schemaDocument.NewElement( "xs:enumeration" );
             pAttributeEnumerationElement->SetAttribute( "value", field.table->table[index].label );
             pAttributeRestrictionElement->LinkEndChild( pAttributeEnumerationElement );
             }
@@ -1469,19 +1469,19 @@ ImplementEnumType(_TamlFormatMode,
             // Yes, so add reserved Taml field attributes here...
 
             // Add Taml "Name" attribute element.
-            TiXmlElement* pNameAttributeElement = new TiXmlElement("xs:attribute");
+            tinyxml2::XMLElement* pNameAttributeElement = schemaDocument.NewElement("xs:attribute");
             pNameAttributeElement->SetAttribute("name", tamlNamedObjectName);
             pNameAttributeElement->SetAttribute("type", "xs:normalizedString");
             pFieldAttributeGroupElement->LinkEndChild(pNameAttributeElement);
 
             // Add Taml "TamlId" attribute element.
-            TiXmlElement* pTamlIdAttributeElement = new TiXmlElement("xs:attribute");
+            tinyxml2::XMLElement* pTamlIdAttributeElement = schemaDocument.NewElement("xs:attribute");
             pTamlIdAttributeElement->SetAttribute("name", tamlRefIdName);
             pTamlIdAttributeElement->SetAttribute("type", "xs:nonNegativeInteger");
             pFieldAttributeGroupElement->LinkEndChild(pTamlIdAttributeElement);
 
             // Add Taml "TamlRefId" attribute element.
-            TiXmlElement* pTamlRefIdAttributeElement = new TiXmlElement("xs:attribute");
+            tinyxml2::XMLElement* pTamlRefIdAttributeElement = schemaDocument.NewElement("xs:attribute");
             pTamlRefIdAttributeElement->SetAttribute("name", tamlRefToIdName);
             pTamlRefIdAttributeElement->SetAttribute("type", "xs:nonNegativeInteger");
             pFieldAttributeGroupElement->LinkEndChild(pTamlRefIdAttributeElement);
@@ -1490,14 +1490,14 @@ ImplementEnumType(_TamlFormatMode,
          // Add attribute group types.
          for (AbstractClassRep* pAttributeGroupsType = pType; pAttributeGroupsType != NULL; pAttributeGroupsType = pAttributeGroupsType->getParentClass())
          {
-            TiXmlElement* pFieldAttributeGroupRefElement = new TiXmlElement("xs:attributeGroup");
+            tinyxml2::XMLElement* pFieldAttributeGroupRefElement = schemaDocument.NewElement("xs:attributeGroup");
             dSprintf(buffer, sizeof(buffer), "%s_Fields", pAttributeGroupsType->getClassName());
             pFieldAttributeGroupRefElement->SetAttribute("ref", buffer);
             pComplexTypeElement->LinkEndChild(pFieldAttributeGroupRefElement);
          }
 
          // Add "any" attribute element (dynamic fields).
-         TiXmlElement* pAnyAttributeElement = new TiXmlElement("xs:anyAttribute");
+         tinyxml2::XMLElement* pAnyAttributeElement = schemaDocument.NewElement("xs:anyAttribute");
          pAnyAttributeElement->SetAttribute("processContents", "skip");
          pComplexTypeElement->LinkEndChild(pAnyAttributeElement);
       }
@@ -1513,17 +1513,19 @@ ImplementEnumType(_TamlFormatMode,
 
    //-----------------------------------------------------------------------------
 
-   void Taml::WriteUnrestrictedCustomTamlSchema(const char* pCustomNodeName, const AbstractClassRep* pClassRep, TiXmlElement* pParentElement)
+   void Taml::WriteUnrestrictedCustomTamlSchema(const char* pCustomNodeName, const AbstractClassRep* pClassRep, tinyxml2::XMLElement* pParentElement)
    {
       // Sanity!
       AssertFatal(pCustomNodeName != NULL, "Taml::WriteDefaultCustomTamlSchema() - Node name cannot be NULL.");
       AssertFatal(pClassRep != NULL, "Taml::WriteDefaultCustomTamlSchema() - ClassRep cannot be NULL.");
       AssertFatal(pParentElement != NULL, "Taml::WriteDefaultCustomTamlSchema() - Parent Element cannot be NULL.");
 
+      tinyxml2::XMLDocument* doc = pParentElement->GetDocument();
+
       char buffer[1024];
 
       // Add custom type element.
-      TiXmlElement* pCustomElement = new TiXmlElement("xs:element");
+      tinyxml2::XMLElement* pCustomElement = doc->NewElement("xs:element");
       dSprintf(buffer, sizeof(buffer), "%s.%s", pClassRep->getClassName(), pCustomNodeName);
       pCustomElement->SetAttribute("name", buffer);
       pCustomElement->SetAttribute("minOccurs", 0);
@@ -1531,21 +1533,21 @@ ImplementEnumType(_TamlFormatMode,
       pParentElement->LinkEndChild(pCustomElement);
 
       // Add complex type element.
-      TiXmlElement* pComplexTypeElement = new TiXmlElement("xs:complexType");
+      tinyxml2::XMLElement* pComplexTypeElement = doc->NewElement("xs:complexType");
       pCustomElement->LinkEndChild(pComplexTypeElement);
 
       // Add choice element.
-      TiXmlElement* pChoiceElement = new TiXmlElement("xs:choice");
+      tinyxml2::XMLElement* pChoiceElement = doc->NewElement("xs:choice");
       pChoiceElement->SetAttribute("minOccurs", 0);
       pChoiceElement->SetAttribute("maxOccurs", "unbounded");
       pComplexTypeElement->LinkEndChild(pChoiceElement);
 
       // Add sequence element.
-      TiXmlElement* pSequenceElement = new TiXmlElement("xs:sequence");
+      tinyxml2::XMLElement* pSequenceElement = doc->NewElement("xs:sequence");
       pChoiceElement->LinkEndChild(pSequenceElement);
 
       // Add "any" element.
-      TiXmlElement* pAnyElement = new TiXmlElement("xs:any");
+      tinyxml2::XMLElement* pAnyElement = doc->NewElement("xs:any");
       pAnyElement->SetAttribute("processContents", "skip");
       pSequenceElement->LinkEndChild(pAnyElement);
    }

+ 2 - 4
Engine/source/persistence/taml/taml.h

@@ -67,8 +67,6 @@ extern StringTableEntry tamlNamedObjectName;
 #define TAML_SCHEMA_VARIABLE            "$pref::T2D::TAMLSchema"
 #define TAML_JSON_STRICT_VARIBLE        "$pref::T2D::JSONStrict"
 
-class TiXmlElement;
-
 //-----------------------------------------------------------------------------
 
 /// @ingroup tamlGroup
@@ -196,7 +194,7 @@ public:
     static bool generateTamlSchema();
 
     /// Write a unrestricted custom Taml schema.
-    static void WriteUnrestrictedCustomTamlSchema( const char* pCustomNodeName, const AbstractClassRep* pClassRep, TiXmlElement* pParentElement );
+    static void WriteUnrestrictedCustomTamlSchema( const char* pCustomNodeName, const AbstractClassRep* pClassRep, tinyxml2::XMLElement* pParentElement );
 
     /// Get format mode info.
     static TamlFormatMode getFormatModeEnum( const char* label );
@@ -215,4 +213,4 @@ public:
     DECLARE_CONOBJECT( Taml );
 };
 
-#endif // _TAML_H_
+#endif // _TAML_H_

+ 14 - 10
Engine/source/persistence/taml/xml/tamlXmlParser.cpp

@@ -21,17 +21,21 @@
 //-----------------------------------------------------------------------------
 
 #include "persistence/taml/xml/tamlXmlParser.h"
-#include "persistence/taml/fsTinyXml.h"
 #include "persistence/taml/tamlVisitor.h"
 #include "console/console.h"
 
 // Debug Profiling.
+#include "persistence/taml/fsTinyXml.h"
 #include "platform/profiler.h"
 
 #ifndef _FILESTREAM_H_
 #include "core/stream/fileStream.h"
 #endif
 
+#ifndef TINYXML2_INCLUDED
+#include <tinyxml2.h>
+#endif
+
 //-----------------------------------------------------------------------------
 
 bool TamlXmlParser::accept( const char* pFilename, TamlVisitor& visitor )
@@ -68,7 +72,7 @@ bool TamlXmlParser::accept( const char* pFilename, TamlVisitor& visitor )
     
      */
 
-    fsTiXmlDocument xmlDocument;
+    VfsXMLDocument xmlDocument;
 
     // Load document from stream.
     if ( !xmlDocument.LoadFile( filenameBuffer ) )
@@ -88,7 +92,7 @@ bool TamlXmlParser::accept( const char* pFilename, TamlVisitor& visitor )
     mDocumentDirty = false;
 
     // Parse root element.
-    parseElement( (fsTiXmlElement*)xmlDocument.RootElement(), visitor );
+    parseElement( xmlDocument.RootElement(), visitor );
 
     // Reset parsing filename.
     setParsingFilename( StringTable->EmptyString() );
@@ -121,7 +125,7 @@ bool TamlXmlParser::accept( const char* pFilename, TamlVisitor& visitor )
 
 //-----------------------------------------------------------------------------
 
-inline bool TamlXmlParser::parseElement( fsTiXmlElement* pXmlElement, TamlVisitor& visitor )
+inline bool TamlXmlParser::parseElement( tinyxml2::XMLElement* pXmlElement, TamlVisitor& visitor )
 {
     // Debug Profiling.
     PROFILE_SCOPE(TamlXmlParser_ParseElement);
@@ -135,13 +139,13 @@ inline bool TamlXmlParser::parseElement( fsTiXmlElement* pXmlElement, TamlVisito
         return false;
 
     // Fetch any children.
-    TiXmlNode* pChildXmlNode = pXmlElement->FirstChild();
+    tinyxml2::XMLNode* pChildXmlNode = pXmlElement->FirstChild();
 
     // Do we have any element children?
-    if ( pChildXmlNode != NULL && pChildXmlNode->Type() == TiXmlNode::TINYXML_ELEMENT )
+    if ( pChildXmlNode != NULL && pChildXmlNode->ToElement() != NULL )
     {
         // Iterate children.
-        for ( fsTiXmlElement* pChildXmlElement = dynamic_cast<fsTiXmlElement*>( pChildXmlNode ); pChildXmlElement; pChildXmlElement = (fsTiXmlElement*)pChildXmlElement->NextSiblingElement() )
+        for ( tinyxml2::XMLElement* pChildXmlElement = pChildXmlNode->ToElement(); pChildXmlElement; pChildXmlElement = pChildXmlElement->NextSiblingElement() )
         {
             // Parse element (stop processing if instructed).
             if ( !parseElement( pChildXmlElement, visitor ) )
@@ -154,7 +158,7 @@ inline bool TamlXmlParser::parseElement( fsTiXmlElement* pXmlElement, TamlVisito
 
 //-----------------------------------------------------------------------------
 
-inline bool TamlXmlParser::parseAttributes( fsTiXmlElement* pXmlElement, TamlVisitor& visitor )
+inline bool TamlXmlParser::parseAttributes( tinyxml2::XMLElement* pXmlElement, TamlVisitor& visitor )
 {
     // Debug Profiling.
     PROFILE_SCOPE(TamlXmlParser_ParseAttribute);
@@ -167,7 +171,7 @@ inline bool TamlXmlParser::parseAttributes( fsTiXmlElement* pXmlElement, TamlVis
     propertyState.setObjectName( pXmlElement->Value(), isRoot );
 
     // Iterate attributes.
-    for ( TiXmlAttribute* pAttribute = pXmlElement->FirstAttribute(); pAttribute; pAttribute = pAttribute->Next() )
+    for ( const tinyxml2::XMLAttribute* pAttribute = pXmlElement->FirstAttribute(); pAttribute; pAttribute = pAttribute->Next() )
     {
         // Configure property state.
         propertyState.setProperty( pAttribute->Name(), pAttribute->Value() );
@@ -179,7 +183,7 @@ inline bool TamlXmlParser::parseAttributes( fsTiXmlElement* pXmlElement, TamlVis
         if ( propertyState.getPropertyValueDirty() )
         {
             // Yes, so update the attribute.
-            pAttribute->SetValue( propertyState.getPropertyValue() );
+            const_cast<tinyxml2::XMLAttribute*>(pAttribute)->SetAttribute( propertyState.getPropertyValue() );
 
             // Flag the document as dirty.
             mDocumentDirty = true;

+ 6 - 2
Engine/source/persistence/taml/xml/tamlXmlParser.h

@@ -27,6 +27,10 @@
 #include "persistence/taml/tamlParser.h"
 #endif
 
+#ifndef TINYXML2_INCLUDED
+#include <tinyxml2.h>
+#endif
+
 //-----------------------------------------------------------------------------
 class fsTiXmlElement;
 
@@ -45,8 +49,8 @@ public:
     virtual bool accept( const char* pFilename, TamlVisitor& visitor );
 
 private:
-    inline bool parseElement( fsTiXmlElement* pXmlElement, TamlVisitor& visitor );
-    inline bool parseAttributes( fsTiXmlElement* pXmlElement, TamlVisitor& visitor );
+    inline bool parseElement( tinyxml2::XMLElement* pXmlElement, TamlVisitor& visitor );
+    inline bool parseAttributes( tinyxml2::XMLElement* pXmlElement, TamlVisitor& visitor );
 
     bool mDocumentDirty;
 };

+ 23 - 21
Engine/source/persistence/taml/xml/tamlXmlReader.cpp

@@ -24,6 +24,8 @@
 
 // Debug Profiling.
 #include "platform/profiler.h"
+#include <tinyxml2.h>
+
 #include "persistence/taml/fsTinyXml.h"
 
 //-----------------------------------------------------------------------------
@@ -34,10 +36,10 @@ SimObject* TamlXmlReader::read( FileStream& stream )
     PROFILE_SCOPE(TamlXmlReader_Read);
 
     // Create document.
-    fsTiXmlDocument xmlDocument;
+    VfsXMLDocument xmlDocument;
 
     // Load document from stream.
-    if ( !xmlDocument.LoadFile( stream ) )
+    if ( !xmlDocument.LoadFile(stream) )
     {
         // Warn!
         Con::warnf("Taml: Could not load Taml XML file from stream.");
@@ -66,7 +68,7 @@ void TamlXmlReader::resetParse( void )
 
 //-----------------------------------------------------------------------------
 
-SimObject* TamlXmlReader::parseElement( TiXmlElement* pXmlElement )
+SimObject* TamlXmlReader::parseElement( tinyxml2::XMLElement* pXmlElement )
 {
     // Debug Profiling.
     PROFILE_SCOPE(TamlXmlReader_ParseElement);
@@ -103,7 +105,7 @@ SimObject* TamlXmlReader::parseElement( TiXmlElement* pXmlElement )
 #ifdef TORQUE_DEBUG
     // Format the type location.
     char typeLocationBuffer[64];
-    dSprintf( typeLocationBuffer, sizeof(typeLocationBuffer), "Taml [format='xml' row=%d column=%d]", pXmlElement->Row(), pXmlElement->Column() );    
+    dSprintf( typeLocationBuffer, sizeof(typeLocationBuffer), "Taml [format='xml' line=%d]", pXmlElement->GetLineNum() );    
 
     // Create type.
     pSimObject = Taml::createType( typeName, mpTaml, typeLocationBuffer );
@@ -165,7 +167,7 @@ SimObject* TamlXmlReader::parseElement( TiXmlElement* pXmlElement )
     }
 
     // Fetch any children.
-    TiXmlNode* pChildXmlNode = pXmlElement->FirstChild();
+    tinyxml2::XMLNode* pChildXmlNode = pXmlElement->FirstChild();
 
     TamlCustomNodes customProperties;
 
@@ -182,7 +184,7 @@ SimObject* TamlXmlReader::parseElement( TiXmlElement* pXmlElement )
         do
         {
             // Fetch element.
-            TiXmlElement* pChildXmlElement = dynamic_cast<TiXmlElement*>( pChildXmlNode );
+            tinyxml2::XMLElement* pChildXmlElement = pChildXmlNode->ToElement();
 
             // Move to next sibling.
             pChildXmlNode = pChildXmlNode->NextSibling();
@@ -271,7 +273,7 @@ SimObject* TamlXmlReader::parseElement( TiXmlElement* pXmlElement )
 
 //-----------------------------------------------------------------------------
 
-void TamlXmlReader::parseAttributes( TiXmlElement* pXmlElement, SimObject* pSimObject )
+void TamlXmlReader::parseAttributes( tinyxml2::XMLElement* pXmlElement, SimObject* pSimObject )
 {
     // Debug Profiling.
     PROFILE_SCOPE(TamlXmlReader_ParseAttributes);
@@ -280,7 +282,7 @@ void TamlXmlReader::parseAttributes( TiXmlElement* pXmlElement, SimObject* pSimO
     AssertFatal( pSimObject != NULL, "Taml: Cannot parse attributes on a NULL object." );
 
     // Iterate attributes.
-    for ( TiXmlAttribute* pAttribute = pXmlElement->FirstAttribute(); pAttribute; pAttribute = pAttribute->Next() )
+    for ( const tinyxml2::XMLAttribute* pAttribute = pXmlElement->FirstAttribute(); pAttribute; pAttribute = pAttribute->Next() )
     {
         // Insert attribute name.
         StringTableEntry attributeName = StringTable->insert( pAttribute->Name() );
@@ -298,7 +300,7 @@ void TamlXmlReader::parseAttributes( TiXmlElement* pXmlElement, SimObject* pSimO
 
 //-----------------------------------------------------------------------------
 
-void TamlXmlReader::parseCustomElement( TiXmlElement* pXmlElement, TamlCustomNodes& customNodes )
+void TamlXmlReader::parseCustomElement( tinyxml2::XMLElement* pXmlElement, TamlCustomNodes& customNodes )
 {
     // Debug Profiling.
     PROFILE_SCOPE(TamlXmlReader_ParseCustomElement);
@@ -310,7 +312,7 @@ void TamlXmlReader::parseCustomElement( TiXmlElement* pXmlElement, TamlCustomNod
     AssertFatal( pPeriod != NULL, "Parsing extended element but no period character found." );
 
     // Fetch any custom XML node.
-    TiXmlNode* pCustomXmlNode = pXmlElement->FirstChild();
+    tinyxml2::XMLNode* pCustomXmlNode = pXmlElement->FirstChild();
 
     // Finish is no XML node exists.
     if ( pCustomXmlNode == NULL )
@@ -322,7 +324,7 @@ void TamlXmlReader::parseCustomElement( TiXmlElement* pXmlElement, TamlCustomNod
     do
     {
         // Fetch element.
-        TiXmlElement* pCustomXmlElement = dynamic_cast<TiXmlElement*>( pCustomXmlNode );
+        tinyxml2::XMLElement* pCustomXmlElement = pCustomXmlNode->ToElement();
 
         // Move to next sibling.
         pCustomXmlNode = pCustomXmlNode->NextSibling();
@@ -339,7 +341,7 @@ void TamlXmlReader::parseCustomElement( TiXmlElement* pXmlElement, TamlCustomNod
 
 //-----------------------------------------------------------------------------
 
-void TamlXmlReader::parseCustomNode( TiXmlElement* pXmlElement, TamlCustomNode* pCustomNode )
+void TamlXmlReader::parseCustomNode( tinyxml2::XMLElement* pXmlElement, TamlCustomNode* pCustomNode )
 {
     // Is the node a proxy object?
     if (  getTamlRefId( pXmlElement ) != 0 || getTamlRefToId( pXmlElement ) != 0 )
@@ -357,7 +359,7 @@ void TamlXmlReader::parseCustomNode( TiXmlElement* pXmlElement, TamlCustomNode*
     TamlCustomNode* pChildNode = pCustomNode->addNode( pXmlElement->Value() );
 
     // Iterate attributes.
-    for ( TiXmlAttribute* pAttribute = pXmlElement->FirstAttribute(); pAttribute; pAttribute = pAttribute->Next() )
+    for ( const tinyxml2::XMLAttribute* pAttribute = pXmlElement->FirstAttribute(); pAttribute; pAttribute = pAttribute->Next() )
     {
         // Insert attribute name.
         StringTableEntry attributeName = StringTable->insert( pAttribute->Name() );
@@ -381,7 +383,7 @@ void TamlXmlReader::parseCustomNode( TiXmlElement* pXmlElement, TamlCustomNode*
     }
 
     // Fetch any children.
-    TiXmlNode* pChildXmlNode = pXmlElement->FirstChild();
+    tinyxml2::XMLNode* pChildXmlNode = pXmlElement->FirstChild();
 
     // Do we have any element children?
     if ( pChildXmlNode != NULL )
@@ -389,7 +391,7 @@ void TamlXmlReader::parseCustomNode( TiXmlElement* pXmlElement, TamlCustomNode*
         do
         {
             // Yes, so fetch child element.
-            TiXmlElement* pChildXmlElement = dynamic_cast<TiXmlElement*>( pChildXmlNode );
+            tinyxml2::XMLElement* pChildXmlElement = pChildXmlNode->ToElement();
 
             // Move to next sibling.
             pChildXmlNode = pChildXmlNode->NextSibling();
@@ -407,13 +409,13 @@ void TamlXmlReader::parseCustomNode( TiXmlElement* pXmlElement, TamlCustomNode*
 
 //-----------------------------------------------------------------------------
 
-U32 TamlXmlReader::getTamlRefId( TiXmlElement* pXmlElement )
+U32 TamlXmlReader::getTamlRefId( tinyxml2::XMLElement* pXmlElement )
 {
     // Debug Profiling.
     PROFILE_SCOPE(TamlXmlReader_GetTamlRefId);
 
     // Iterate attributes.
-    for ( TiXmlAttribute* pAttribute = pXmlElement->FirstAttribute(); pAttribute; pAttribute = pAttribute->Next() )
+    for ( const tinyxml2::XMLAttribute* pAttribute = pXmlElement->FirstAttribute(); pAttribute; pAttribute = pAttribute->Next() )
     {
         // Insert attribute name.
         StringTableEntry attributeName = StringTable->insert( pAttribute->Name() );
@@ -432,13 +434,13 @@ U32 TamlXmlReader::getTamlRefId( TiXmlElement* pXmlElement )
 
 //-----------------------------------------------------------------------------
 
-U32 TamlXmlReader::getTamlRefToId( TiXmlElement* pXmlElement )
+U32 TamlXmlReader::getTamlRefToId( tinyxml2::XMLElement* pXmlElement )
 {
     // Debug Profiling.
     PROFILE_SCOPE(TamlXmlReader_GetTamlRefToId);
 
     // Iterate attributes.
-    for ( TiXmlAttribute* pAttribute = pXmlElement->FirstAttribute(); pAttribute; pAttribute = pAttribute->Next() )
+    for ( const tinyxml2::XMLAttribute* pAttribute = pXmlElement->FirstAttribute(); pAttribute; pAttribute = pAttribute->Next() )
     {
         // Insert attribute name.
         StringTableEntry attributeName = StringTable->insert( pAttribute->Name() );
@@ -457,13 +459,13 @@ U32 TamlXmlReader::getTamlRefToId( TiXmlElement* pXmlElement )
 
 //-----------------------------------------------------------------------------
 
-const char* TamlXmlReader::getTamlObjectName( TiXmlElement* pXmlElement )
+const char* TamlXmlReader::getTamlObjectName( tinyxml2::XMLElement* pXmlElement )
 {
     // Debug Profiling.
     PROFILE_SCOPE(TamlXmlReader_GetTamlObjectName);
 
     // Iterate attributes.
-    for ( TiXmlAttribute* pAttribute = pXmlElement->FirstAttribute(); pAttribute; pAttribute = pAttribute->Next() )
+    for ( const tinyxml2::XMLAttribute* pAttribute = pXmlElement->FirstAttribute(); pAttribute; pAttribute = pAttribute->Next() )
     {
         // Insert attribute name.
         StringTableEntry attributeName = StringTable->insert( pAttribute->Name() );

+ 8 - 12
Engine/source/persistence/taml/xml/tamlXmlReader.h

@@ -31,10 +31,6 @@
 #include "persistence/taml/taml.h"
 #endif
 
-#ifndef TINYXML_INCLUDED
-#include "tinyXML/tinyxml.h"
-#endif
-
 //-----------------------------------------------------------------------------
 
 /// @ingroup tamlGroup
@@ -60,14 +56,14 @@ private:
 private:
     void resetParse( void );
 
-    SimObject* parseElement( TiXmlElement* pXmlElement );
-    void parseAttributes( TiXmlElement* pXmlElement, SimObject* pSimObject );
-    void parseCustomElement( TiXmlElement* pXmlElement, TamlCustomNodes& pCustomNode );
-    void parseCustomNode( TiXmlElement* pXmlElement, TamlCustomNode* pCustomNode );
+    SimObject* parseElement( tinyxml2::XMLElement* pXmlElement );
+    void parseAttributes( tinyxml2::XMLElement* pXmlElement, SimObject* pSimObject );
+    void parseCustomElement( tinyxml2::XMLElement* pXmlElement, TamlCustomNodes& pCustomNode );
+    void parseCustomNode( tinyxml2::XMLElement* pXmlElement, TamlCustomNode* pCustomNode );
 
-    U32 getTamlRefId( TiXmlElement* pXmlElement );
-    U32 getTamlRefToId( TiXmlElement* pXmlElement );
-    const char* getTamlObjectName( TiXmlElement* pXmlElement );   
+    U32 getTamlRefId( tinyxml2::XMLElement* pXmlElement );
+    U32 getTamlRefToId( tinyxml2::XMLElement* pXmlElement );
+    const char* getTamlObjectName( tinyxml2::XMLElement* pXmlElement );   
 };
 
-#endif // _TAML_XMLREADER_H_
+#endif // _TAML_XMLREADER_H_

+ 16 - 16
Engine/source/persistence/taml/xml/tamlXmlWriter.cpp

@@ -34,10 +34,10 @@ bool TamlXmlWriter::write( FileStream& stream, const TamlWriteNode* pTamlWriteNo
     PROFILE_SCOPE(TamlXmlWriter_Write);
 
     // Create document.
-    fsTiXmlDocument xmlDocument;
+    VfsXMLDocument xmlDocument;
 
     // Compile the root element.
-    TiXmlElement* pRootElement = compileElement( pTamlWriteNode );
+    tinyxml2::XMLElement* pRootElement = compileElement( &xmlDocument, pTamlWriteNode );
 
     // Fetch any TAML Schema file reference.
     const char* pTamlSchemaFile = Con::getVariable( TAML_SCHEMA_VARIABLE );
@@ -77,7 +77,7 @@ bool TamlXmlWriter::write( FileStream& stream, const TamlWriteNode* pTamlWriteNo
 
 //-----------------------------------------------------------------------------
 
-TiXmlElement* TamlXmlWriter::compileElement( const TamlWriteNode* pTamlWriteNode )
+tinyxml2::XMLElement* TamlXmlWriter::compileElement( tinyxml2::XMLDocument* doc, const TamlWriteNode* pTamlWriteNode )
 {
     // Debug Profiling.
     PROFILE_SCOPE(TamlXmlWriter_CompileElement);
@@ -89,7 +89,7 @@ TiXmlElement* TamlXmlWriter::compileElement( const TamlWriteNode* pTamlWriteNode
     const char* pElementName = pSimObject->getClassName();
 
     // Create element.
-    TiXmlElement* pElement = new fsTiXmlElement( pElementName );
+    tinyxml2::XMLElement* pElement = doc->NewElement( pElementName );
 
     // Fetch reference Id.
     const U32 referenceId = pTamlWriteNode->mRefId;
@@ -140,7 +140,7 @@ TiXmlElement* TamlXmlWriter::compileElement( const TamlWriteNode* pTamlWriteNode
         for( Vector<TamlWriteNode*>::iterator itr = pChildren->begin(); itr != pChildren->end(); ++itr )
         {
             // Write child element.
-            pElement->LinkEndChild( compileElement( (*itr) ) );
+            pElement->LinkEndChild( compileElement( doc, (*itr) ) );
         }
     }
 
@@ -152,7 +152,7 @@ TiXmlElement* TamlXmlWriter::compileElement( const TamlWriteNode* pTamlWriteNode
 
 //-----------------------------------------------------------------------------
 
-void TamlXmlWriter::compileAttributes( TiXmlElement* pXmlElement, const TamlWriteNode* pTamlWriteNode )
+void TamlXmlWriter::compileAttributes( tinyxml2::XMLElement* pXmlElement, const TamlWriteNode* pTamlWriteNode )
 {
     // Debug Profiling.
     PROFILE_SCOPE(TamlXmlWriter_CompileAttributes);
@@ -177,7 +177,7 @@ void TamlXmlWriter::compileAttributes( TiXmlElement* pXmlElement, const TamlWrit
 
 //-----------------------------------------------------------------------------
 
-void TamlXmlWriter::compileCustomElements( TiXmlElement* pXmlElement, const TamlWriteNode* pTamlWriteNode )
+void TamlXmlWriter::compileCustomElements( tinyxml2::XMLElement* pXmlElement, const TamlWriteNode* pTamlWriteNode )
 {
     // Debug Profiling.
     PROFILE_SCOPE(TamlXmlWriter_CompileCustomElements);
@@ -189,7 +189,7 @@ void TamlXmlWriter::compileCustomElements( TiXmlElement* pXmlElement, const Taml
     const TamlCustomNodeVector& nodes = customNodes.getNodes();
 
     // Finish if no custom nodes to process.
-    if ( nodes.size() == 0 )
+    if (nodes.empty())
         return;
 
     // Iterate custom nodes.
@@ -204,7 +204,7 @@ void TamlXmlWriter::compileCustomElements( TiXmlElement* pXmlElement, const Taml
         StringTableEntry extendedElementName = StringTable->insert( extendedElementNameBuffer );
 
         // Create element.
-        TiXmlElement* pExtendedPropertyElement = new fsTiXmlElement( extendedElementName );
+        tinyxml2::XMLElement* pExtendedPropertyElement = pXmlElement->GetDocument()->NewElement( extendedElementName );
 
         // Fetch node children.
         const TamlCustomNodeVector& nodeChildren = pCustomNode->getChildren();
@@ -223,7 +223,7 @@ void TamlXmlWriter::compileCustomElements( TiXmlElement* pXmlElement, const Taml
         if ( pCustomNode->getIgnoreEmpty() && pExtendedPropertyElement->NoChildren() )
         {
             // Yes, so delete the extended element.
-            delete pExtendedPropertyElement;
+            pXmlElement->GetDocument()->DeleteNode(pExtendedPropertyElement);
             pExtendedPropertyElement = NULL;
         }
         else
@@ -236,7 +236,7 @@ void TamlXmlWriter::compileCustomElements( TiXmlElement* pXmlElement, const Taml
 
 //-----------------------------------------------------------------------------
 
-void TamlXmlWriter::compileCustomNode( TiXmlElement* pXmlElement, const TamlCustomNode* pCustomNode )
+void TamlXmlWriter::compileCustomNode(tinyxml2::XMLElement* pXmlElement, const TamlCustomNode* pCustomNode )
 {
     // Finish if the node is set to ignore if empty and it is empty.
     if ( pCustomNode->getIgnoreEmpty() && pCustomNode->isEmpty() )
@@ -246,18 +246,18 @@ void TamlXmlWriter::compileCustomNode( TiXmlElement* pXmlElement, const TamlCust
     if ( pCustomNode->isProxyObject() )
     {
         // Yes, so write the proxy object.
-        pXmlElement->LinkEndChild( compileElement( pCustomNode->getProxyWriteNode() ) );
+        pXmlElement->LinkEndChild( compileElement( pXmlElement->GetDocument(), pCustomNode->getProxyWriteNode() ) );
         return;
     }
 
     // Create element.
-    TiXmlElement* pNodeElement = new fsTiXmlElement( pCustomNode->getNodeName() );
+    tinyxml2::XMLElement* pNodeElement = pXmlElement->GetDocument()->NewElement( pCustomNode->getNodeName() );
 
     // Is there any node text?
     if ( !pCustomNode->getNodeTextField().isValueEmpty() )
     {
         // Yes, so add a text node.
-        pNodeElement->LinkEndChild( new TiXmlText( pCustomNode->getNodeTextField().getFieldValue() ) );
+        pNodeElement->LinkEndChild( pXmlElement->GetDocument()->NewText( pCustomNode->getNodeTextField().getFieldValue() ) );
     }
 
     // Fetch fields.
@@ -287,10 +287,10 @@ void TamlXmlWriter::compileCustomNode( TiXmlElement* pXmlElement, const TamlCust
     }
 
     // Finish if the node is set to ignore if empty and it is empty (including fields).
-    if ( pCustomNode->getIgnoreEmpty() && fields.size() == 0 && pNodeElement->NoChildren() )
+    if ( pCustomNode->getIgnoreEmpty() && fields.empty() && pNodeElement->NoChildren() )
     {
         // Yes, so delete the extended element.
-        delete pNodeElement;
+        pXmlElement->GetDocument()->DeleteNode(pNodeElement);
         pNodeElement = NULL;
     }
     else

+ 5 - 9
Engine/source/persistence/taml/xml/tamlXmlWriter.h

@@ -27,10 +27,6 @@
 #include "persistence/taml/taml.h"
 #endif
 
-#ifndef TINYXML_INCLUDED
-#include "tinyXML/tinyxml.h"
-#endif
-
 //-----------------------------------------------------------------------------
 
 /// @ingroup tamlGroup
@@ -50,10 +46,10 @@ private:
     Taml* mpTaml;
 
 private:
-    TiXmlElement* compileElement( const TamlWriteNode* pTamlWriteNode );
-    void compileAttributes( TiXmlElement* pXmlElement, const TamlWriteNode* pTamlWriteNode );
-    void compileCustomElements( TiXmlElement* pXmlElement, const TamlWriteNode* pTamlWriteNode );
-    void compileCustomNode( TiXmlElement* pXmlElement, const TamlCustomNode* pCustomNode );
+    tinyxml2::XMLElement* compileElement( tinyxml2::XMLDocument* doc, const TamlWriteNode* pTamlWriteNode );
+    void compileAttributes( tinyxml2::XMLElement* pXmlElement, const TamlWriteNode* pTamlWriteNode );
+    void compileCustomElements( tinyxml2::XMLElement* pXmlElement, const TamlWriteNode* pTamlWriteNode );
+    void compileCustomNode( tinyxml2::XMLElement* pXmlElement, const TamlCustomNode* pCustomNode );
 };
 
-#endif // _TAML_XMLWRITER_H_
+#endif // _TAML_XMLWRITER_H_

文件差异内容过多而无法显示
+ 203 - 189
Engine/source/ts/collada/colladaUtils.cpp


+ 13 - 13
Engine/source/ts/collada/colladaUtils.h

@@ -43,8 +43,8 @@
 #ifndef _OPTIMIZEDPOLYLIST_H_
 #include "collision/optimizedPolyList.h"
 #endif
-#ifndef TINYXML_INCLUDED
-#include "tinyxml.h"
+#ifndef TINYXML2_INCLUDED
+#include "tinyxml2.h"
 #endif
 #ifndef _CONSOLE_H_
 #include "console/console.h"
@@ -299,17 +299,17 @@ namespace ColladaUtils
 
    // Collada export helper functions
    Torque::Path findTexture(const Torque::Path& diffuseMap);
-   void exportColladaHeader(TiXmlElement* rootNode);
-   void exportColladaMaterials(TiXmlElement* rootNode, const OptimizedPolyList& mesh, Vector<String>& matNames, const Torque::Path& colladaFile);
-   void exportColladaTriangles(TiXmlElement* meshNode, const OptimizedPolyList& mesh, const String& meshName, const Vector<String>& matNames);
-   void exportColladaMesh(TiXmlElement* rootNode, const OptimizedPolyList& mesh, const String& meshName, const Vector<String>& matNames);
-   void exportColladaScene(TiXmlElement* rootNode, const String& meshName, const Vector<String>& matNames);
-
-   void exportColladaMaterials(TiXmlElement* rootNode, const ExportData& exportData, const Torque::Path& colladaFile);
-   void exportColladaMesh(TiXmlElement* rootNode, const ExportData& exportData, const String& meshName);
-   void exportColladaCollisionTriangles(TiXmlElement* meshNode, const ExportData& exportData, const U32 collisionIdx);
-   void exportColladaTriangles(TiXmlElement* meshNode, const ExportData& exportData, const U32 detailLevel, const String& meshName);
-   void exportColladaScene(TiXmlElement* rootNode, const ExportData& exportData, const String& meshName);
+   void exportColladaHeader(tinyxml2::XMLElement* rootNode);
+   void exportColladaMaterials(tinyxml2::XMLElement* rootNode, const OptimizedPolyList& mesh, Vector<String>& matNames, const Torque::Path& colladaFile);
+   void exportColladaTriangles(tinyxml2::XMLElement* meshNode, const OptimizedPolyList& mesh, const String& meshName, const Vector<String>& matNames);
+   void exportColladaMesh(tinyxml2::XMLElement* rootNode, const OptimizedPolyList& mesh, const String& meshName, const Vector<String>& matNames);
+   void exportColladaScene(tinyxml2::XMLElement* rootNode, const String& meshName, const Vector<String>& matNames);
+
+   void exportColladaMaterials(tinyxml2::XMLElement* rootNode, const ExportData& exportData, const Torque::Path& colladaFile);
+   void exportColladaMesh(tinyxml2::XMLElement* rootNode, const ExportData& exportData, const String& meshName);
+   void exportColladaCollisionTriangles(tinyxml2::XMLElement* meshNode, const ExportData& exportData, const U32 collisionIdx);
+   void exportColladaTriangles(tinyxml2::XMLElement* meshNode, const ExportData& exportData, const U32 detailLevel, const String& meshName);
+   void exportColladaScene(tinyxml2::XMLElement* rootNode, const ExportData& exportData, const String& meshName);
 
    // Export an OptimizedPolyList to a simple Collada file
    void exportToCollada(const Torque::Path& colladaFile, const OptimizedPolyList& mesh, const String& meshName = String::EmptyString);

+ 0 - 8
Engine/source/ts/tsShapeConstruct.cpp

@@ -2294,14 +2294,6 @@ void TSShapeConstructor::ChangeSet::write(TSShape* shape, Stream& stream, const
    }
 }
 
-
-TiXmlElement *createNodeWithText( const char* name, const char* text )
-{
-   TiXmlElement* node = new TiXmlElement( name );
-   node->LinkEndChild( new TiXmlText( text ) );
-   return node;
-}
-
 void TSShapeConstructor::ChangeSet::add( TSShapeConstructor::ChangeSet::Command& cmd )
 {
    // Lookup the command type

部分文件因为文件数量过多而无法显示