From 9a795e89f3eb14b483dba46115bd166aca1e6fc7 Mon Sep 17 00:00:00 2001 From: Lukas Aldershaab Date: Sat, 31 Jul 2021 21:54:19 +0200 Subject: [PATCH] Update usage of TinyXML to use TinyXML2 --- .../collada/include/dae/daeTinyXMLPlugin.h | 11 +- .../lib/collada/src/dae/daeTinyXMLPlugin.cpp | 28 +- .../Verve/Core/Persistence/VPersistence.cpp | 12 +- .../Verve/Core/Persistence/VPersistence.h | 37 +- Engine/source/Verve/Core/VController.cpp | 14 +- Engine/source/Verve/Core/VController.h | 6 +- Engine/source/Verve/Core/VObject.h | 6 +- Engine/source/console/SimXMLDocument.cpp | 155 ++-- Engine/source/console/SimXMLDocument.h | 15 +- Engine/source/console/consoleObject.h | 4 +- Engine/source/persistence/taml/fsTinyXml.cpp | 710 +++-------------- Engine/source/persistence/taml/fsTinyXml.h | 260 ++----- Engine/source/persistence/taml/taml.cpp | 152 ++-- Engine/source/persistence/taml/taml.h | 6 +- .../persistence/taml/xml/tamlXmlParser.cpp | 24 +- .../persistence/taml/xml/tamlXmlParser.h | 8 +- .../persistence/taml/xml/tamlXmlReader.cpp | 44 +- .../persistence/taml/xml/tamlXmlReader.h | 20 +- .../persistence/taml/xml/tamlXmlWriter.cpp | 32 +- .../persistence/taml/xml/tamlXmlWriter.h | 14 +- Engine/source/ts/collada/colladaUtils.cpp | 722 +++++++++--------- Engine/source/ts/collada/colladaUtils.h | 24 +- Engine/source/ts/tsShapeConstruct.cpp | 8 - 23 files changed, 865 insertions(+), 1447 deletions(-) diff --git a/Engine/lib/collada/include/dae/daeTinyXMLPlugin.h b/Engine/lib/collada/include/dae/daeTinyXMLPlugin.h index 06b55dbe7..a8ac56007 100644 --- a/Engine/lib/collada/include/dae/daeTinyXMLPlugin.h +++ b/Engine/lib/collada/include/dae/daeTinyXMLPlugin.h @@ -20,8 +20,9 @@ #include #include -class TiXmlDocument; -class TiXmlElement; +#ifndef TINYXML2_INCLUDED +#include +#endif class daeTinyXMLPlugin : public daeIOPluginCommon { @@ -60,12 +61,12 @@ public: virtual DLLSPEC daeString getOption( daeString option ); private: - TiXmlDocument* m_doc; - std::list m_elements; + tinyxml2::XMLDocument* m_doc; + std::list 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 ); diff --git a/Engine/lib/collada/src/dae/daeTinyXMLPlugin.cpp b/Engine/lib/collada/src/dae/daeTinyXMLPlugin.cpp index c8bd37a8b..164a4a18f 100644 --- a/Engine/lib/collada/src/dae/daeTinyXMLPlugin.cpp +++ b/Engine/lib/collada/src/dae/daeTinyXMLPlugin.cpp @@ -24,7 +24,7 @@ #endif #include -#include +#include #include #include #include @@ -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 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()) ); } } diff --git a/Engine/source/Verve/Core/Persistence/VPersistence.cpp b/Engine/source/Verve/Core/Persistence/VPersistence.cpp index daf3336a9..1d1dee6d1 100644 --- a/Engine/source/Verve/Core/Persistence/VPersistence.cpp +++ b/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; } -} \ No newline at end of file +} diff --git a/Engine/source/Verve/Core/Persistence/VPersistence.h b/Engine/source/Verve/Core/Persistence/VPersistence.h index b65b49ed4..edbc892c8 100644 --- a/Engine/source/Verve/Core/Persistence/VPersistence.h +++ b/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 bool write( TiXmlElement *pElement, T *pObject ); + template bool write( tinyxml2::XMLElement *pElement, T *pObject ); template 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 bool writeProperties( TiXmlElement *pElement, T *pObject ) + template 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 bool writeObjects( TiXmlElement *pElement, T *pObject ) + template bool writeObjects( tinyxml2::XMLElement *pElement, T *pObject ) { for ( ITreeNode *node = pObject->mChildNode; node != NULL; node = node->mSiblingNextNode ) { @@ -143,18 +144,18 @@ namespace VPersistence //------------------------------------------------------------------------- - template bool read( TiXmlElement *pElement, T *pObject ); + template bool read( tinyxml2::XMLElement *pElement, T *pObject ); template 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 bool readProperties( TiXmlElement *pElement, T *pObject ) + template 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 bool readObjects( TiXmlElement *pElement, T *pObject ) + template 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" ); diff --git a/Engine/source/Verve/Core/VController.cpp b/Engine/source/Verve/Core/VController.cpp index ff16fad16..abb84fbb9 100644 --- a/Engine/source/Verve/Core/VController.cpp +++ b/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" ); diff --git a/Engine/source/Verve/Core/VController.h b/Engine/source/Verve/Core/VController.h index f38a1cdf0..d6996c8ef 100644 --- a/Engine/source/Verve/Core/VController.h +++ b/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_ \ No newline at end of file +#endif // _VT_VCONTROLLER_H_ diff --git a/Engine/source/Verve/Core/VObject.h b/Engine/source/Verve/Core/VObject.h index a4fe22f18..f42b5cae7 100644 --- a/Engine/source/Verve/Core/VObject.h +++ b/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_ \ No newline at end of file +#endif // _VT_VOBJECT_H_ diff --git a/Engine/source/console/SimXMLDocument.cpp b/Engine/source/console/SimXMLDocument.cpp index 3e0259bfe..5c1f8feef 100644 --- a/Engine/source/console/SimXMLDocument.cpp +++ b/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 - (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 - (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 - (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 - (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 - (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 ""; diff --git a/Engine/source/console/SimXMLDocument.h b/Engine/source/console/SimXMLDocument.h index fcc0274dc..3ba32bb9b 100644 --- a/Engine/source/console/SimXMLDocument.h +++ b/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 +#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 m_paNode; + Vector m_paNode; // The current attribute - fsTiXmlAttribute* m_CurrentAttribute; + const tinyxml2::XMLAttribute* m_CurrentAttribute; public: DECLARE_CONOBJECT(SimXMLDocument); diff --git a/Engine/source/console/consoleObject.h b/Engine/source/console/consoleObject.h index 784e294ff..beaf94235 100644 --- a/Engine/source/console/consoleObject.h +++ b/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 /// @{ diff --git a/Engine/source/persistence/taml/fsTinyXml.cpp b/Engine/source/persistence/taml/fsTinyXml.cpp index a43eb1345..e0dc53572 100644 --- a/Engine/source/persistence/taml/fsTinyXml.cpp +++ b/Engine/source/persistence/taml/fsTinyXml.cpp @@ -21,13 +21,16 @@ //----------------------------------------------------------------------------- #include "fsTinyXml.h" + +#include + #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(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 +bool VfsXMLDocument::SaveFile(FileStream& stream) { - 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; + // 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(); } - -void fsTiXmlDocument::Print( FileStream& stream, int depth ) const -{ - for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) - { - //AttemptPrintTiNode(const_cast(node), stream, depth); - dynamic_cast(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( "" ); - if ( str ) (*str) += "?>"; -} - -void fsTiXmlElement::Print(FileStream& stream, int depth) const -{ - int i; - for ( i=0; iNext() ) - { - stream.writeStringBuffer( "\n" ); - dynamic_cast(attrib)->Print( stream, depth+1 ); - } - - // There are 3 different formatting approaches: - // 1) An element without children is printed as a node - // 2) An element with only a text child is printed as text - // 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(firstChild)->Print( stream, depth + 1 ); - stream.writeFormattedBuffer( "", value.c_str() ); - } - else - { - stream.writeStringBuffer( ">" ); - - for ( node = firstChild; node; node=node->NextSibling() ) - { - if ( !node->ToText() ) - { - stream.writeStringBuffer( "\n" ); - } - dynamic_cast(node)->Print( stream, depth+1 ); - } - stream.writeStringBuffer( "\n" ); - for( i=0; i", value.c_str() ); - } -} - -void fsTiXmlComment::Print(FileStream& stream, int depth) const -{ - for ( int i=0; i", value.c_str() ); -} - -void fsTiXmlText::Print(FileStream& stream, int depth) const -{ - if ( cdata ) - { - int i; - stream.writeStringBuffer( "\n" ); - for ( i=0; i\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", 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: