MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / FindOrCreateAttribute

Method FindOrCreateAttribute

Source/3rdParty/tinyxml2/tinyxml2.cpp:1129–1151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1127}
1128
1129XMLAttribute* XMLElement::FindOrCreateAttribute(const char* name) {
1130 XMLAttribute* last = 0;
1131 XMLAttribute* attrib = 0;
1132 for (attrib = _rootAttribute;
1133 attrib;
1134 last = attrib, attrib = attrib->_next) {
1135 if (XMLUtil::StringEqual(attrib->Name(), name)) {
1136 break;
1137 }
1138 }
1139 if (!attrib) {
1140 attrib = new (_document->_attributePool.Alloc()) XMLAttribute();
1141 attrib->_memPool = &_document->_attributePool;
1142 if (last) {
1143 last->_next = attrib;
1144 } else {
1145 _rootAttribute = attrib;
1146 }
1147 attrib->SetName(name);
1148 attrib->_memPool->SetTracked(); // always created and linked.
1149 }
1150 return attrib;
1151}
1152
1153void XMLElement::DeleteAttribute(const char* name) {
1154 XMLAttribute* prev = 0;

Callers

nothing calls this directly

Calls 5

StringEqualFunction · 0.85
SetTrackedMethod · 0.80
NameMethod · 0.65
AllocMethod · 0.45
SetNameMethod · 0.45

Tested by

no test coverage detected