MCPcopy Create free account
hub / github.com/avast/retdec / ParseDeep

Method ParseDeep

deps/tinyxml2/tinyxml2.cpp:1010–1122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1008
1009
1010char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr )
1011{
1012 // This is a recursive method, but thinking about it "at the current level"
1013 // it is a pretty simple flat list:
1014 // <foo/>
1015 // <!-- comment -->
1016 //
1017 // With a special case:
1018 // <foo>
1019 // </foo>
1020 // <!-- comment -->
1021 //
1022 // Where the closing element (/foo) *must* be the next thing after the opening
1023 // element, and the names must match. BUT the tricky bit is that the closing
1024 // element will be read by the child.
1025 //
1026 // 'endTag' is the end tag for this node, it is returned by a call to a child.
1027 // 'parentEnd' is the end tag for the parent, which is filled in and returned.
1028
1029 XMLDocument::DepthTracker tracker(_document);
1030 if (_document->Error())
1031 return 0;
1032
1033 while( p && *p ) {
1034 XMLNode* node = 0;
1035
1036 p = _document->Identify( p, &node );
1037 TIXMLASSERT( p );
1038 if ( node == 0 ) {
1039 break;
1040 }
1041
1042 const int initialLineNum = node->_parseLineNum;
1043
1044 StrPair endTag;
1045 p = node->ParseDeep( p, &endTag, curLineNumPtr );
1046 if ( !p ) {
1047 DeleteNode( node );
1048 if ( !_document->Error() ) {
1049 _document->SetError( XML_ERROR_PARSING, initialLineNum, 0);
1050 }
1051 break;
1052 }
1053
1054 const XMLDeclaration* const decl = node->ToDeclaration();
1055 if ( decl ) {
1056 // Declarations are only allowed at document level
1057 //
1058 // Multiple declarations are allowed but all declarations
1059 // must occur before anything else.
1060 //
1061 // Optimized due to a security test case. If the first node is
1062 // a declaration, and the last node is a declaration, then only
1063 // declarations have so far been added.
1064 bool wellLocated = false;
1065
1066 if (ToDocument()) {
1067 if (FirstChild()) {

Callers 1

ParseAttributesMethod · 0.80

Calls 15

ToDocumentFunction · 0.85
FirstChildFunction · 0.85
LastChildFunction · 0.85
SkipWhiteSpaceFunction · 0.85
IdentifyMethod · 0.80
SetErrorMethod · 0.80
TransferToMethod · 0.80
SetTrackedMethod · 0.80
GetStrMethod · 0.80
ParseTextMethod · 0.80
ParseNameMethod · 0.80
StringEqualFunction · 0.50

Tested by

no test coverage detected