MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / ParseDeep

Method ParseDeep

externals/tinyxml2/tinyxml2.cpp:1072–1186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1070
1071
1072char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr )
1073{
1074 // This is a recursive method, but thinking about it "at the current level"
1075 // it is a pretty simple flat list:
1076 // <foo/>
1077 // <!-- comment -->
1078 //
1079 // With a special case:
1080 // <foo>
1081 // </foo>
1082 // <!-- comment -->
1083 //
1084 // Where the closing element (/foo) *must* be the next thing after the opening
1085 // element, and the names must match. BUT the tricky bit is that the closing
1086 // element will be read by the child.
1087 //
1088 // 'endTag' is the end tag for this node, it is returned by a call to a child.
1089 // 'parentEnd' is the end tag for the parent, which is filled in and returned.
1090
1091 XMLDocument::DepthTracker tracker(_document);
1092 if (_document->Error())
1093 return 0;
1094
1095 bool first = true;
1096 while( p && *p ) {
1097 XMLNode* node = 0;
1098
1099 p = _document->Identify( p, &node, first );
1100 TIXMLASSERT( p );
1101 if ( node == 0 ) {
1102 break;
1103 }
1104 first = false;
1105
1106 const int initialLineNum = node->_parseLineNum;
1107
1108 StrPair endTag;
1109 p = node->ParseDeep( p, &endTag, curLineNumPtr );
1110 if ( !p ) {
1111 _document->DeleteNode( node );
1112 if ( !_document->Error() ) {
1113 _document->SetError( XML_ERROR_PARSING, initialLineNum, 0);
1114 }
1115 break;
1116 }
1117
1118 const XMLDeclaration* const decl = node->ToDeclaration();
1119 if ( decl ) {
1120 // Declarations are only allowed at document level
1121 //
1122 // Multiple declarations are allowed but all declarations
1123 // must occur before anything else.
1124 //
1125 // Optimized due to a security test case. If the first node is
1126 // a declaration, and the last node is a declaration, then only
1127 // declarations have so far been added.
1128 bool wellLocated = false;
1129

Callers 1

ParseAttributesMethod · 0.80

Calls 15

ToDocumentFunction · 0.85
FirstChildFunction · 0.85
LastChildFunction · 0.85
StringEqualFunction · 0.85
SkipWhiteSpaceFunction · 0.85
IdentifyMethod · 0.80
DeleteNodeMethod · 0.80
SetErrorMethod · 0.80
TransferToMethod · 0.80
SetTrackedMethod · 0.80
EmptyMethod · 0.80
GetStrMethod · 0.80

Tested by

no test coverage detected