MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / Identify

Method Identify

3rdparty/tinyxml2/tinyxml2.cpp:702–779  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

700
701
702char* XMLDocument::Identify( char* p, XMLNode** node, bool first )
703{
704 TIXMLASSERT( node );
705 TIXMLASSERT( p );
706 char* const start = p;
707 int const startLine = _parseCurLineNum;
708 p = XMLUtil::SkipWhiteSpace( p, &_parseCurLineNum );
709 if( !*p ) {
710 *node = 0;
711 TIXMLASSERT( p );
712 return p;
713 }
714
715 // These strings define the matching patterns:
716 static const char* xmlHeader = { "<?" };
717 static const char* commentHeader = { "<!--" };
718 static const char* cdataHeader = { "<![CDATA[" };
719 static const char* dtdHeader = { "<!" };
720 static const char* elementHeader = { "<" }; // and a header for everything else; check last.
721
722 static const int xmlHeaderLen = 2;
723 static const int commentHeaderLen = 4;
724 static const int cdataHeaderLen = 9;
725 static const int dtdHeaderLen = 2;
726 static const int elementHeaderLen = 1;
727
728 TIXMLASSERT( sizeof( XMLComment ) == sizeof( XMLUnknown ) ); // use same memory pool
729 TIXMLASSERT( sizeof( XMLComment ) == sizeof( XMLDeclaration ) ); // use same memory pool
730 XMLNode* returnNode = 0;
731 if ( XMLUtil::StringEqual( p, xmlHeader, xmlHeaderLen ) ) {
732 returnNode = CreateUnlinkedNode<XMLDeclaration>( _commentPool );
733 returnNode->_parseLineNum = _parseCurLineNum;
734 p += xmlHeaderLen;
735 }
736 else if ( XMLUtil::StringEqual( p, commentHeader, commentHeaderLen ) ) {
737 returnNode = CreateUnlinkedNode<XMLComment>( _commentPool );
738 returnNode->_parseLineNum = _parseCurLineNum;
739 p += commentHeaderLen;
740 }
741 else if ( XMLUtil::StringEqual( p, cdataHeader, cdataHeaderLen ) ) {
742 XMLText* text = CreateUnlinkedNode<XMLText>( _textPool );
743 returnNode = text;
744 returnNode->_parseLineNum = _parseCurLineNum;
745 p += cdataHeaderLen;
746 text->SetCData( true );
747 }
748 else if ( XMLUtil::StringEqual( p, dtdHeader, dtdHeaderLen ) ) {
749 returnNode = CreateUnlinkedNode<XMLUnknown>( _commentPool );
750 returnNode->_parseLineNum = _parseCurLineNum;
751 p += dtdHeaderLen;
752 }
753 else if ( XMLUtil::StringEqual( p, elementHeader, elementHeaderLen ) ) {
754
755 // Preserve whitespace pedantically before closing tag, when it's immediately after opening tag
756 if (WhitespaceMode() == PEDANTIC_WHITESPACE && first && p != start && *(p + elementHeaderLen) == '/') {
757 returnNode = CreateUnlinkedNode<XMLText>(_textPool);
758 returnNode->_parseLineNum = startLine;
759 p = start; // Back it up, all the text counts.

Callers 1

ParseDeepMethod · 0.80

Calls 3

SkipWhiteSpaceFunction · 0.85
StringEqualFunction · 0.85
WhitespaceModeFunction · 0.85

Tested by

no test coverage detected