MCPcopy Create free account
hub / github.com/PolygonTek/BlueshiftEngine / ParseDeep

Method ParseDeep

Source/ThirdParty/tinyxml2/tinyxml2.cpp:951–1036  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

949
950
951char* XMLNode::ParseDeep( char* p, StrPair* parentEnd )
952{
953 // This is a recursive method, but thinking about it "at the current level"
954 // it is a pretty simple flat list:
955 // <foo/>
956 // <!-- comment -->
957 //
958 // With a special case:
959 // <foo>
960 // </foo>
961 // <!-- comment -->
962 //
963 // Where the closing element (/foo) *must* be the next thing after the opening
964 // element, and the names must match. BUT the tricky bit is that the closing
965 // element will be read by the child.
966 //
967 // 'endTag' is the end tag for this node, it is returned by a call to a child.
968 // 'parentEnd' is the end tag for the parent, which is filled in and returned.
969
970 while( p && *p ) {
971 XMLNode* node = 0;
972
973 p = _document->Identify( p, &node );
974 if ( node == 0 ) {
975 break;
976 }
977
978 StrPair endTag;
979 p = node->ParseDeep( p, &endTag );
980 if ( !p ) {
981 DeleteNode( node );
982 if ( !_document->Error() ) {
983 _document->SetError( XML_ERROR_PARSING, 0, 0 );
984 }
985 break;
986 }
987
988 XMLDeclaration* decl = node->ToDeclaration();
989 if ( decl ) {
990 // A declaration can only be the first child of a document.
991 // Set error, if document already has children.
992 if ( !_document->NoChildren() ) {
993 _document->SetError( XML_ERROR_PARSING_DECLARATION, decl->Value(), 0);
994 DeleteNode( node );
995 break;
996 }
997 }
998
999 XMLElement* ele = node->ToElement();
1000 if ( ele ) {
1001 // We read the end tag. Return it to the parent.
1002 if ( ele->ClosingType() == XMLElement::CLOSING ) {
1003 if ( parentEnd ) {
1004 ele->_value.TransferTo( parentEnd );
1005 }
1006 node->_memPool->SetTracked(); // created and then immediately deleted.
1007 DeleteNode( node );
1008 return p;

Callers 1

ParseAttributesMethod · 0.80

Calls 11

IdentifyMethod · 0.80
SetErrorMethod · 0.80
TransferToMethod · 0.80
SetTrackedMethod · 0.80
GetStrMethod · 0.80
ParseTextMethod · 0.80
ParseNameMethod · 0.80
ErrorMethod · 0.45
ValueMethod · 0.45
EmptyMethod · 0.45
NameMethod · 0.45

Tested by

no test coverage detected