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

Method ParseAttributes

Source/3rdParty/tinyxml2/tinyxml2.cpp:1169–1220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1167}
1168
1169char* XMLElement::ParseAttributes(char* p) {
1170 const char* start = p;
1171 XMLAttribute* prevAttribute = 0;
1172
1173 // Read the attributes.
1174 while (p) {
1175 p = XMLUtil::SkipWhiteSpace(p);
1176 if (!p || !(*p)) {
1177 _document->SetError(start, XML_ERROR_PARSING_ELEMENT, start, Name());
1178 return 0;
1179 }
1180
1181 // attribute.
1182 if (XMLUtil::IsAlpha(*p)) {
1183 XMLAttribute* attrib = new (_document->_attributePool.Alloc()) XMLAttribute();
1184 attrib->_memPool = &_document->_attributePool;
1185 attrib->_memPool->SetTracked();
1186 const char* tmp = p;
1187 p = attrib->ParseDeep(p, _document->ProcessEntities());
1188 if (!p || Attribute(attrib->Name())) {
1189 DELETE_ATTRIBUTE(attrib);
1190 _document->SetError(tmp, XML_ERROR_PARSING_ATTRIBUTE, tmp, p);
1191 return 0;
1192 }
1193 // There is a minor bug here: if the attribute in the source xml
1194 // document is duplicated, it will not be detected and the
1195 // attribute will be doubly added. However, tracking the 'prevAttribute'
1196 // avoids re-scanning the attribute list. Preferring performance for
1197 // now, may reconsider in the future.
1198 if (prevAttribute) {
1199 prevAttribute->_next = attrib;
1200 } else {
1201 _rootAttribute = attrib;
1202 }
1203 prevAttribute = attrib;
1204 }
1205 // end of the tag
1206 else if (*p == '/' && *(p + 1) == '>') {
1207 _closingType = CLOSED;
1208 return p + 2; // done; sealed element.
1209 }
1210 // end of the tag
1211 else if (*p == '>') {
1212 ++p;
1213 break;
1214 } else {
1215 _document->SetError(start, XML_ERROR_PARSING_ELEMENT, start, p);
1216 return 0;
1217 }
1218 }
1219 return p;
1220}
1221
1222//
1223// <ele></ele>

Callers

nothing calls this directly

Calls 8

NameClass · 0.85
SetErrorMethod · 0.80
SetTrackedMethod · 0.80
ParseDeepMethod · 0.80
ProcessEntitiesMethod · 0.80
NameMethod · 0.65
AttributeClass · 0.50
AllocMethod · 0.45

Tested by

no test coverage detected