mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-20 20:05:33 +00:00
Update usage of TinyXML to use TinyXML2
This commit is contained in:
parent
cd170910b2
commit
9a795e89f3
23 changed files with 865 additions and 1447 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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() );
|
||||
|
|
|
|||
|
|
@ -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_
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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_
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue