MCPcopy Create free account
hub / github.com/ajkhoury/ReClassEx / ParseDeep

Method ParseDeep

ReClass/tinyxml2.cpp:989–1087  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

987
988
989char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr )
990{
991 // This is a recursive method, but thinking about it "at the current level"
992 // it is a pretty simple flat list:
993 // <foo/>
994 // <!-- comment -->
995 //
996 // With a special case:
997 // <foo>
998 // </foo>
999 // <!-- comment -->
1000 //
1001 // Where the closing element (/foo) *must* be the next thing after the opening
1002 // element, and the names must match. BUT the tricky bit is that the closing
1003 // element will be read by the child.
1004 //
1005 // 'endTag' is the end tag for this node, it is returned by a call to a child.
1006 // 'parentEnd' is the end tag for the parent, which is filled in and returned.
1007
1008 while( p && *p ) {
1009 XMLNode* node = 0;
1010
1011 p = _document->Identify( p, &node );
1012 TIXMLASSERT( p );
1013 if ( node == 0 ) {
1014 break;
1015 }
1016
1017 int initialLineNum = node->_parseLineNum;
1018
1019 StrPair endTag;
1020 p = node->ParseDeep( p, &endTag, curLineNumPtr );
1021 if ( !p ) {
1022 DeleteNode( node );
1023 if ( !_document->Error() ) {
1024 _document->SetError( XML_ERROR_PARSING, 0, 0, initialLineNum);
1025 }
1026 break;
1027 }
1028
1029 XMLDeclaration* decl = node->ToDeclaration();
1030 if ( decl ) {
1031 // Declarations are only allowed at document level
1032 bool wellLocated = ( ToDocument() != 0 );
1033 if ( wellLocated ) {
1034 // Multiple declarations are allowed but all declarations
1035 // must occur before anything else
1036 for ( const XMLNode* existingNode = _document->FirstChild(); existingNode; existingNode = existingNode->NextSibling() ) {
1037 if ( !existingNode->ToDeclaration() ) {
1038 wellLocated = false;
1039 break;
1040 }
1041 }
1042 }
1043 if ( !wellLocated ) {
1044 _document->SetError( XML_ERROR_PARSING_DECLARATION, decl->Value(), 0, initialLineNum);
1045 DeleteNode( node );
1046 break;

Callers 1

ParseAttributesMethod · 0.80

Calls 13

ToDocumentFunction · 0.85
StringEqualFunction · 0.85
SkipWhiteSpaceFunction · 0.85
IdentifyMethod · 0.80
SetErrorMethod · 0.80
ValueMethod · 0.80
TransferToMethod · 0.80
SetTrackedMethod · 0.80
GetStrMethod · 0.80
NameMethod · 0.80
ParseTextMethod · 0.80
ParseNameMethod · 0.80

Tested by

no test coverage detected