MCPcopy Create free account
hub / github.com/NanoMichael/MicroTeX / ParseDeep

Method ParseDeep

src/xml/tinyxml2.cpp:788–859  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

ParseAttributesMethod · 0.80

Calls 9

IdentifyMethod · 0.80
SetErrorMethod · 0.80
TransferToMethod · 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