MCPcopy Create free account
hub / github.com/MaxBelkov/visualsyslog / ParseAttributes

Method ParseAttributes

sourcecommon/tinyxml2.cpp:1430–1484  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1428
1429
1430char* XMLElement::ParseAttributes( char* p )
1431{
1432 const char* start = p;
1433 XMLAttribute* prevAttribute = 0;
1434
1435 // Read the attributes.
1436 while( p ) {
1437 p = XMLUtil::SkipWhiteSpace( p );
1438 if ( !p || !(*p) ) {
1439 _document->SetError( XML_ERROR_PARSING_ELEMENT, start, Name() );
1440 return 0;
1441 }
1442
1443 // attribute.
1444 if (XMLUtil::IsNameStartChar( *p ) ) {
1445 XMLAttribute* attrib = new (_document->_attributePool.Alloc() ) XMLAttribute();
1446 attrib->_memPool = &_document->_attributePool;
1447 attrib->_memPool->SetTracked();
1448
1449 p = attrib->ParseDeep( p, _document->ProcessEntities() );
1450 if ( !p || Attribute( attrib->Name() ) ) {
1451 DeleteAttribute( attrib );
1452 _document->SetError( XML_ERROR_PARSING_ATTRIBUTE, start, p );
1453 return 0;
1454 }
1455 // There is a minor bug here: if the attribute in the source xml
1456 // document is duplicated, it will not be detected and the
1457 // attribute will be doubly added. However, tracking the 'prevAttribute'
1458 // avoids re-scanning the attribute list. Preferring performance for
1459 // now, may reconsider in the future.
1460 if ( prevAttribute ) {
1461 prevAttribute->_next = attrib;
1462 }
1463 else {
1464 _rootAttribute = attrib;
1465 }
1466 prevAttribute = attrib;
1467 }
1468 // end of the tag
1469 else if ( *p == '/' && *(p+1) == '>' ) {
1470 _closingType = CLOSED;
1471 return p+2; // done; sealed element.
1472 }
1473 // end of the tag
1474 else if ( *p == '>' ) {
1475 ++p;
1476 break;
1477 }
1478 else {
1479 _document->SetError( XML_ERROR_PARSING_ELEMENT, start, p );
1480 return 0;
1481 }
1482 }
1483 return p;
1484}
1485
1486void XMLElement::DeleteAttribute( XMLAttribute* attribute )
1487{

Callers

nothing calls this directly

Calls 5

SetErrorMethod · 0.80
AllocMethod · 0.80
SetTrackedMethod · 0.80
ParseDeepMethod · 0.80
NameMethod · 0.80

Tested by

no test coverage detected