Big refactor, shuffling a lot of files around

This commit is contained in:
2025-11-01 19:51:19 -04:00
parent 99b7d9f49d
commit 62cd94ca78
125 changed files with 4073 additions and 3011 deletions

38
src/util/xml_.cpp Normal file
View File

@@ -0,0 +1,38 @@
#include "xml_.h"
#include "math_.h"
using namespace tinyxml2;
namespace anm2ed::util::xml
{
std::string document_to_string(XMLDocument& self)
{
XMLPrinter printer{};
self.Print(&printer);
return std::string(printer.CStr());
}
XMLError query_string_attribute(XMLElement* element, const char* attribute, std::string* out)
{
const char* temp = nullptr;
auto result = element->QueryStringAttribute(attribute, &temp);
if (result == XML_SUCCESS && temp) *out = temp;
return result;
}
XMLError query_path_attribute(XMLElement* element, const char* attribute, std::filesystem::path* out)
{
std::string temp{};
auto result = query_string_attribute(element, attribute, &temp);
if (result == XML_SUCCESS) *out = temp;
return result;
}
void query_color_attribute(XMLElement* element, const char* attribute, float& out)
{
int value{};
element->QueryIntAttribute(attribute, &value);
out = math::uint8_to_float(value);
}
}