MCPcopy Create free account
hub / github.com/9miao/CrossApp / ParseDeep

Method ParseDeep

CrossApp/support/tinyxml2/tinyxml2.cpp:777–853  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

ParseAttributesMethod · 0.80

Calls 9

InsertEndChildMethod · 0.95
StringEqualFunction · 0.85
SkipWhiteSpaceFunction · 0.85
IdentifyMethod · 0.80
SetErrorMethod · 0.80
ValueMethod · 0.80
GetStrMethod · 0.80
ParseTextMethod · 0.80
ParseNameMethod · 0.80

Tested by

no test coverage detected