MCPcopy Create free account
hub / github.com/JayXon/Leanify / FindOrCreateAttribute

Method FindOrCreateAttribute

lib/tinyxml2/tinyxml2.cpp:1452–1477  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1450
1451
1452XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name )
1453{
1454 XMLAttribute* last = 0;
1455 XMLAttribute* attrib = 0;
1456 for( attrib = _rootAttribute;
1457 attrib;
1458 last = attrib, attrib = attrib->_next ) {
1459 if ( XMLUtil::StringEqual( attrib->Name(), name ) ) {
1460 break;
1461 }
1462 }
1463 if ( !attrib ) {
1464 TIXMLASSERT( sizeof( XMLAttribute ) == _document->_attributePool.ItemSize() );
1465 attrib = new (_document->_attributePool.Alloc() ) XMLAttribute();
1466 attrib->_memPool = &_document->_attributePool;
1467 if ( last ) {
1468 last->_next = attrib;
1469 }
1470 else {
1471 _rootAttribute = attrib;
1472 }
1473 attrib->SetName( name );
1474 attrib->_memPool->SetTracked(); // always created and linked.
1475 }
1476 return attrib;
1477}
1478
1479
1480void XMLElement::DeleteAttribute( const char* name )

Callers

nothing calls this directly

Calls 5

NameMethod · 0.80
ItemSizeMethod · 0.80
AllocMethod · 0.80
SetNameMethod · 0.80
SetTrackedMethod · 0.80

Tested by

no test coverage detected