MCPcopy Create free account
hub / github.com/AllentDan/LibtorchTutorials / Identify

Method Identify

lesson7-Detection/src/utils/tinyxmlparser.cpp:818–899  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

816
817
818TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding )
819{
820 TiXmlNode* returnNode = 0;
821
822 p = SkipWhiteSpace( p, encoding );
823 if( !p || !*p || *p != '<' )
824 {
825 return 0;
826 }
827
828 p = SkipWhiteSpace( p, encoding );
829
830 if ( !p || !*p )
831 {
832 return 0;
833 }
834
835 // What is this thing?
836 // - Elements start with a letter or underscore, but xml is reserved.
837 // - Comments: <!--
838 // - Decleration: <?xml
839 // - Everthing else is unknown to tinyxml.
840 //
841
842 const char* xmlHeader = { "<?xml" };
843 const char* commentHeader = { "<!--" };
844 const char* dtdHeader = { "<!" };
845 const char* cdataHeader = { "<![CDATA[" };
846
847 if ( StringEqual( p, xmlHeader, true, encoding ) )
848 {
849 #ifdef DEBUG_PARSER
850 TIXML_LOG( "XML parsing Declaration\n" );
851 #endif
852 returnNode = new TiXmlDeclaration();
853 }
854 else if ( StringEqual( p, commentHeader, false, encoding ) )
855 {
856 #ifdef DEBUG_PARSER
857 TIXML_LOG( "XML parsing Comment\n" );
858 #endif
859 returnNode = new TiXmlComment();
860 }
861 else if ( StringEqual( p, cdataHeader, false, encoding ) )
862 {
863 #ifdef DEBUG_PARSER
864 TIXML_LOG( "XML parsing CDATA\n" );
865 #endif
866 TiXmlText* text = new TiXmlText( "" );
867 text->SetCDATA( true );
868 returnNode = text;
869 }
870 else if ( StringEqual( p, dtdHeader, false, encoding ) )
871 {
872 #ifdef DEBUG_PARSER
873 TIXML_LOG( "XML parsing Unknown(1)\n" );
874 #endif
875 returnNode = new TiXmlUnknown();

Callers

nothing calls this directly

Calls 1

SetCDATAMethod · 0.80

Tested by

no test coverage detected