43 bool hasRequiredAttributes(
const TiXmlElement& e,
const std::vector<Attribute>& attributes)
45 for (
const auto& attr : attributes)
49 const char*
value = e.Attribute(
attr.name);
50 if (value && strcmp(
attr.value, value) == 0)
59 TiXmlElement*
uniqueInsert(TiXmlElement& element,
const char* tag,
const std::vector<Attribute>& attributes,
63 TiXmlElement* result = element.FirstChildElement(tag);
64 while (result && !hasRequiredAttributes(*result, attributes))
65 result = result->NextSiblingElement(tag);
68 result = element.InsertEndChild(TiXmlElement(tag))->ToElement();
71 for (
const auto& attr : attributes)
73 if (!result->Attribute(
attr.name))
74 result->SetAttribute(
attr.name,
attr.value);
78 if (text && !result->GetText())
79 result->InsertEndChild(TiXmlText(text));