mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 23:24:41 +00:00
Merge pull request #1588 from marauder2k9-torque/XM-Document-Blind-Traversal
Some checks failed
Linux Build / ${{matrix.config.name}} (map[build_type:Release cc:gcc cxx:g++ generator:Ninja name:Ubuntu Latest GCC]) (push) Has been cancelled
MacOSX Build / ${{matrix.config.name}} (map[build_type:Release cc:clang cxx:clang++ generator:Ninja name:MacOSX Latest Clang]) (push) Has been cancelled
Windows Build / ${{matrix.config.name}} (map[build_type:Release cc:cl cxx:cl environment_script:C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat generator:Visual Studio 17 2022 name:Windows Latest MSVC]) (push) Has been cancelled
Some checks failed
Linux Build / ${{matrix.config.name}} (map[build_type:Release cc:gcc cxx:g++ generator:Ninja name:Ubuntu Latest GCC]) (push) Has been cancelled
MacOSX Build / ${{matrix.config.name}} (map[build_type:Release cc:clang cxx:clang++ generator:Ninja name:MacOSX Latest Clang]) (push) Has been cancelled
Windows Build / ${{matrix.config.name}} (map[build_type:Release cc:cl cxx:cl environment_script:C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat generator:Visual Studio 17 2022 name:Windows Latest MSVC]) (push) Has been cancelled
XML Document Blind element traversal
This commit is contained in:
commit
f2da4ac828
2 changed files with 101 additions and 0 deletions
|
|
@ -1419,4 +1419,99 @@ DefineEngineMethod( SimXMLDocument, getData, const char*, (),,
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SimXMLDocument::prevElement()
|
||||||
|
{
|
||||||
|
m_CurrentAttribute = NULL;
|
||||||
|
|
||||||
|
if (m_paNode.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
S32 idx = m_paNode.size() - 1;
|
||||||
|
tinyxml2::XMLNode*& curr = m_paNode[idx];
|
||||||
|
|
||||||
|
if (!curr)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
tinyxml2::XMLNode* prev = curr->PreviousSiblingElement();
|
||||||
|
|
||||||
|
if (!prev)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
curr = prev;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
DefineEngineMethod(SimXMLDocument, prevElement, const char*, (), ,
|
||||||
|
"@brief Move to previous sibling element regardless of name.\n"
|
||||||
|
"@return The element name, or empty string if none.\n")
|
||||||
|
{
|
||||||
|
if (object->prevElement())
|
||||||
|
return object->elementValue();
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SimXMLDocument::nextElement()
|
||||||
|
{
|
||||||
|
m_CurrentAttribute = NULL;
|
||||||
|
|
||||||
|
if (m_paNode.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
S32 idx = m_paNode.size() - 1;
|
||||||
|
tinyxml2::XMLNode*& curr = m_paNode[idx];
|
||||||
|
|
||||||
|
if (!curr)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
tinyxml2::XMLNode* next = curr->NextSiblingElement();
|
||||||
|
|
||||||
|
if (!next)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
curr = next;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
DefineEngineMethod(SimXMLDocument, nextElement, const char*, (), ,
|
||||||
|
"@brief Move to next sibling element regardless of name.\n"
|
||||||
|
"@return The element name, or empty string if none.\n")
|
||||||
|
{
|
||||||
|
if (object->nextElement())
|
||||||
|
return object->elementValue(); // return the name of the element
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SimXMLDocument::nextChildElement()
|
||||||
|
{
|
||||||
|
m_CurrentAttribute = NULL;
|
||||||
|
|
||||||
|
if (m_paNode.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
tinyxml2::XMLNode* parent = m_paNode.back();
|
||||||
|
if (!parent)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
tinyxml2::XMLElement* firstChild = parent->FirstChildElement();
|
||||||
|
if (!firstChild)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_paNode.push_back(firstChild);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
DefineEngineMethod(SimXMLDocument, nextChildElement, const char*, (),,
|
||||||
|
"@brief Move to the next child element under the same parent.\n"
|
||||||
|
"@return True if a next child exists, false otherwise.")
|
||||||
|
{
|
||||||
|
if (object->nextChildElement())
|
||||||
|
{
|
||||||
|
const char* name = object->elementValue();
|
||||||
|
return name ? name : "";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
////EOF/////////////////////////////////////////////////////////////////////////
|
////EOF/////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,12 @@ class SimXMLDocument: public SimObject
|
||||||
// Retrieve data from the current level.
|
// Retrieve data from the current level.
|
||||||
const char* getData();
|
const char* getData();
|
||||||
|
|
||||||
|
bool prevElement();
|
||||||
|
|
||||||
|
bool nextElement();
|
||||||
|
|
||||||
|
bool nextChildElement();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Document.
|
// Document.
|
||||||
VfsXMLDocument* m_qDocument;
|
VfsXMLDocument* m_qDocument;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue