mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
Updates SimXMLDocument, fsTiXmlDocument, Taml and TamlXmlParser for reading from zip.
This commit is contained in:
parent
8765d3a46e
commit
0ece989560
6 changed files with 67 additions and 68 deletions
|
|
@ -31,6 +31,7 @@
|
||||||
#include "console/consoleInternal.h"
|
#include "console/consoleInternal.h"
|
||||||
#include "console/SimXMLDocument.h"
|
#include "console/SimXMLDocument.h"
|
||||||
#include "console/engineAPI.h"
|
#include "console/engineAPI.h"
|
||||||
|
#include "persistence/taml/fsTinyXml.h"
|
||||||
|
|
||||||
IMPLEMENT_CONOBJECT(SimXMLDocument);
|
IMPLEMENT_CONOBJECT(SimXMLDocument);
|
||||||
|
|
||||||
|
|
@ -175,7 +176,7 @@ bool SimXMLDocument::onAdd()
|
||||||
|
|
||||||
if(!m_qDocument)
|
if(!m_qDocument)
|
||||||
{
|
{
|
||||||
m_qDocument = new TiXmlDocument();
|
m_qDocument = new fsTiXmlDocument();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -345,16 +346,16 @@ bool SimXMLDocument::pushFirstChildElement(const char* rName)
|
||||||
m_CurrentAttribute = 0;
|
m_CurrentAttribute = 0;
|
||||||
|
|
||||||
// Push the first element found under the current element of the given name
|
// Push the first element found under the current element of the given name
|
||||||
TiXmlElement* pElement;
|
fsTiXmlElement* pElement;
|
||||||
if(!m_paNode.empty())
|
if(!m_paNode.empty())
|
||||||
{
|
{
|
||||||
const S32 iLastElement = m_paNode.size() - 1;
|
const S32 iLastElement = m_paNode.size() - 1;
|
||||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||||
if(!pNode)
|
if(!pNode)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pElement = pNode->FirstChildElement(rName);
|
pElement = (fsTiXmlElement*) pNode->FirstChildElement(rName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -362,7 +363,7 @@ bool SimXMLDocument::pushFirstChildElement(const char* rName)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pElement = m_qDocument->FirstChildElement(rName);
|
pElement = (fsTiXmlElement*)m_qDocument->FirstChildElement(rName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!pElement)
|
if(!pElement)
|
||||||
|
|
@ -409,22 +410,22 @@ bool SimXMLDocument::pushChildElement(S32 index)
|
||||||
m_CurrentAttribute = 0;
|
m_CurrentAttribute = 0;
|
||||||
|
|
||||||
// Push the first element found under the current element of the given name
|
// Push the first element found under the current element of the given name
|
||||||
TiXmlElement* pElement;
|
fsTiXmlElement* pElement;
|
||||||
if(!m_paNode.empty())
|
if(!m_paNode.empty())
|
||||||
{
|
{
|
||||||
const S32 iLastElement = m_paNode.size() - 1;
|
const S32 iLastElement = m_paNode.size() - 1;
|
||||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||||
if(!pNode)
|
if(!pNode)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pElement = pNode->FirstChildElement();
|
pElement = (fsTiXmlElement*) pNode->FirstChildElement();
|
||||||
for( S32 i = 0; i < index; i++ )
|
for( S32 i = 0; i < index; i++ )
|
||||||
{
|
{
|
||||||
if( !pElement )
|
if( !pElement )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
pElement = pElement->NextSiblingElement();
|
pElement = (fsTiXmlElement*)pElement->NextSiblingElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -433,13 +434,13 @@ bool SimXMLDocument::pushChildElement(S32 index)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pElement = m_qDocument->FirstChildElement();
|
pElement = (fsTiXmlElement*)m_qDocument->FirstChildElement();
|
||||||
for( S32 i = 0; i < index; i++ )
|
for( S32 i = 0; i < index; i++ )
|
||||||
{
|
{
|
||||||
if( !pElement )
|
if( !pElement )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
pElement = pElement->NextSiblingElement();
|
pElement = (fsTiXmlElement*)pElement->NextSiblingElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -473,13 +474,13 @@ bool SimXMLDocument::nextSiblingElement(const char* rName)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const S32 iLastElement = m_paNode.size() - 1;
|
const S32 iLastElement = m_paNode.size() - 1;
|
||||||
TiXmlElement*& pElement = m_paNode[iLastElement];
|
fsTiXmlElement*& pElement = m_paNode[iLastElement];
|
||||||
if(!pElement)
|
if(!pElement)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pElement = pElement->NextSiblingElement(rName);
|
pElement = (fsTiXmlElement*)pElement->NextSiblingElement(rName);
|
||||||
if(!pElement)
|
if(!pElement)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -507,7 +508,7 @@ const char* SimXMLDocument::elementValue()
|
||||||
return StringTable->EmptyString();
|
return StringTable->EmptyString();
|
||||||
}
|
}
|
||||||
const S32 iLastElement = m_paNode.size() - 1;
|
const S32 iLastElement = m_paNode.size() - 1;
|
||||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||||
if(!pNode)
|
if(!pNode)
|
||||||
{
|
{
|
||||||
return StringTable->EmptyString();
|
return StringTable->EmptyString();
|
||||||
|
|
@ -548,7 +549,7 @@ const char* SimXMLDocument::attribute(const char* rAttribute)
|
||||||
return StringTable->EmptyString();
|
return StringTable->EmptyString();
|
||||||
}
|
}
|
||||||
const S32 iLastElement = m_paNode.size() - 1;
|
const S32 iLastElement = m_paNode.size() - 1;
|
||||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||||
if(!pNode)
|
if(!pNode)
|
||||||
{
|
{
|
||||||
return StringTable->EmptyString();
|
return StringTable->EmptyString();
|
||||||
|
|
@ -599,7 +600,7 @@ bool SimXMLDocument::attributeExists(const char* rAttribute)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const S32 iLastElement = m_paNode.size() - 1;
|
const S32 iLastElement = m_paNode.size() - 1;
|
||||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||||
if(!pNode)
|
if(!pNode)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -632,14 +633,14 @@ const char* SimXMLDocument::firstAttribute()
|
||||||
return StringTable->EmptyString();
|
return StringTable->EmptyString();
|
||||||
}
|
}
|
||||||
const S32 iLastElement = m_paNode.size() - 1;
|
const S32 iLastElement = m_paNode.size() - 1;
|
||||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||||
if(!pNode)
|
if(!pNode)
|
||||||
{
|
{
|
||||||
return StringTable->EmptyString();
|
return StringTable->EmptyString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets its first attribute, if any
|
// Gets its first attribute, if any
|
||||||
m_CurrentAttribute = pNode->FirstAttribute();
|
m_CurrentAttribute = (fsTiXmlAttribute*)pNode->FirstAttribute();
|
||||||
if(!m_CurrentAttribute)
|
if(!m_CurrentAttribute)
|
||||||
{
|
{
|
||||||
return StringTable->EmptyString();
|
return StringTable->EmptyString();
|
||||||
|
|
@ -669,14 +670,14 @@ const char* SimXMLDocument::lastAttribute()
|
||||||
return StringTable->EmptyString();
|
return StringTable->EmptyString();
|
||||||
}
|
}
|
||||||
const S32 iLastElement = m_paNode.size() - 1;
|
const S32 iLastElement = m_paNode.size() - 1;
|
||||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||||
if(!pNode)
|
if(!pNode)
|
||||||
{
|
{
|
||||||
return StringTable->EmptyString();
|
return StringTable->EmptyString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets its last attribute, if any
|
// Gets its last attribute, if any
|
||||||
m_CurrentAttribute = pNode->LastAttribute();
|
m_CurrentAttribute = (fsTiXmlAttribute*)pNode->LastAttribute();
|
||||||
if(!m_CurrentAttribute)
|
if(!m_CurrentAttribute)
|
||||||
{
|
{
|
||||||
return StringTable->EmptyString();
|
return StringTable->EmptyString();
|
||||||
|
|
@ -707,7 +708,7 @@ const char* SimXMLDocument::nextAttribute()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets its next attribute, if any
|
// Gets its next attribute, if any
|
||||||
m_CurrentAttribute = m_CurrentAttribute->Next();
|
m_CurrentAttribute = (fsTiXmlAttribute*)m_CurrentAttribute->Next();
|
||||||
if(!m_CurrentAttribute)
|
if(!m_CurrentAttribute)
|
||||||
{
|
{
|
||||||
return StringTable->EmptyString();
|
return StringTable->EmptyString();
|
||||||
|
|
@ -738,7 +739,7 @@ const char* SimXMLDocument::prevAttribute()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets its next attribute, if any
|
// Gets its next attribute, if any
|
||||||
m_CurrentAttribute = m_CurrentAttribute->Previous();
|
m_CurrentAttribute = (fsTiXmlAttribute*)m_CurrentAttribute->Previous();
|
||||||
if(!m_CurrentAttribute)
|
if(!m_CurrentAttribute)
|
||||||
{
|
{
|
||||||
return StringTable->EmptyString();
|
return StringTable->EmptyString();
|
||||||
|
|
@ -768,7 +769,7 @@ void SimXMLDocument::setAttribute(const char* rAttribute, const char* rVal)
|
||||||
}
|
}
|
||||||
|
|
||||||
const S32 iLastElement = m_paNode.size() - 1;
|
const S32 iLastElement = m_paNode.size() - 1;
|
||||||
TiXmlElement* pElement = m_paNode[iLastElement];
|
fsTiXmlElement* pElement = m_paNode[iLastElement];
|
||||||
if(!pElement)
|
if(!pElement)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
@ -800,13 +801,13 @@ void SimXMLDocument::setObjectAttributes(const char* objectID)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const S32 iLastElement = m_paNode.size() - 1;
|
const S32 iLastElement = m_paNode.size() - 1;
|
||||||
TiXmlElement* pElement = m_paNode[iLastElement];
|
fsTiXmlElement* pElement = m_paNode[iLastElement];
|
||||||
if(!pElement)
|
if(!pElement)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char textbuf[1024];
|
char textbuf[1024];
|
||||||
TiXmlElement field( "Field" );
|
fsTiXmlElement field( "Field" );
|
||||||
TiXmlElement group( "FieldGroup" );
|
fsTiXmlElement group( "FieldGroup" );
|
||||||
pElement->SetAttribute( "Name", pObject->getName() );
|
pElement->SetAttribute( "Name", pObject->getName() );
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -917,22 +918,22 @@ DefineEngineMethod( SimXMLDocument, setObjectAttributes, void, ( const char* obj
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
void SimXMLDocument::pushNewElement(const char* rName)
|
void SimXMLDocument::pushNewElement(const char* rName)
|
||||||
{
|
{
|
||||||
TiXmlElement cElement( rName );
|
fsTiXmlElement cElement( rName );
|
||||||
TiXmlElement* pStackTop = 0;
|
fsTiXmlElement* pStackTop = 0;
|
||||||
if(m_paNode.empty())
|
if(m_paNode.empty())
|
||||||
{
|
{
|
||||||
pStackTop = dynamic_cast<TiXmlElement*>
|
pStackTop = dynamic_cast<fsTiXmlElement*>
|
||||||
(m_qDocument->InsertEndChild( cElement ) );
|
(m_qDocument->InsertEndChild( cElement ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const S32 iFinalElement = m_paNode.size() - 1;
|
const S32 iFinalElement = m_paNode.size() - 1;
|
||||||
TiXmlElement* pNode = m_paNode[iFinalElement];
|
fsTiXmlElement* pNode = m_paNode[iFinalElement];
|
||||||
if(!pNode)
|
if(!pNode)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pStackTop = dynamic_cast<TiXmlElement*>
|
pStackTop = dynamic_cast<fsTiXmlElement*>
|
||||||
(pNode->InsertEndChild( cElement ));
|
(pNode->InsertEndChild( cElement ));
|
||||||
}
|
}
|
||||||
if(!pStackTop)
|
if(!pStackTop)
|
||||||
|
|
@ -962,11 +963,11 @@ DefineEngineMethod( SimXMLDocument, pushNewElement, void, ( const char* name ),,
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
void SimXMLDocument::addNewElement(const char* rName)
|
void SimXMLDocument::addNewElement(const char* rName)
|
||||||
{
|
{
|
||||||
TiXmlElement cElement( rName );
|
fsTiXmlElement cElement( rName );
|
||||||
TiXmlElement* pStackTop = 0;
|
fsTiXmlElement* pStackTop = 0;
|
||||||
if(m_paNode.empty())
|
if(m_paNode.empty())
|
||||||
{
|
{
|
||||||
pStackTop = dynamic_cast<TiXmlElement*>
|
pStackTop = dynamic_cast<fsTiXmlElement*>
|
||||||
(m_qDocument->InsertEndChild( cElement ));
|
(m_qDocument->InsertEndChild( cElement ));
|
||||||
if(!pStackTop)
|
if(!pStackTop)
|
||||||
{
|
{
|
||||||
|
|
@ -979,7 +980,7 @@ void SimXMLDocument::addNewElement(const char* rName)
|
||||||
const S32 iParentElement = m_paNode.size() - 2;
|
const S32 iParentElement = m_paNode.size() - 2;
|
||||||
if(iParentElement < 0)
|
if(iParentElement < 0)
|
||||||
{
|
{
|
||||||
pStackTop = dynamic_cast<TiXmlElement*>
|
pStackTop = dynamic_cast<fsTiXmlElement*>
|
||||||
(m_qDocument->InsertEndChild( cElement ));
|
(m_qDocument->InsertEndChild( cElement ));
|
||||||
if(!pStackTop)
|
if(!pStackTop)
|
||||||
{
|
{
|
||||||
|
|
@ -990,12 +991,12 @@ void SimXMLDocument::addNewElement(const char* rName)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TiXmlElement* pNode = m_paNode[iParentElement];
|
fsTiXmlElement* pNode = m_paNode[iParentElement];
|
||||||
if(!pNode)
|
if(!pNode)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pStackTop = dynamic_cast<TiXmlElement*>
|
pStackTop = dynamic_cast<fsTiXmlElement*>
|
||||||
(pNode->InsertEndChild( cElement ));
|
(pNode->InsertEndChild( cElement ));
|
||||||
if(!pStackTop)
|
if(!pStackTop)
|
||||||
{
|
{
|
||||||
|
|
@ -1029,7 +1030,7 @@ DefineEngineMethod( SimXMLDocument, addNewElement, void, ( const char* name ),,
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
void SimXMLDocument::addHeader(void)
|
void SimXMLDocument::addHeader(void)
|
||||||
{
|
{
|
||||||
TiXmlDeclaration cDeclaration("1.0", "utf-8", "yes");
|
fsTiXmlDeclaration cDeclaration("1.0", "utf-8", "yes");
|
||||||
m_qDocument->InsertEndChild(cDeclaration);
|
m_qDocument->InsertEndChild(cDeclaration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1057,7 +1058,7 @@ DefineEngineMethod( SimXMLDocument, addHeader, void, (),,
|
||||||
|
|
||||||
void SimXMLDocument::addComment(const char* comment)
|
void SimXMLDocument::addComment(const char* comment)
|
||||||
{
|
{
|
||||||
TiXmlComment cComment;
|
fsTiXmlComment cComment;
|
||||||
cComment.SetValue(comment);
|
cComment.SetValue(comment);
|
||||||
m_qDocument->InsertEndChild(cComment);
|
m_qDocument->InsertEndChild(cComment);
|
||||||
}
|
}
|
||||||
|
|
@ -1093,7 +1094,7 @@ const char* SimXMLDocument::readComment( S32 index )
|
||||||
if(!m_paNode.empty())
|
if(!m_paNode.empty())
|
||||||
{
|
{
|
||||||
const S32 iLastElement = m_paNode.size() - 1;
|
const S32 iLastElement = m_paNode.size() - 1;
|
||||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||||
if(!pNode)
|
if(!pNode)
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
|
|
@ -1161,11 +1162,11 @@ void SimXMLDocument::addText(const char* text)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const S32 iFinalElement = m_paNode.size() - 1;
|
const S32 iFinalElement = m_paNode.size() - 1;
|
||||||
TiXmlElement* pNode = m_paNode[iFinalElement];
|
fsTiXmlElement* pNode = m_paNode[iFinalElement];
|
||||||
if(!pNode)
|
if(!pNode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TiXmlText cText(text);
|
fsTiXmlText cText(text);
|
||||||
pNode->InsertEndChild( cText );
|
pNode->InsertEndChild( cText );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1213,7 +1214,7 @@ const char* SimXMLDocument::getText()
|
||||||
if(!pNode->FirstChild())
|
if(!pNode->FirstChild())
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
TiXmlText* text = pNode->FirstChild()->ToText();
|
fsTiXmlText* text = (fsTiXmlText*)pNode->FirstChild()->ToText();
|
||||||
if( !text )
|
if( !text )
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
|
|
@ -1266,14 +1267,14 @@ void SimXMLDocument::removeText()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const S32 iFinalElement = m_paNode.size() - 1;
|
const S32 iFinalElement = m_paNode.size() - 1;
|
||||||
TiXmlElement* pNode = m_paNode[iFinalElement];
|
fsTiXmlElement* pNode = m_paNode[iFinalElement];
|
||||||
if(!pNode)
|
if(!pNode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( !pNode->FirstChild() )
|
if( !pNode->FirstChild() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TiXmlText* text = pNode->FirstChild()->ToText();
|
fsTiXmlText* text = (fsTiXmlText*)pNode->FirstChild()->ToText();
|
||||||
if( !text )
|
if( !text )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -1302,11 +1303,11 @@ void SimXMLDocument::addData(const char* text)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const S32 iFinalElement = m_paNode.size() - 1;
|
const S32 iFinalElement = m_paNode.size() - 1;
|
||||||
TiXmlElement* pNode = m_paNode[iFinalElement];
|
fsTiXmlElement* pNode = m_paNode[iFinalElement];
|
||||||
if(!pNode)
|
if(!pNode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TiXmlText cText(text);
|
fsTiXmlText cText(text);
|
||||||
pNode->InsertEndChild( cText );
|
pNode->InsertEndChild( cText );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,9 +36,9 @@
|
||||||
#endif // _TVECTOR_H_
|
#endif // _TVECTOR_H_
|
||||||
|
|
||||||
|
|
||||||
class TiXmlDocument;
|
class fsTiXmlDocument;
|
||||||
class TiXmlElement;
|
class fsTiXmlElement;
|
||||||
class TiXmlAttribute;
|
class fsTiXmlAttribute;
|
||||||
|
|
||||||
|
|
||||||
class SimXMLDocument: public SimObject
|
class SimXMLDocument: public SimObject
|
||||||
|
|
@ -136,11 +136,11 @@ class SimXMLDocument: public SimObject
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Document.
|
// Document.
|
||||||
TiXmlDocument* m_qDocument;
|
fsTiXmlDocument* m_qDocument;
|
||||||
// Stack of nodes.
|
// Stack of nodes.
|
||||||
Vector<TiXmlElement*> m_paNode;
|
Vector<fsTiXmlElement*> m_paNode;
|
||||||
// The current attribute
|
// The current attribute
|
||||||
TiXmlAttribute* m_CurrentAttribute;
|
fsTiXmlAttribute* m_CurrentAttribute;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DECLARE_CONOBJECT(SimXMLDocument);
|
DECLARE_CONOBJECT(SimXMLDocument);
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ bool fsTiXmlDocument::LoadFile( const char * pFilename, TiXmlEncoding encoding )
|
||||||
{
|
{
|
||||||
// Expand the file-path.
|
// Expand the file-path.
|
||||||
char filenameBuffer[1024];
|
char filenameBuffer[1024];
|
||||||
Con::expandToolScriptFilename( filenameBuffer, sizeof(filenameBuffer), pFilename );
|
Con::expandScriptFilename( filenameBuffer, sizeof(filenameBuffer), pFilename );
|
||||||
|
|
||||||
FileStream stream;
|
FileStream stream;
|
||||||
|
|
||||||
|
|
@ -62,7 +62,7 @@ bool fsTiXmlDocument::SaveFile( const char * pFilename ) const
|
||||||
{
|
{
|
||||||
// Expand the file-name into the file-path buffer.
|
// Expand the file-name into the file-path buffer.
|
||||||
char filenameBuffer[1024];
|
char filenameBuffer[1024];
|
||||||
Con::expandToolScriptFilename( filenameBuffer, sizeof(filenameBuffer), pFilename );
|
Con::expandScriptFilename(filenameBuffer, sizeof(filenameBuffer), pFilename);
|
||||||
|
|
||||||
FileStream stream;
|
FileStream stream;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,7 @@ ImplementEnumType(_TamlFormatMode,
|
||||||
AssertFatal(pFilename != NULL, "Cannot read from a NULL filename.");
|
AssertFatal(pFilename != NULL, "Cannot read from a NULL filename.");
|
||||||
|
|
||||||
// Expand the file-name into the file-path buffer.
|
// Expand the file-name into the file-path buffer.
|
||||||
Con::expandToolScriptFilename(mFilePathBuffer, sizeof(mFilePathBuffer), pFilename);
|
Con::expandScriptFilename(mFilePathBuffer, sizeof(mFilePathBuffer), pFilename);
|
||||||
|
|
||||||
FileStream stream;
|
FileStream stream;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "persistence/taml/xml/tamlXmlParser.h"
|
#include "persistence/taml/xml/tamlXmlParser.h"
|
||||||
|
#include "persistence/taml/fsTinyXml.h"
|
||||||
#include "persistence/taml/tamlVisitor.h"
|
#include "persistence/taml/tamlVisitor.h"
|
||||||
#include "console/console.h"
|
#include "console/console.h"
|
||||||
|
|
||||||
|
|
@ -45,7 +46,7 @@ bool TamlXmlParser::accept( const char* pFilename, TamlVisitor& visitor )
|
||||||
char filenameBuffer[1024];
|
char filenameBuffer[1024];
|
||||||
// TODO: Make sure this is a proper substitute for
|
// TODO: Make sure this is a proper substitute for
|
||||||
// Con::expandPath (T2D)
|
// Con::expandPath (T2D)
|
||||||
Con::expandToolScriptFilename( filenameBuffer, sizeof(filenameBuffer), pFilename );
|
Con::expandScriptFilename( filenameBuffer, sizeof(filenameBuffer), pFilename );
|
||||||
/** T2D uses a custom version of TinyXML that supports FileStream.
|
/** T2D uses a custom version of TinyXML that supports FileStream.
|
||||||
* We don't so we can't do this
|
* We don't so we can't do this
|
||||||
*
|
*
|
||||||
|
|
@ -67,7 +68,7 @@ bool TamlXmlParser::accept( const char* pFilename, TamlVisitor& visitor )
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
TiXmlDocument xmlDocument;
|
fsTiXmlDocument xmlDocument;
|
||||||
|
|
||||||
// Load document from stream.
|
// Load document from stream.
|
||||||
if ( !xmlDocument.LoadFile( filenameBuffer ) )
|
if ( !xmlDocument.LoadFile( filenameBuffer ) )
|
||||||
|
|
@ -87,7 +88,7 @@ bool TamlXmlParser::accept( const char* pFilename, TamlVisitor& visitor )
|
||||||
mDocumentDirty = false;
|
mDocumentDirty = false;
|
||||||
|
|
||||||
// Parse root element.
|
// Parse root element.
|
||||||
parseElement( xmlDocument.RootElement(), visitor );
|
parseElement( (fsTiXmlElement*)xmlDocument.RootElement(), visitor );
|
||||||
|
|
||||||
// Reset parsing filename.
|
// Reset parsing filename.
|
||||||
setParsingFilename( StringTable->EmptyString() );
|
setParsingFilename( StringTable->EmptyString() );
|
||||||
|
|
@ -120,7 +121,7 @@ bool TamlXmlParser::accept( const char* pFilename, TamlVisitor& visitor )
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
inline bool TamlXmlParser::parseElement( TiXmlElement* pXmlElement, TamlVisitor& visitor )
|
inline bool TamlXmlParser::parseElement( fsTiXmlElement* pXmlElement, TamlVisitor& visitor )
|
||||||
{
|
{
|
||||||
// Debug Profiling.
|
// Debug Profiling.
|
||||||
PROFILE_SCOPE(TamlXmlParser_ParseElement);
|
PROFILE_SCOPE(TamlXmlParser_ParseElement);
|
||||||
|
|
@ -140,7 +141,7 @@ inline bool TamlXmlParser::parseElement( TiXmlElement* pXmlElement, TamlVisitor&
|
||||||
if ( pChildXmlNode != NULL && pChildXmlNode->Type() == TiXmlNode::TINYXML_ELEMENT )
|
if ( pChildXmlNode != NULL && pChildXmlNode->Type() == TiXmlNode::TINYXML_ELEMENT )
|
||||||
{
|
{
|
||||||
// Iterate children.
|
// Iterate children.
|
||||||
for ( TiXmlElement* pChildXmlElement = dynamic_cast<TiXmlElement*>( pChildXmlNode ); pChildXmlElement; pChildXmlElement = pChildXmlElement->NextSiblingElement() )
|
for ( fsTiXmlElement* pChildXmlElement = dynamic_cast<fsTiXmlElement*>( pChildXmlNode ); pChildXmlElement; pChildXmlElement = (fsTiXmlElement*)pChildXmlElement->NextSiblingElement() )
|
||||||
{
|
{
|
||||||
// Parse element (stop processing if instructed).
|
// Parse element (stop processing if instructed).
|
||||||
if ( !parseElement( pChildXmlElement, visitor ) )
|
if ( !parseElement( pChildXmlElement, visitor ) )
|
||||||
|
|
@ -153,7 +154,7 @@ inline bool TamlXmlParser::parseElement( TiXmlElement* pXmlElement, TamlVisitor&
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
inline bool TamlXmlParser::parseAttributes( TiXmlElement* pXmlElement, TamlVisitor& visitor )
|
inline bool TamlXmlParser::parseAttributes( fsTiXmlElement* pXmlElement, TamlVisitor& visitor )
|
||||||
{
|
{
|
||||||
// Debug Profiling.
|
// Debug Profiling.
|
||||||
PROFILE_SCOPE(TamlXmlParser_ParseAttribute);
|
PROFILE_SCOPE(TamlXmlParser_ParseAttribute);
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,8 @@
|
||||||
#include "persistence/taml/tamlParser.h"
|
#include "persistence/taml/tamlParser.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TINYXML_INCLUDED
|
|
||||||
#include "tinyxml/tinyxml.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
class fsTiXmlElement;
|
||||||
|
|
||||||
/// @ingroup tamlGroup
|
/// @ingroup tamlGroup
|
||||||
/// @see tamlGroup
|
/// @see tamlGroup
|
||||||
|
|
@ -48,8 +45,8 @@ public:
|
||||||
virtual bool accept( const char* pFilename, TamlVisitor& visitor );
|
virtual bool accept( const char* pFilename, TamlVisitor& visitor );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline bool parseElement( TiXmlElement* pXmlElement, TamlVisitor& visitor );
|
inline bool parseElement( fsTiXmlElement* pXmlElement, TamlVisitor& visitor );
|
||||||
inline bool parseAttributes( TiXmlElement* pXmlElement, TamlVisitor& visitor );
|
inline bool parseAttributes( fsTiXmlElement* pXmlElement, TamlVisitor& visitor );
|
||||||
|
|
||||||
bool mDocumentDirty;
|
bool mDocumentDirty;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue