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

Method FindOrCreateAttribute

sourcecommon/tinyxml2.cpp:1384–1408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1382
1383
1384XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name )
1385{
1386 XMLAttribute* last = 0;
1387 XMLAttribute* attrib = 0;
1388 for( attrib = _rootAttribute;
1389 attrib;
1390 last = attrib, attrib = attrib->_next ) {
1391 if ( XMLUtil::StringEqual( attrib->Name(), name ) ) {
1392 break;
1393 }
1394 }
1395 if ( !attrib ) {
1396 attrib = new (_document->_attributePool.Alloc() ) XMLAttribute();
1397 attrib->_memPool = &_document->_attributePool;
1398 if ( last ) {
1399 last->_next = attrib;
1400 }
1401 else {
1402 _rootAttribute = attrib;
1403 }
1404 attrib->SetName( name );
1405 attrib->_memPool->SetTracked(); // always created and linked.
1406 }
1407 return attrib;
1408}
1409
1410
1411void XMLElement::DeleteAttribute( const char* name )

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected