aboutsummaryrefslogtreecommitdiff
path: root/src/ui/ThemeResourceDictionary.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/ThemeResourceDictionary.cpp')
-rw-r--r--src/ui/ThemeResourceDictionary.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/ui/ThemeResourceDictionary.cpp b/src/ui/ThemeResourceDictionary.cpp
index 4bf3d691..d6f2d3e3 100644
--- a/src/ui/ThemeResourceDictionary.cpp
+++ b/src/ui/ThemeResourceDictionary.cpp
@@ -1,4 +1,5 @@
#include "cru/ui/ThemeResourceDictionary.h"
+#include "cru/base/StringUtil.h"
#include "cru/base/io/CFileStream.h"
#include "cru/base/log/Logger.h"
#include "cru/xml/XmlNode.h"
@@ -10,7 +11,7 @@ std::unique_ptr<ThemeResourceDictionary> ThemeResourceDictionary::FromFile(
const String& file_path) {
io::CFileStream stream(file_path.ToUtf8().c_str(), "r");
auto xml_string = stream.ReadToEndAsUtf8String();
- auto parser = xml::XmlParser(String::FromUtf8(xml_string));
+ auto parser = xml::XmlParser(xml_string);
return std::make_unique<ThemeResourceDictionary>(parser.Parse(), false);
}
@@ -24,15 +25,15 @@ ThemeResourceDictionary::ThemeResourceDictionary(xml::XmlElementNode* xml_root,
ThemeResourceDictionary::~ThemeResourceDictionary() = default;
void ThemeResourceDictionary::UpdateResourceMap(xml::XmlElementNode* xml_root) {
- if (!xml_root->GetTag().CaseInsensitiveEqual(u"Theme")) {
+ if (cru::string::CaseInsensitiveCompare(xml_root->GetTag(), "Theme") != 0) {
throw Exception("Root tag of theme must be 'Theme'.");
}
for (auto child : xml_root->GetChildren()) {
if (child->IsElementNode()) {
auto c = child->AsElement();
- if (c->GetTag().CaseInsensitiveEqual(u"Resource")) {
- auto key_attr = c->GetOptionalAttributeValueCaseInsensitive(u"key");
+ if (cru::string::CaseInsensitiveCompare(c->GetTag(), "Resource") == 0) {
+ auto key_attr = c->GetOptionalAttributeValueCaseInsensitive("key");
if (!key_attr) {
throw Exception("'key' attribute is required for resource.");
}
@@ -42,13 +43,12 @@ void ThemeResourceDictionary::UpdateResourceMap(xml::XmlElementNode* xml_root) {
ResourceEntry entry;
- entry.name = *key_attr;
+ entry.name = String::FromUtf8(*key_attr);
entry.xml_node = c->GetFirstChildElement();
resource_map_[entry.name] = std::move(entry);
} else {
- CRU_LOG_TAG_DEBUG("Ignore unknown element {} of theme.",
- c->GetTag().ToUtf8());
+ CRU_LOG_TAG_DEBUG("Ignore unknown element {} of theme.", c->GetTag());
}
} else {
CRU_LOG_TAG_DEBUG("Ignore text or comment node of theme.");