MCPcopy Create free account
hub / github.com/ajkhoury/ReClassEx / ParseAttributes

Method ParseAttributes

ReClass/tinyxml2.cpp:1807–1865  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected