Big refactor, shuffling a lot of files around
This commit is contained in:
38
src/util/xml_.cpp
Normal file
38
src/util/xml_.cpp
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user