MCPcopy Create free account
hub / github.com/Overload-Technologies/Overload / ParseAttributes

Method ParseAttributes

Dependencies/tinyxml2/src/tinyxml2.cpp:1812–1869  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected