MCPcopy Create free account
hub / github.com/MediaArea/MediaInfoLib / ParseAttributes

Method ParseAttributes

Source/ThirdParty/tinyxml2/tinyxml2.cpp:1805–1862  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1803
1804
1805char* XMLElement::ParseAttributes( char* p, int* curLineNumPtr )
1806{
1807 XMLAttribute* prevAttribute = 0;
1808
1809 // Read the attributes.
1810 while( p ) {
1811 p = XMLUtil::SkipWhiteSpace( p, curLineNumPtr );
1812 if ( !(*p) ) {
1813 _document->SetError( XML_ERROR_PARSING_ELEMENT, _parseLineNum, "XMLElement name=%s", Name() );
1814 return 0;
1815 }
1816
1817 // attribute.
1818 if (XMLUtil::IsNameStartChar( *p ) ) {
1819 XMLAttribute* attrib = CreateAttribute();
1820 TIXMLASSERT( attrib );
1821 attrib->_parseLineNum = _document->_parseCurLineNum;
1822
1823 int attrLineNum = attrib->_parseLineNum;
1824
1825 p = attrib->ParseDeep( p, _document->ProcessEntities(), curLineNumPtr );
1826 if ( !p || Attribute( attrib->Name() ) ) {
1827 DeleteAttribute( attrib );
1828 _document->SetError( XML_ERROR_PARSING_ATTRIBUTE, attrLineNum, "XMLElement name=%s", Name() );
1829 return 0;
1830 }
1831 // There is a minor bug here: if the attribute in the source xml
1832 // document is duplicated, it will not be detected and the
1833 // attribute will be doubly added. However, tracking the 'prevAttribute'
1834 // avoids re-scanning the attribute list. Preferring performance for
1835 // now, may reconsider in the future.
1836 if ( prevAttribute ) {
1837 TIXMLASSERT( prevAttribute->_next == 0 );
1838 prevAttribute->_next = attrib;
1839 }
1840 else {
1841 TIXMLASSERT( _rootAttribute == 0 );
1842 _rootAttribute = attrib;
1843 }
1844 prevAttribute = attrib;
1845 }
1846 // end of the tag
1847 else if ( *p == '>' ) {
1848 ++p;
1849 break;
1850 }
1851 // end of the tag
1852 else if ( *p == '/' && *(p+1) == '>' ) {
1853 _closingType = CLOSED;
1854 return p+2; // done; sealed element.
1855 }
1856 else {
1857 _document->SetError( XML_ERROR_PARSING_ELEMENT, _parseLineNum, 0 );
1858 return 0;
1859 }
1860 }
1861 return p;
1862}

Callers

nothing calls this directly

Calls 5

SkipWhiteSpaceFunction · 0.85
IsNameStartCharFunction · 0.85
SetErrorMethod · 0.80
ParseDeepMethod · 0.80
NameMethod · 0.45

Tested by

no test coverage detected