----------------------------------------------------------------------------- Create a new element and set to child of current stack element. New element is placed on top of element stack. -----------------------------------------------------------------------------
| 980 | // New element is placed on top of element stack. |
| 981 | // ----------------------------------------------------------------------------- |
| 982 | void SimXMLDocument::addNewElement(const char* rName) |
| 983 | { |
| 984 | tinyxml2::XMLElement* cElement = m_qDocument->NewElement(rName); |
| 985 | tinyxml2::XMLNode* pStackTop = 0; |
| 986 | if(m_paNode.empty()) |
| 987 | { |
| 988 | pStackTop = m_qDocument->InsertEndChild( cElement ); |
| 989 | if(!pStackTop) |
| 990 | { |
| 991 | return; |
| 992 | } |
| 993 | m_paNode.push_back(pStackTop); |
| 994 | return; |
| 995 | } |
| 996 | |
| 997 | const S32 iParentElement = m_paNode.size() - 2; |
| 998 | if(iParentElement < 0) |
| 999 | { |
| 1000 | pStackTop = m_qDocument->InsertEndChild( cElement ); |
| 1001 | if(!pStackTop) |
| 1002 | { |
| 1003 | return; |
| 1004 | } |
| 1005 | m_paNode.push_back(pStackTop); |
| 1006 | return; |
| 1007 | } |
| 1008 | else |
| 1009 | { |
| 1010 | tinyxml2::XMLNode* pNode = m_paNode[iParentElement]; |
| 1011 | if(!pNode) |
| 1012 | { |
| 1013 | return; |
| 1014 | } |
| 1015 | pStackTop = pNode->InsertEndChild( cElement ); |
| 1016 | if(!pStackTop) |
| 1017 | { |
| 1018 | return; |
| 1019 | } |
| 1020 | |
| 1021 | // Overwrite top stack position. |
| 1022 | const S32 iFinalElement = m_paNode.size() - 1; |
| 1023 | m_paNode[iFinalElement] = pStackTop; |
| 1024 | //pNode = pStackTop; |
| 1025 | } |
| 1026 | } |
| 1027 | |
| 1028 | DefineEngineMethod( SimXMLDocument, addNewElement, void, ( const char* name ),, |
| 1029 | "@brief Create a new element with the given name as child of current Element's " |
no test coverage detected