MCPcopy Create free account
hub / github.com/crossuo/crossuo / ParseAttributes

Method ParseAttributes

external/tinyxml2.cpp:1932–1989  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1930
1931
1932char* XMLElement::ParseAttributes( char* p, int* curLineNumPtr )
1933{
1934 XMLAttribute* prevAttribute = 0;
1935
1936 // Read the attributes.
1937 while( p ) {
1938 p = XMLUtil::SkipWhiteSpace( p, curLineNumPtr );
1939 if ( !(*p) ) {
1940 _document->SetError( XML_ERROR_PARSING_ELEMENT, _parseLineNum, "XMLElement name=%s", Name() );
1941 return 0;
1942 }
1943
1944 // attribute.
1945 if (XMLUtil::IsNameStartChar( *p ) ) {
1946 XMLAttribute* attrib = CreateAttribute();
1947 TIXMLASSERT( attrib );
1948 attrib->_parseLineNum = _document->_parseCurLineNum;
1949
1950 const int attrLineNum = attrib->_parseLineNum;
1951
1952 p = attrib->ParseDeep( p, _document->ProcessEntities(), curLineNumPtr );
1953 if ( !p || Attribute( attrib->Name() ) ) {
1954 DeleteAttribute( attrib );
1955 _document->SetError( XML_ERROR_PARSING_ATTRIBUTE, attrLineNum, "XMLElement name=%s", Name() );
1956 return 0;
1957 }
1958 // There is a minor bug here: if the attribute in the source xml
1959 // document is duplicated, it will not be detected and the
1960 // attribute will be doubly added. However, tracking the 'prevAttribute'
1961 // avoids re-scanning the attribute list. Preferring performance for
1962 // now, may reconsider in the future.
1963 if ( prevAttribute ) {
1964 TIXMLASSERT( prevAttribute->_next == 0 );
1965 prevAttribute->_next = attrib;
1966 }
1967 else {
1968 TIXMLASSERT( _rootAttribute == 0 );
1969 _rootAttribute = attrib;
1970 }
1971 prevAttribute = attrib;
1972 }
1973 // end of the tag
1974 else if ( *p == '>' ) {
1975 ++p;
1976 break;
1977 }
1978 // end of the tag
1979 else if ( *p == '/' && *(p+1) == '>' ) {
1980 _closingType = CLOSED;
1981 return p+2; // done; sealed element.
1982 }
1983 else {
1984 _document->SetError( XML_ERROR_PARSING_ELEMENT, _parseLineNum, 0 );
1985 return 0;
1986 }
1987 }
1988 return p;
1989}

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