MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / Identify

Method Identify

Source/3rdParty/tinyxml2/tinyxml2.cpp:430–506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

428}
429
430char* XMLDocument::Identify(char* p, XMLNode** node) {
431 XMLNode* returnNode = 0;
432 char* start = p;
433 if (!_cdataHeader) {
434 p = XMLUtil::SkipWhiteSpace(p);
435 if (!p || !*p) {
436 return p;
437 }
438 }
439 // What is this thing?
440 // - Elements start with a letter or underscore, but xml is reserved.
441 // - Comments: <!--
442 // - Decleration: <?
443 // - Everthing else is unknown to tinyxml.
444 //
445
446 static const char* xmlHeader = {"<?"};
447 static const char* commentHeader = {"<!--"};
448 static const char* dtdHeader = {"<!"};
449 static const char* cdataHeader = {"<![CDATA["};
450 static const char* elementHeader = {"<"}; // and a header for everything else; check last.
451
452 static const int xmlHeaderLen = 2;
453 static const int commentHeaderLen = 4;
454 static const int dtdHeaderLen = 2;
455 static const int cdataHeaderLen = 9;
456 static const int elementHeaderLen = 1;
457
458#if defined(_MSC_VER)
459#pragma warning(push)
460#pragma warning(disable : 4127)
461#endif
462 TIXMLASSERT(sizeof(XMLComment) == sizeof(XMLUnknown)); // use same memory pool
463 TIXMLASSERT(sizeof(XMLComment) == sizeof(XMLDeclaration)); // use same memory pool
464#if defined(_MSC_VER)
465#pragma warning(pop)
466#endif
467 if (XMLUtil::StringEqual(p, xmlHeader, xmlHeaderLen)) {
468 returnNode = new (_commentPool.Alloc()) XMLDeclaration(this);
469 returnNode->_memPool = &_commentPool;
470 p += xmlHeaderLen;
471 } else if (XMLUtil::StringEqual(p, commentHeader, commentHeaderLen)) {
472 returnNode = new (_commentPool.Alloc()) XMLComment(this);
473 returnNode->_memPool = &_commentPool;
474 p += commentHeaderLen;
475 } else if (XMLUtil::StringEqual(p, cdataHeader, cdataHeaderLen)) {
476 XMLText* text = new (_textPool.Alloc()) XMLText(this);
477 returnNode = text;
478 returnNode->_memPool = &_textPool;
479 p += cdataHeaderLen;
480 text->SetCData(true);
481 // clear temporary used cdata header
482 if (_cdataHeader) {
483 _cdataHeader = NULL;
484 }
485 } else if (_cdataHeader) {
486 XMLText* text = new (_textPool.Alloc()) XMLText(this);
487 returnNode = text;

Callers 1

ParseDeepMethod · 0.80

Calls 3

StringEqualFunction · 0.85
SetCDataMethod · 0.80
AllocMethod · 0.45

Tested by

no test coverage detected