MCPcopy Create free account
hub / github.com/MaxBelkov/visualsyslog / ParseDeep

Method ParseDeep

sourcecommon/tinyxml2.cpp:785–863  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

783
784
785char* XMLNode::ParseDeep( char* p, StrPair* parentEnd )
786{
787 // This is a recursive method, but thinking about it "at the current level"
788 // it is a pretty simple flat list:
789 // <foo/>
790 // <!-- comment -->
791 //
792 // With a special case:
793 // <foo>
794 // </foo>
795 // <!-- comment -->
796 //
797 // Where the closing element (/foo) *must* be the next thing after the opening
798 // element, and the names must match. BUT the tricky bit is that the closing
799 // element will be read by the child.
800 //
801 // 'endTag' is the end tag for this node, it is returned by a call to a child.
802 // 'parentEnd' is the end tag for the parent, which is filled in and returned.
803
804 while( p && *p ) {
805 XMLNode* node = 0;
806
807 p = _document->Identify( p, &node );
808 if ( p == 0 || node == 0 ) {
809 break;
810 }
811
812 StrPair endTag;
813 p = node->ParseDeep( p, &endTag );
814 if ( !p ) {
815 DeleteNode( node );
816 node = 0;
817 if ( !_document->Error() ) {
818 _document->SetError( XML_ERROR_PARSING, 0, 0 );
819 }
820 break;
821 }
822
823 XMLElement* ele = node->ToElement();
824 // We read the end tag. Return it to the parent.
825 if ( ele && ele->ClosingType() == XMLElement::CLOSING ) {
826 if ( parentEnd ) {
827 *parentEnd = ele->_value;
828 }
829 node->_memPool->SetTracked(); // created and then immediately deleted.
830 DeleteNode( node );
831 return p;
832 }
833
834 // Handle an end tag returned to this level.
835 // And handle a bunch of annoying errors.
836 if ( ele ) {
837 bool mismatch = false;
838 if ( endTag.Empty() && ele->ClosingType() == XMLElement::OPEN ) {
839 mismatch = true;
840 }
841 else if ( !endTag.Empty() && ele->ClosingType() != XMLElement::OPEN ) {
842 mismatch = true;

Callers 1

ParseAttributesMethod · 0.80

Calls 10

InsertEndChildMethod · 0.95
DeleteNodeFunction · 0.85
IdentifyMethod · 0.80
SetErrorMethod · 0.80
SetTrackedMethod · 0.80
GetStrMethod · 0.80
ValueMethod · 0.80
ParseTextMethod · 0.80
ParseNameMethod · 0.80
EmptyMethod · 0.45

Tested by

no test coverage detected