MCPcopy Create free account
hub / github.com/OpenMW/openmw / Parse

Method Parse

extern/oics/tinyxml/tinyxmlparser.cpp:696–788  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

694#endif
695
696const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiXmlEncoding encoding )
697{
698 ClearError();
699
700 // Parse away, at the document level. Since a document
701 // contains nothing but other tags, most of what happens
702 // here is skipping white space.
703 if ( !p || !*p )
704 {
705 SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
706 return 0;
707 }
708
709 // Note that, for a document, this needs to come
710 // before the while space skip, so that parsing
711 // starts from the pointer we are given.
712 location.Clear();
713 if ( prevData )
714 {
715 location.row = prevData->cursor.row;
716 location.col = prevData->cursor.col;
717 }
718 else
719 {
720 location.row = 0;
721 location.col = 0;
722 }
723 TiXmlParsingData data( p, TabSize(), location.row, location.col );
724 location = data.Cursor();
725
726 if ( encoding == TIXML_ENCODING_UNKNOWN )
727 {
728 // Check for the Microsoft UTF-8 lead bytes.
729 const unsigned char* pU = (const unsigned char*)p;
730 if ( *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0
731 && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1
732 && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 )
733 {
734 encoding = TIXML_ENCODING_UTF8;
735 useMicrosoftBOM = true;
736 }
737 }
738
739 p = SkipWhiteSpace( p, encoding );
740 if ( !p )
741 {
742 SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
743 return 0;
744 }
745
746 while ( p && *p )
747 {
748 TiXmlNode* node = Identify( p, encoding );
749 if ( node )
750 {
751 p = node->Parse( p, &data, encoding );
752 LinkEndChild( node );
753 }

Callers 3

saveMethod · 0.80
tinyxml.cppFile · 0.80
ReadValueMethod · 0.80

Calls 14

EncodingMethod · 0.80
SetErrorMethod · 0.80
StampMethod · 0.80
c_strMethod · 0.80
lengthMethod · 0.80
SetDocumentMethod · 0.80
NameMethod · 0.80
AddMethod · 0.80
ClearMethod · 0.45
ToDeclarationMethod · 0.45
FindMethod · 0.45
SetValueMethod · 0.45

Tested by

no test coverage detected