/
redgpu
/
tech5
Обзор
Документация
Войти
/
redgpu
/
tech5
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
source/shared/idlib/xml/xmlelement.cpp
71 строка
2 KB
Justin Marshall
First pass idLib conversion from hex rays4.
08 авг 2026, 23:54
08 авг 2026, 23:54
09a4cb9
Код
Авторство
О чём код?
#include "xmlelement.h" idXMLElement::idXMLElement(const char* const elementName) : name(elementName), value(), attributes(), children() { } idXMLElement::idXMLElement(const char* const elementName, const char* const elementValue) : name(elementName), value(elementValue), attributes(), children() { } idXMLElement::~idXMLElement() { for (int index = 0; index < children.Num(); ++index) { idXMLElement* const child = children[index]; if (child != nullptr) { child->~idXMLElement(); std::free(child); } } } idXMLAttribute* idXMLElement::AddAttribute(const char* const attributeName, const char* const attributeValue) { return attributes.Append(idXMLAttribute(attributeName, attributeValue)); } idXMLElement* idXMLElement::AddChild(const char* const childName, const char* const childValue) { idXMLElement* const child = Create(childName, childValue); if (child == nullptr) { return nullptr; } if (children.Append(child) == nullptr) { Destroy(child); return nullptr; } return child; } idXMLElement* idXMLElement::Create(const char* const elementName, const char* const elementValue) { void* const storage = std::malloc(sizeof(idXMLElement)); return storage == nullptr ? nullptr : new (storage) idXMLElement(elementName, elementValue); } void idXMLElement::Destroy(idXMLElement* const element) { if (element != nullptr) { element->~idXMLElement(); std::free(element); } } void idXMLElement::FormatStrings() { FormatStrings_R(this); } void idXMLElement::FormatStrings_R(idXMLElement* const element) { for (int index = 0; index < element->children.Num(); ++index) { FormatStrings_R(element->children[index]); } element->name.ReplaceRecovered("&", "&"); element->name.ReplaceRecovered("<", "<"); element->name.ReplaceRecovered(">", ">"); element->value.ReplaceRecovered("&", "&"); element->value.ReplaceRecovered("<", "<"); element->value.ReplaceRecovered(">", ">"); for (int index = 0; index < element->attributes.Num(); ++index) { element->attributes[index].FormatEntities(); } }