mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +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/SimXMLDocument.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "persistence/taml/fsTinyXml.h"
|
||||
|
||||
IMPLEMENT_CONOBJECT(SimXMLDocument);
|
||||
|
||||
|
|
@ -175,7 +176,7 @@ bool SimXMLDocument::onAdd()
|
|||
|
||||
if(!m_qDocument)
|
||||
{
|
||||
m_qDocument = new TiXmlDocument();
|
||||
m_qDocument = new fsTiXmlDocument();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -345,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
|
||||
TiXmlElement* pElement;
|
||||
fsTiXmlElement* pElement;
|
||||
if(!m_paNode.empty())
|
||||
{
|
||||
const S32 iLastElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||
if(!pNode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
pElement = pNode->FirstChildElement(rName);
|
||||
pElement = (fsTiXmlElement*) pNode->FirstChildElement(rName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -362,7 +363,7 @@ bool SimXMLDocument::pushFirstChildElement(const char* rName)
|
|||
{
|
||||
return false;
|
||||
}
|
||||
pElement = m_qDocument->FirstChildElement(rName);
|
||||
pElement = (fsTiXmlElement*)m_qDocument->FirstChildElement(rName);
|
||||
}
|
||||
|
||||
if(!pElement)
|
||||
|
|
@ -409,22 +410,22 @@ bool SimXMLDocument::pushChildElement(S32 index)
|
|||
m_CurrentAttribute = 0;
|
||||
|
||||
// Push the first element found under the current element of the given name
|
||||
TiXmlElement* pElement;
|
||||
fsTiXmlElement* pElement;
|
||||
if(!m_paNode.empty())
|
||||
{
|
||||
const S32 iLastElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||
if(!pNode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
pElement = pNode->FirstChildElement();
|
||||
pElement = (fsTiXmlElement*) pNode->FirstChildElement();
|
||||
for( S32 i = 0; i < index; i++ )
|
||||
{
|
||||
if( !pElement )
|
||||
return false;
|
||||
|
||||
pElement = pElement->NextSiblingElement();
|
||||
pElement = (fsTiXmlElement*)pElement->NextSiblingElement();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -433,13 +434,13 @@ bool SimXMLDocument::pushChildElement(S32 index)
|
|||
{
|
||||
return false;
|
||||
}
|
||||
pElement = m_qDocument->FirstChildElement();
|
||||
pElement = (fsTiXmlElement*)m_qDocument->FirstChildElement();
|
||||
for( S32 i = 0; i < index; i++ )
|
||||
{
|
||||
if( !pElement )
|
||||
return false;
|
||||
|
||||
pElement = pElement->NextSiblingElement();
|
||||
pElement = (fsTiXmlElement*)pElement->NextSiblingElement();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -473,13 +474,13 @@ bool SimXMLDocument::nextSiblingElement(const char* rName)
|
|||
return false;
|
||||
}
|
||||
const S32 iLastElement = m_paNode.size() - 1;
|
||||
TiXmlElement*& pElement = m_paNode[iLastElement];
|
||||
fsTiXmlElement*& pElement = m_paNode[iLastElement];
|
||||
if(!pElement)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
pElement = pElement->NextSiblingElement(rName);
|
||||
pElement = (fsTiXmlElement*)pElement->NextSiblingElement(rName);
|
||||
if(!pElement)
|
||||
{
|
||||
return false;
|
||||
|
|
@ -507,7 +508,7 @@ const char* SimXMLDocument::elementValue()
|
|||
return StringTable->EmptyString();
|
||||
}
|
||||
const S32 iLastElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||
if(!pNode)
|
||||
{
|
||||
return StringTable->EmptyString();
|
||||
|
|
@ -548,7 +549,7 @@ const char* SimXMLDocument::attribute(const char* rAttribute)
|
|||
return StringTable->EmptyString();
|
||||
}
|
||||
const S32 iLastElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||
if(!pNode)
|
||||
{
|
||||
return StringTable->EmptyString();
|
||||
|
|
@ -599,7 +600,7 @@ bool SimXMLDocument::attributeExists(const char* rAttribute)
|
|||
return false;
|
||||
}
|
||||
const S32 iLastElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||
if(!pNode)
|
||||
{
|
||||
return false;
|
||||
|
|
@ -632,14 +633,14 @@ const char* SimXMLDocument::firstAttribute()
|
|||
return StringTable->EmptyString();
|
||||
}
|
||||
const S32 iLastElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||
if(!pNode)
|
||||
{
|
||||
return StringTable->EmptyString();
|
||||
}
|
||||
|
||||
// Gets its first attribute, if any
|
||||
m_CurrentAttribute = pNode->FirstAttribute();
|
||||
m_CurrentAttribute = (fsTiXmlAttribute*)pNode->FirstAttribute();
|
||||
if(!m_CurrentAttribute)
|
||||
{
|
||||
return StringTable->EmptyString();
|
||||
|
|
@ -669,14 +670,14 @@ const char* SimXMLDocument::lastAttribute()
|
|||
return StringTable->EmptyString();
|
||||
}
|
||||
const S32 iLastElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||
if(!pNode)
|
||||
{
|
||||
return StringTable->EmptyString();
|
||||
}
|
||||
|
||||
// Gets its last attribute, if any
|
||||
m_CurrentAttribute = pNode->LastAttribute();
|
||||
m_CurrentAttribute = (fsTiXmlAttribute*)pNode->LastAttribute();
|
||||
if(!m_CurrentAttribute)
|
||||
{
|
||||
return StringTable->EmptyString();
|
||||
|
|
@ -707,7 +708,7 @@ const char* SimXMLDocument::nextAttribute()
|
|||
}
|
||||
|
||||
// Gets its next attribute, if any
|
||||
m_CurrentAttribute = m_CurrentAttribute->Next();
|
||||
m_CurrentAttribute = (fsTiXmlAttribute*)m_CurrentAttribute->Next();
|
||||
if(!m_CurrentAttribute)
|
||||
{
|
||||
return StringTable->EmptyString();
|
||||
|
|
@ -738,7 +739,7 @@ const char* SimXMLDocument::prevAttribute()
|
|||
}
|
||||
|
||||
// Gets its next attribute, if any
|
||||
m_CurrentAttribute = m_CurrentAttribute->Previous();
|
||||
m_CurrentAttribute = (fsTiXmlAttribute*)m_CurrentAttribute->Previous();
|
||||
if(!m_CurrentAttribute)
|
||||
{
|
||||
return StringTable->EmptyString();
|
||||
|
|
@ -768,7 +769,7 @@ void SimXMLDocument::setAttribute(const char* rAttribute, const char* rVal)
|
|||
}
|
||||
|
||||
const S32 iLastElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pElement = m_paNode[iLastElement];
|
||||
fsTiXmlElement* pElement = m_paNode[iLastElement];
|
||||
if(!pElement)
|
||||
{
|
||||
return;
|
||||
|
|
@ -800,13 +801,13 @@ void SimXMLDocument::setObjectAttributes(const char* objectID)
|
|||
return;
|
||||
|
||||
const S32 iLastElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pElement = m_paNode[iLastElement];
|
||||
fsTiXmlElement* pElement = m_paNode[iLastElement];
|
||||
if(!pElement)
|
||||
return;
|
||||
|
||||
char textbuf[1024];
|
||||
TiXmlElement field( "Field" );
|
||||
TiXmlElement group( "FieldGroup" );
|
||||
fsTiXmlElement field( "Field" );
|
||||
fsTiXmlElement group( "FieldGroup" );
|
||||
pElement->SetAttribute( "Name", pObject->getName() );
|
||||
|
||||
|
||||
|
|
@ -917,22 +918,22 @@ DefineEngineMethod( SimXMLDocument, setObjectAttributes, void, ( const char* obj
|
|||
// -----------------------------------------------------------------------------
|
||||
void SimXMLDocument::pushNewElement(const char* rName)
|
||||
{
|
||||
TiXmlElement cElement( rName );
|
||||
TiXmlElement* pStackTop = 0;
|
||||
fsTiXmlElement cElement( rName );
|
||||
fsTiXmlElement* pStackTop = 0;
|
||||
if(m_paNode.empty())
|
||||
{
|
||||
pStackTop = dynamic_cast<TiXmlElement*>
|
||||
pStackTop = dynamic_cast<fsTiXmlElement*>
|
||||
(m_qDocument->InsertEndChild( cElement ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
const S32 iFinalElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iFinalElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iFinalElement];
|
||||
if(!pNode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pStackTop = dynamic_cast<TiXmlElement*>
|
||||
pStackTop = dynamic_cast<fsTiXmlElement*>
|
||||
(pNode->InsertEndChild( cElement ));
|
||||
}
|
||||
if(!pStackTop)
|
||||
|
|
@ -962,11 +963,11 @@ DefineEngineMethod( SimXMLDocument, pushNewElement, void, ( const char* name ),,
|
|||
// -----------------------------------------------------------------------------
|
||||
void SimXMLDocument::addNewElement(const char* rName)
|
||||
{
|
||||
TiXmlElement cElement( rName );
|
||||
TiXmlElement* pStackTop = 0;
|
||||
fsTiXmlElement cElement( rName );
|
||||
fsTiXmlElement* pStackTop = 0;
|
||||
if(m_paNode.empty())
|
||||
{
|
||||
pStackTop = dynamic_cast<TiXmlElement*>
|
||||
pStackTop = dynamic_cast<fsTiXmlElement*>
|
||||
(m_qDocument->InsertEndChild( cElement ));
|
||||
if(!pStackTop)
|
||||
{
|
||||
|
|
@ -979,7 +980,7 @@ void SimXMLDocument::addNewElement(const char* rName)
|
|||
const S32 iParentElement = m_paNode.size() - 2;
|
||||
if(iParentElement < 0)
|
||||
{
|
||||
pStackTop = dynamic_cast<TiXmlElement*>
|
||||
pStackTop = dynamic_cast<fsTiXmlElement*>
|
||||
(m_qDocument->InsertEndChild( cElement ));
|
||||
if(!pStackTop)
|
||||
{
|
||||
|
|
@ -990,12 +991,12 @@ void SimXMLDocument::addNewElement(const char* rName)
|
|||
}
|
||||
else
|
||||
{
|
||||
TiXmlElement* pNode = m_paNode[iParentElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iParentElement];
|
||||
if(!pNode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pStackTop = dynamic_cast<TiXmlElement*>
|
||||
pStackTop = dynamic_cast<fsTiXmlElement*>
|
||||
(pNode->InsertEndChild( cElement ));
|
||||
if(!pStackTop)
|
||||
{
|
||||
|
|
@ -1029,7 +1030,7 @@ DefineEngineMethod( SimXMLDocument, addNewElement, void, ( const char* name ),,
|
|||
// -----------------------------------------------------------------------------
|
||||
void SimXMLDocument::addHeader(void)
|
||||
{
|
||||
TiXmlDeclaration cDeclaration("1.0", "utf-8", "yes");
|
||||
fsTiXmlDeclaration cDeclaration("1.0", "utf-8", "yes");
|
||||
m_qDocument->InsertEndChild(cDeclaration);
|
||||
}
|
||||
|
||||
|
|
@ -1057,7 +1058,7 @@ DefineEngineMethod( SimXMLDocument, addHeader, void, (),,
|
|||
|
||||
void SimXMLDocument::addComment(const char* comment)
|
||||
{
|
||||
TiXmlComment cComment;
|
||||
fsTiXmlComment cComment;
|
||||
cComment.SetValue(comment);
|
||||
m_qDocument->InsertEndChild(cComment);
|
||||
}
|
||||
|
|
@ -1093,7 +1094,7 @@ const char* SimXMLDocument::readComment( S32 index )
|
|||
if(!m_paNode.empty())
|
||||
{
|
||||
const S32 iLastElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||
if(!pNode)
|
||||
{
|
||||
return "";
|
||||
|
|
@ -1161,11 +1162,11 @@ void SimXMLDocument::addText(const char* text)
|
|||
return;
|
||||
|
||||
const S32 iFinalElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iFinalElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iFinalElement];
|
||||
if(!pNode)
|
||||
return;
|
||||
|
||||
TiXmlText cText(text);
|
||||
fsTiXmlText cText(text);
|
||||
pNode->InsertEndChild( cText );
|
||||
}
|
||||
|
||||
|
|
@ -1213,7 +1214,7 @@ const char* SimXMLDocument::getText()
|
|||
if(!pNode->FirstChild())
|
||||
return "";
|
||||
|
||||
TiXmlText* text = pNode->FirstChild()->ToText();
|
||||
fsTiXmlText* text = (fsTiXmlText*)pNode->FirstChild()->ToText();
|
||||
if( !text )
|
||||
return "";
|
||||
|
||||
|
|
@ -1266,14 +1267,14 @@ void SimXMLDocument::removeText()
|
|||
return;
|
||||
|
||||
const S32 iFinalElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iFinalElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iFinalElement];
|
||||
if(!pNode)
|
||||
return;
|
||||
|
||||
if( !pNode->FirstChild() )
|
||||
return;
|
||||
|
||||
TiXmlText* text = pNode->FirstChild()->ToText();
|
||||
fsTiXmlText* text = (fsTiXmlText*)pNode->FirstChild()->ToText();
|
||||
if( !text )
|
||||
return;
|
||||
|
||||
|
|
@ -1302,11 +1303,11 @@ void SimXMLDocument::addData(const char* text)
|
|||
return;
|
||||
|
||||
const S32 iFinalElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iFinalElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iFinalElement];
|
||||
if(!pNode)
|
||||
return;
|
||||
|
||||
TiXmlText cText(text);
|
||||
fsTiXmlText cText(text);
|
||||
pNode->InsertEndChild( cText );
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue