aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.cpp2
-rw-r--r--src/ThemeBuilder/components/properties/PointPropertyEditor.cpp2
-rw-r--r--src/ThemeBuilder/components/properties/ThicknessPropertyEditor.cpp2
-rw-r--r--src/base/StringUtil.cpp39
-rw-r--r--src/ui/ThemeResourceDictionary.cpp14
-rw-r--r--src/ui/mapper/BorderStyleMapper.cpp14
-rw-r--r--src/ui/mapper/BrushMapper.cpp4
-rw-r--r--src/ui/mapper/ColorMapper.cpp13
-rw-r--r--src/ui/mapper/CornerRadiusMapper.cpp16
-rw-r--r--src/ui/mapper/CursorMapper.cpp12
-rw-r--r--src/ui/mapper/FontMapper.cpp14
-rw-r--r--src/ui/mapper/Mapper.cpp4
-rw-r--r--src/ui/mapper/MeasureLengthMapper.cpp14
-rw-r--r--src/ui/mapper/PointMapper.cpp8
-rw-r--r--src/ui/mapper/SizeMapper.cpp8
-rw-r--r--src/ui/mapper/StringMapper.cpp8
-rw-r--r--src/ui/mapper/ThicknessMapper.cpp8
-rw-r--r--src/ui/mapper/style/AndConditionMapper.cpp2
-rw-r--r--src/ui/mapper/style/BorderStylerMapper.cpp2
-rw-r--r--src/ui/mapper/style/CheckedConditionMapper.cpp14
-rw-r--r--src/ui/mapper/style/ClickStateConditionMapper.cpp17
-rw-r--r--src/ui/mapper/style/CursorStylerMapper.cpp2
-rw-r--r--src/ui/mapper/style/FocusConditionMapper.cpp12
-rw-r--r--src/ui/mapper/style/HoverConditionMapper.cpp12
-rw-r--r--src/ui/mapper/style/MarginStylerMapper.cpp2
-rw-r--r--src/ui/mapper/style/NoConditionMapper.cpp2
-rw-r--r--src/ui/mapper/style/OrConditionMapper.cpp2
-rw-r--r--src/ui/mapper/style/PaddingStylerMapper.cpp3
-rw-r--r--src/ui/mapper/style/PreferredSizeStylerMapper.cpp6
-rw-r--r--src/ui/mapper/style/StyleRuleMapper.cpp4
-rw-r--r--src/ui/mapper/style/StyleRuleSetMapper.cpp2
-rw-r--r--src/xml/XmlNode.cpp2
-rw-r--r--src/xml/XmlParser.cpp47
33 files changed, 187 insertions, 126 deletions
diff --git a/src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.cpp b/src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.cpp
index e359199f..9280718d 100644
--- a/src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.cpp
+++ b/src/ThemeBuilder/components/properties/MeasureLengthPropertyEditor.cpp
@@ -15,7 +15,7 @@ MeasureLengthPropertyEditor::MeasureLengthPropertyEditor() {
->GetMapper<ui::render::MeasureLength>();
try {
auto measure_length =
- measure_length_mapper->MapFromString(text.ToString());
+ measure_length_mapper->MapFromString(text.ToString().ToUtf8());
measure_length_ = measure_length;
is_text_valid_ = true;
RaiseChangeEvent();
diff --git a/src/ThemeBuilder/components/properties/PointPropertyEditor.cpp b/src/ThemeBuilder/components/properties/PointPropertyEditor.cpp
index f2d10cf7..8d7ac942 100644
--- a/src/ThemeBuilder/components/properties/PointPropertyEditor.cpp
+++ b/src/ThemeBuilder/components/properties/PointPropertyEditor.cpp
@@ -14,7 +14,7 @@ PointPropertyEditor::PointPropertyEditor() {
auto point_mapper =
ui::mapper::MapperRegistry::GetInstance()->GetMapper<ui::Point>();
try {
- auto point = point_mapper->MapFromString(text.ToString());
+ auto point = point_mapper->MapFromString(text.ToString().ToUtf8());
point_ = point;
is_text_valid_ = true;
RaiseChangeEvent();
diff --git a/src/ThemeBuilder/components/properties/ThicknessPropertyEditor.cpp b/src/ThemeBuilder/components/properties/ThicknessPropertyEditor.cpp
index 955a44f7..0790cd98 100644
--- a/src/ThemeBuilder/components/properties/ThicknessPropertyEditor.cpp
+++ b/src/ThemeBuilder/components/properties/ThicknessPropertyEditor.cpp
@@ -13,7 +13,7 @@ ThicknessPropertyEditor::ThicknessPropertyEditor() {
auto thickness_mapper =
ui::mapper::MapperRegistry::GetInstance()->GetMapper<ui::Thickness>();
try {
- auto thickness = thickness_mapper->MapFromString(text);
+ auto thickness = thickness_mapper->MapFromString(text.ToUtf8());
thickness_ = thickness;
is_text_valid_ = true;
RaiseChangeEvent();
diff --git a/src/base/StringUtil.cpp b/src/base/StringUtil.cpp
index 6299acc2..bbd201cd 100644
--- a/src/base/StringUtil.cpp
+++ b/src/base/StringUtil.cpp
@@ -2,7 +2,46 @@
#include "cru/base/Base.h"
#include "cru/base/Exception.h"
+#include <algorithm>
+#include <cctype>
+#include <compare>
+
namespace cru {
+namespace string {
+
+std::weak_ordering CaseInsensitiveCompare(std::string_view left,
+ std::string_view right) {
+ return std::lexicographical_compare_three_way(
+ left.cbegin(), left.cend(), right.cbegin(), right.cend(),
+ [](char left, char right) {
+ auto l = tolower(left), r = tolower(right);
+ return l < r ? std::weak_ordering::less
+ : (l == r ? std::weak_ordering::equivalent
+ : std::weak_ordering::greater);
+ });
+}
+
+std::string TrimBegin(std::string_view str) {
+ auto iter = std::find_if(str.cbegin(), str.cend(),
+ [](char c) { return !std::isspace(c); });
+ return std::string(iter, str.cend());
+}
+
+std::string TrimEnd(std::string_view str) {
+ auto iter = std::find_if(str.crbegin(), str.crend(),
+ [](char c) { return !std::isspace(c); });
+ return std::string(str.cbegin(), str.cend() - (iter - str.crbegin()));
+}
+
+std::string Trim(std::string_view str) {
+ auto iter1 = std::find_if(str.cbegin(), str.cend(),
+ [](char c) { return !std::isspace(c); });
+ auto iter2 = std::find_if(str.crbegin(), str.crend(),
+ [](char c) { return !std::isspace(c); });
+ return std::string(iter1, str.cend() - (iter2 - str.crbegin()));
+}
+} // namespace string
+
using details::ExtractBits;
CodePoint Utf8NextCodePoint(const char* ptr, Index size, Index current,
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.");
diff --git a/src/ui/mapper/BorderStyleMapper.cpp b/src/ui/mapper/BorderStyleMapper.cpp
index a51651bd..fa3f672d 100644
--- a/src/ui/mapper/BorderStyleMapper.cpp
+++ b/src/ui/mapper/BorderStyleMapper.cpp
@@ -1,8 +1,6 @@
#include "cru/ui/mapper/BorderStyleMapper.h"
-#include "../Helper.h"
-#include "cru/base/log/Logger.h"
+#include "cru/base/StringUtil.h"
#include "cru/platform/graphics/Brush.h"
-#include "cru/platform/graphics/Factory.h"
#include "cru/ui/mapper/MapperRegistry.h"
#include "cru/ui/style/ApplyBorderStyleInfo.h"
#include "cru/xml/XmlNode.h"
@@ -12,7 +10,8 @@ using namespace xml;
using ui::style::ApplyBorderStyleInfo;
bool BorderStyleMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
- return node->GetTag().CaseInsensitiveCompare(u"BorderStyle") == 0;
+ return cru::string::CaseInsensitiveCompare(node->GetTag(), "BorderStyle") ==
+ 0;
}
ApplyBorderStyleInfo BorderStyleMapper::DoMapFromXml(
@@ -36,11 +35,12 @@ ApplyBorderStyleInfo BorderStyleMapper::DoMapFromXml(
result.border_radius = corner_radius_mapper->MapFromXml(c);
} else if (brush_mapper->XmlElementIsOfThisType(c)) {
auto brush = brush_mapper->MapFromXml(c);
- auto name = c->GetOptionalAttributeValueCaseInsensitive(u"name");
+ auto name = c->GetOptionalAttributeValueCaseInsensitive("name");
if (name) {
- if (name->CaseInsensitiveCompare(u"foreground") == 0) {
+ if (cru::string::CaseInsensitiveCompare(*name, "foreground") == 0) {
result.foreground_brush = std::move(brush);
- } else if (name->CaseInsensitiveCompare(u"background") == 0) {
+ } else if (cru::string::CaseInsensitiveCompare(*name, "background") ==
+ 0) {
result.background_brush = std::move(brush);
} else {
}
diff --git a/src/ui/mapper/BrushMapper.cpp b/src/ui/mapper/BrushMapper.cpp
index 737508ce..81eb40a5 100644
--- a/src/ui/mapper/BrushMapper.cpp
+++ b/src/ui/mapper/BrushMapper.cpp
@@ -1,9 +1,9 @@
#include "cru/ui/mapper/BrushMapper.h"
#include "../Helper.h"
+#include "cru/base/StringUtil.h"
#include "cru/platform/Color.h"
#include "cru/platform/graphics/Brush.h"
#include "cru/platform/graphics/Factory.h"
-#include "cru/ui/mapper/ColorMapper.h"
#include "cru/ui/mapper/MapperRegistry.h"
#include "cru/xml/XmlNode.h"
@@ -13,7 +13,7 @@ namespace cru::ui::mapper {
bool BrushMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
auto color_mapper = MapperRegistry::GetInstance()->GetMapper<Color>();
return color_mapper->XmlElementIsOfThisType(node) ||
- node->GetTag().CaseInsensitiveEqual(u"Brush");
+ cru::string::CaseInsensitiveCompare(node->GetTag(), "Brush") == 0;
}
std::shared_ptr<platform::graphics::IBrush> BrushMapper::DoMapFromXml(
diff --git a/src/ui/mapper/ColorMapper.cpp b/src/ui/mapper/ColorMapper.cpp
index 72ea1ce2..a959e6d8 100644
--- a/src/ui/mapper/ColorMapper.cpp
+++ b/src/ui/mapper/ColorMapper.cpp
@@ -2,11 +2,11 @@
namespace cru::ui::mapper {
bool ColorMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
- return node->GetTag().CaseInsensitiveCompare(u"Color") == 0;
+ return cru::string::CaseInsensitiveCompare(node->GetTag(), "Color") == 0;
}
-Color ColorMapper::DoMapFromString(String str) {
- auto c = Color::Parse(str);
+Color ColorMapper::DoMapFromString(std::string str) {
+ auto c = Color::Parse(String::FromUtf8(str));
if (!c) {
throw Exception("Invalid color value.");
}
@@ -14,15 +14,16 @@ Color ColorMapper::DoMapFromString(String str) {
}
Color ColorMapper::DoMapFromXml(xml::XmlElementNode* node) {
- auto value_attr = node->GetOptionalAttributeValueCaseInsensitive(u"value");
+ auto value_attr = node->GetOptionalAttributeValueCaseInsensitive("value");
Color result = colors::transparent;
if (value_attr) {
result = DoMapFromString(*value_attr);
}
- auto alpha_value_attr = node->GetOptionalAttributeValueCaseInsensitive(u"alpha");
+ auto alpha_value_attr =
+ node->GetOptionalAttributeValueCaseInsensitive("alpha");
if (alpha_value_attr) {
- result.alpha = alpha_value_attr->ParseToDouble() * 255;
+ result.alpha = String::FromUtf8(*alpha_value_attr).ParseToDouble() * 255;
}
return result;
diff --git a/src/ui/mapper/CornerRadiusMapper.cpp b/src/ui/mapper/CornerRadiusMapper.cpp
index 60a72855..defb9d21 100644
--- a/src/ui/mapper/CornerRadiusMapper.cpp
+++ b/src/ui/mapper/CornerRadiusMapper.cpp
@@ -1,37 +1,39 @@
#include "cru/ui/mapper/CornerRadiusMapper.h"
#include "cru/ui/mapper/MapperRegistry.h"
-#include "cru/ui/mapper/PointMapper.h"
namespace cru::ui::mapper {
bool CornerRadiusMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
- return node->GetTag().CaseInsensitiveCompare(u"CornerRadius") == 0;
+ return cru::string::CaseInsensitiveCompare(node->GetTag(), "CornerRadius") ==
+ 0;
}
CornerRadius CornerRadiusMapper::DoMapFromXml(xml::XmlElementNode* node) {
auto point_mapper = MapperRegistry::GetInstance()->GetMapper<Point>();
CornerRadius result;
- auto all = node->GetOptionalAttributeValueCaseInsensitive(u"all");
+ auto all = node->GetOptionalAttributeValueCaseInsensitive("all");
if (all) {
result.SetAll(point_mapper->MapFromString(*all));
}
- auto lefttop = node->GetOptionalAttributeValueCaseInsensitive(u"lefttop");
+ auto lefttop = node->GetOptionalAttributeValueCaseInsensitive("lefttop");
if (lefttop) {
result.left_top = point_mapper->MapFromString(*lefttop);
}
- auto righttop = node->GetOptionalAttributeValueCaseInsensitive(u"righttop");
+ auto righttop = node->GetOptionalAttributeValueCaseInsensitive("righttop");
if (righttop) {
result.right_top = point_mapper->MapFromString(*righttop);
}
- auto rightbottom = node->GetOptionalAttributeValueCaseInsensitive(u"rightbottom");
+ auto rightbottom =
+ node->GetOptionalAttributeValueCaseInsensitive("rightbottom");
if (rightbottom) {
result.right_bottom = point_mapper->MapFromString(*rightbottom);
}
- auto leftbottom = node->GetOptionalAttributeValueCaseInsensitive(u"leftbottom");
+ auto leftbottom =
+ node->GetOptionalAttributeValueCaseInsensitive("leftbottom");
if (leftbottom) {
result.left_bottom = point_mapper->MapFromString(*leftbottom);
}
diff --git a/src/ui/mapper/CursorMapper.cpp b/src/ui/mapper/CursorMapper.cpp
index 4f59439f..c0c8e8d2 100644
--- a/src/ui/mapper/CursorMapper.cpp
+++ b/src/ui/mapper/CursorMapper.cpp
@@ -9,19 +9,19 @@ using cru::platform::gui::ICursor;
using cru::platform::gui::SystemCursorType;
bool CursorMapper::XmlElementIsOfThisType(xml::XmlElementNode *node) {
- return node->GetTag().CaseInsensitiveCompare(u"Cursor") == 0;
+ return cru::string::CaseInsensitiveCompare(node->GetTag(), "Cursor") == 0;
}
-std::shared_ptr<ICursor> CursorMapper::DoMapFromString(String str) {
+std::shared_ptr<ICursor> CursorMapper::DoMapFromString(std::string str) {
if (str.empty()) return nullptr;
auto cursor_manager = GetUiApplication()->GetCursorManager();
- if (str.CaseInsensitiveCompare(u"arrow") == 0) {
+ if (cru::string::CaseInsensitiveCompare(str, "arrow") == 0) {
return cursor_manager->GetSystemCursor(SystemCursorType::Arrow);
- } else if (str.CaseInsensitiveCompare(u"hand") == 0) {
+ } else if (cru::string::CaseInsensitiveCompare(str, "hand") == 0) {
return cursor_manager->GetSystemCursor(SystemCursorType::Hand);
- } else if (str.CaseInsensitiveCompare(u"ibeam") == 0) {
+ } else if (cru::string::CaseInsensitiveCompare(str, "ibeam") == 0) {
return cursor_manager->GetSystemCursor(SystemCursorType::IBeam);
} else {
throw Exception("Unsupported cursor type.");
@@ -29,7 +29,7 @@ std::shared_ptr<ICursor> CursorMapper::DoMapFromString(String str) {
}
std::shared_ptr<ICursor> CursorMapper::DoMapFromXml(xml::XmlElementNode *node) {
- auto value_attr = node->GetOptionalAttributeValueCaseInsensitive(u"value");
+ auto value_attr = node->GetOptionalAttributeValueCaseInsensitive("value");
if (!value_attr) return nullptr;
return DoMapFromString(*value_attr);
}
diff --git a/src/ui/mapper/FontMapper.cpp b/src/ui/mapper/FontMapper.cpp
index 13a2bc75..bb3550ea 100644
--- a/src/ui/mapper/FontMapper.cpp
+++ b/src/ui/mapper/FontMapper.cpp
@@ -4,17 +4,19 @@
namespace cru::ui::mapper {
bool FontMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
- return node->GetTag().CaseInsensitiveEqual(u"font");
+ return cru::string::CaseInsensitiveCompare(node->GetTag(), "font") == 0;
}
std::shared_ptr<platform::graphics::IFont> FontMapper::DoMapFromXml(
xml::XmlElementNode* node) {
- auto font_family_attr = node->GetOptionalAttributeValue(u"family");
- auto font_size_attr = node->GetOptionalAttributeValue(u"size");
+ auto font_family_attr = node->GetOptionalAttributeValue("family");
+ auto font_size_attr = node->GetOptionalAttributeValue("size");
- auto font_family = font_family_attr.value_or(u"");
- auto font_size = font_size_attr ? font_size_attr->ParseToFloat() : 24.0f;
+ auto font_family = font_family_attr.value_or("");
+ auto font_size =
+ font_size_attr ? String::FromUtf8(*font_size_attr).ParseToFloat() : 24.0f;
- return GetGraphicsFactory()->CreateFont(font_family, font_size);
+ return GetGraphicsFactory()->CreateFont(String::FromUtf8(font_family),
+ font_size);
}
} // namespace cru::ui::mapper
diff --git a/src/ui/mapper/Mapper.cpp b/src/ui/mapper/Mapper.cpp
index ebf880a2..ca6cf0b3 100644
--- a/src/ui/mapper/Mapper.cpp
+++ b/src/ui/mapper/Mapper.cpp
@@ -1,4 +1,5 @@
#include "cru/ui/mapper/Mapper.h"
+#include "cru/base/StringUtil.h"
#include <typeindex>
@@ -8,7 +9,8 @@ MapperBase::MapperBase(std::type_index type_index)
bool MapperBase::XmlElementIsOfThisType(xml::XmlElementNode* node) {
for (const auto& tag : allowed_tags_) {
- if (node->GetTag().CaseInsensitiveEqual(tag)) {
+ if (cru::string::CaseInsensitiveCompare(node->GetTag(), tag.ToUtf8()) ==
+ 0) {
return true;
}
}
diff --git a/src/ui/mapper/MeasureLengthMapper.cpp b/src/ui/mapper/MeasureLengthMapper.cpp
index 0dfcd033..9f5c2a26 100644
--- a/src/ui/mapper/MeasureLengthMapper.cpp
+++ b/src/ui/mapper/MeasureLengthMapper.cpp
@@ -1,19 +1,21 @@
#include "cru/ui/mapper/MeasureLengthMapper.h"
+#include "cru/base/StringUtil.h"
#include "cru/ui/render/MeasureRequirement.h"
namespace cru::ui::mapper {
bool MeasureLengthMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
- return node->GetTag().CaseInsensitiveEqual(u"MeasureLength");
+ return cru::string::CaseInsensitiveCompare(node->GetTag(), "MeasureLength") ==
+ 0;
}
-render::MeasureLength MeasureLengthMapper::DoMapFromString(String str) {
- if (str.CaseInsensitiveEqual(u"notspecified")) {
+render::MeasureLength MeasureLengthMapper::DoMapFromString(std::string str) {
+ if (cru::string::CaseInsensitiveCompare(str, "notspecified") == 0) {
return render::MeasureLength::NotSpecified();
}
- if (str.CaseInsensitiveEqual(u"unspecified")) {
+ if (cru::string::CaseInsensitiveCompare(str, "unspecified") == 0) {
return render::MeasureLength::NotSpecified();
}
- auto value = str.ParseToFloat();
+ auto value = String::FromUtf8(str).ParseToFloat();
if (value < 0) {
return render::MeasureLength::NotSpecified();
}
@@ -22,7 +24,7 @@ render::MeasureLength MeasureLengthMapper::DoMapFromString(String str) {
render::MeasureLength MeasureLengthMapper::DoMapFromXml(
xml::XmlElementNode* node) {
- auto value_attr = node->GetOptionalAttributeValueCaseInsensitive(u"value");
+ auto value_attr = node->GetOptionalAttributeValueCaseInsensitive("value");
if (!value_attr) return {};
return DoMapFromString(*value_attr);
}
diff --git a/src/ui/mapper/PointMapper.cpp b/src/ui/mapper/PointMapper.cpp
index 1bf7defb..16731544 100644
--- a/src/ui/mapper/PointMapper.cpp
+++ b/src/ui/mapper/PointMapper.cpp
@@ -2,11 +2,11 @@
namespace cru::ui::mapper {
bool PointMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
- return node->GetTag().CaseInsensitiveCompare(u"Point") == 0;
+ return cru::string::CaseInsensitiveCompare(node->GetTag(), "Point") == 0;
}
-Point PointMapper::DoMapFromString(String str) {
- std::vector<float> values = str.ParseToFloatList();
+Point PointMapper::DoMapFromString(std::string str) {
+ std::vector<float> values = String::FromUtf8(str).ParseToFloatList();
if (values.size() == 2) {
return {values[0], values[1]};
} else if (values.size() == 1) {
@@ -17,7 +17,7 @@ Point PointMapper::DoMapFromString(String str) {
}
Point PointMapper::DoMapFromXml(xml::XmlElementNode* node) {
- auto value_attr = node->GetOptionalAttributeValueCaseInsensitive(u"value");
+ auto value_attr = node->GetOptionalAttributeValueCaseInsensitive("value");
if (!value_attr) return {};
return DoMapFromString(*value_attr);
}
diff --git a/src/ui/mapper/SizeMapper.cpp b/src/ui/mapper/SizeMapper.cpp
index 7e1bbd91..f976bfe4 100644
--- a/src/ui/mapper/SizeMapper.cpp
+++ b/src/ui/mapper/SizeMapper.cpp
@@ -2,11 +2,11 @@
namespace cru::ui::mapper {
bool SizeMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
- return node->GetTag().CaseInsensitiveCompare(u"Size") == 0;
+ return cru::string::CaseInsensitiveCompare(node->GetTag(), "Size") == 0;
}
-Size SizeMapper::DoMapFromString(String str) {
- std::vector<float> values = str.ParseToFloatList();
+Size SizeMapper::DoMapFromString(std::string str) {
+ std::vector<float> values = String::FromUtf8(str).ParseToFloatList();
if (values.size() == 2) {
return {values[0], values[1]};
} else if (values.size() == 1) {
@@ -17,7 +17,7 @@ Size SizeMapper::DoMapFromString(String str) {
}
Size SizeMapper::DoMapFromXml(xml::XmlElementNode* node) {
- auto value_attr = node->GetOptionalAttributeValueCaseInsensitive(u"value");
+ auto value_attr = node->GetOptionalAttributeValueCaseInsensitive("value");
if (!value_attr) return {};
return DoMapFromString(*value_attr);
}
diff --git a/src/ui/mapper/StringMapper.cpp b/src/ui/mapper/StringMapper.cpp
index 89893ce1..6e224d3f 100644
--- a/src/ui/mapper/StringMapper.cpp
+++ b/src/ui/mapper/StringMapper.cpp
@@ -6,11 +6,13 @@ StringMapper::StringMapper() { SetAllowedTags({u"String"}); }
StringMapper::~StringMapper() {}
-String StringMapper::DoMapFromString(String str) { return std::move(str); }
+String StringMapper::DoMapFromString(std::string str) {
+ return String::FromUtf8(str);
+}
String StringMapper::DoMapFromXml(xml::XmlElementNode* node) {
- auto value_attr = node->GetOptionalAttributeValueCaseInsensitive(u"value");
- if (value_attr) return *value_attr;
+ auto value_attr = node->GetOptionalAttributeValueCaseInsensitive("value");
+ if (value_attr) return String::FromUtf8(*value_attr);
return {};
}
} // namespace cru::ui::mapper
diff --git a/src/ui/mapper/ThicknessMapper.cpp b/src/ui/mapper/ThicknessMapper.cpp
index eed7c651..61c3641c 100644
--- a/src/ui/mapper/ThicknessMapper.cpp
+++ b/src/ui/mapper/ThicknessMapper.cpp
@@ -3,11 +3,11 @@
namespace cru::ui::mapper {
bool ThicknessMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
- return node->GetTag().CaseInsensitiveCompare(u"Thickness") == 0;
+ return cru::string::CaseInsensitiveCompare(node->GetTag(), "Thickness") == 0;
}
-Thickness ThicknessMapper::DoMapFromString(String str) {
- std::vector<float> values = str.ParseToFloatList();
+Thickness ThicknessMapper::DoMapFromString(std::string str) {
+ std::vector<float> values = String::FromUtf8(str).ParseToFloatList();
if (values.size() == 4) {
return Thickness(values[0], values[1], values[2], values[3]);
} else if (values.size() == 2) {
@@ -20,7 +20,7 @@ Thickness ThicknessMapper::DoMapFromString(String str) {
}
Thickness ThicknessMapper::DoMapFromXml(xml::XmlElementNode* node) {
- auto value_attr = node->GetOptionalAttributeValueCaseInsensitive(u"value");
+ auto value_attr = node->GetOptionalAttributeValueCaseInsensitive("value");
if (!value_attr) return {};
return DoMapFromString(*value_attr);
}
diff --git a/src/ui/mapper/style/AndConditionMapper.cpp b/src/ui/mapper/style/AndConditionMapper.cpp
index d57c4927..c1b7e5e5 100644
--- a/src/ui/mapper/style/AndConditionMapper.cpp
+++ b/src/ui/mapper/style/AndConditionMapper.cpp
@@ -7,7 +7,7 @@
namespace cru::ui::mapper::style {
bool AndConditionMapper::XmlElementIsOfThisType(xml::XmlElementNode *node) {
- return node->GetTag().CaseInsensitiveEqual(u"AndCondition");
+ return cru::string::CaseInsensitiveCompare(node->GetTag(), "AndCondition") == 0;
}
ClonablePtr<ui::style::AndCondition> AndConditionMapper::DoMapFromXml(
diff --git a/src/ui/mapper/style/BorderStylerMapper.cpp b/src/ui/mapper/style/BorderStylerMapper.cpp
index e6e33053..e93a0af8 100644
--- a/src/ui/mapper/style/BorderStylerMapper.cpp
+++ b/src/ui/mapper/style/BorderStylerMapper.cpp
@@ -10,7 +10,7 @@ using cru::ui::style::ApplyBorderStyleInfo;
using cru::ui::style::BorderStyler;
bool BorderStylerMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
- return node->GetTag().CaseInsensitiveEqual(u"BorderStyler");
+ return cru::string::CaseInsensitiveCompare(node->GetTag(), "BorderStyler") == 0;
}
ClonablePtr<BorderStyler> BorderStylerMapper::DoMapFromXml(
diff --git a/src/ui/mapper/style/CheckedConditionMapper.cpp b/src/ui/mapper/style/CheckedConditionMapper.cpp
index e33c1113..aafc97a4 100644
--- a/src/ui/mapper/style/CheckedConditionMapper.cpp
+++ b/src/ui/mapper/style/CheckedConditionMapper.cpp
@@ -1,22 +1,24 @@
-#include "cru/base/ClonablePtr.h"
#include "cru/ui/mapper/style/CheckedConditionMapper.h"
+#include "cru/base/ClonablePtr.h"
+#include "cru/base/StringUtil.h"
#include "cru/ui/style/Condition.h"
#include "cru/xml/XmlNode.h"
namespace cru::ui::mapper::style {
bool CheckedConditionMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
- return node->GetTag().CaseInsensitiveEqual(u"CheckedCondition");
+ return cru::string::CaseInsensitiveCompare(node->GetTag(),
+ "CheckedCondition") == 0;
}
ClonablePtr<ui::style::CheckedCondition> CheckedConditionMapper::DoMapFromXml(
xml::XmlElementNode* node) {
- auto value = node->GetAttributeValueCaseInsensitive(u"value");
- if (value.CaseInsensitiveEqual(u"true")) {
+ auto value = node->GetAttributeValueCaseInsensitive("value");
+ if (cru::string::CaseInsensitiveCompare(value, "true") == 0) {
return ui::style::CheckedCondition::Create(true);
- } else if (value.CaseInsensitiveEqual(u"false")) {
+ } else if (cru::string::CaseInsensitiveCompare(value, "false") == 0) {
return ui::style::CheckedCondition::Create(false);
} else {
- throw Exception("Invalid value for CheckedCondition: " + value.ToUtf8());
+ throw Exception("Invalid value for CheckedCondition: " + value);
}
}
} // namespace cru::ui::mapper::style
diff --git a/src/ui/mapper/style/ClickStateConditionMapper.cpp b/src/ui/mapper/style/ClickStateConditionMapper.cpp
index ca1f09c6..badaca85 100644
--- a/src/ui/mapper/style/ClickStateConditionMapper.cpp
+++ b/src/ui/mapper/style/ClickStateConditionMapper.cpp
@@ -1,30 +1,33 @@
#include "cru/ui/mapper/style/ClickStateConditionMapper.h"
#include "cru/base/ClonablePtr.h"
#include "cru/base/Exception.h"
+#include "cru/base/StringUtil.h"
#include "cru/ui/helper/ClickDetector.h"
#include "cru/ui/style/Condition.h"
namespace cru::ui::mapper::style {
bool ClickStateConditionMapper::XmlElementIsOfThisType(
xml::XmlElementNode *node) {
- return node->GetTag().CaseInsensitiveEqual(u"ClickStateCondition");
+ return cru::string::CaseInsensitiveCompare(node->GetTag(),
+ "ClickStateCondition") == 0;
}
ClonablePtr<ui::style::ClickStateCondition>
ClickStateConditionMapper::DoMapFromXml(xml::XmlElementNode *node) {
auto state = helper::ClickState::None;
- auto value_attr = node->GetOptionalAttributeValueCaseInsensitive(u"value");
+ auto value_attr = node->GetOptionalAttributeValueCaseInsensitive("value");
if (value_attr) {
- if (value_attr->CaseInsensitiveEqual(u"none")) {
+ if (cru::string::CaseInsensitiveCompare(*value_attr, "none") == 0) {
state = helper::ClickState::None;
- } else if (value_attr->CaseInsensitiveEqual(u"hover")) {
+ } else if (cru::string::CaseInsensitiveCompare(*value_attr, "hover") == 0) {
state = helper::ClickState::Hover;
- } else if (value_attr->CaseInsensitiveEqual(u"press")) {
+ } else if (cru::string::CaseInsensitiveCompare(*value_attr, "press") == 0) {
state = helper::ClickState::Press;
- } else if (value_attr->CaseInsensitiveEqual(u"pressinactive")) {
+ } else if (cru::string::CaseInsensitiveCompare(*value_attr,
+ "pressinactive") == 0) {
state = helper::ClickState::PressInactive;
} else {
- throw Exception("Unknown click state: " + value_attr->ToUtf8());
+ throw Exception("Unknown click state: " + *value_attr);
}
}
diff --git a/src/ui/mapper/style/CursorStylerMapper.cpp b/src/ui/mapper/style/CursorStylerMapper.cpp
index 3b060c25..c9a75329 100644
--- a/src/ui/mapper/style/CursorStylerMapper.cpp
+++ b/src/ui/mapper/style/CursorStylerMapper.cpp
@@ -6,7 +6,7 @@
namespace cru::ui::mapper::style {
bool CursorStylerMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
- return node->GetTag().CaseInsensitiveEqual(u"CursorStyler");
+ return cru::string::CaseInsensitiveCompare(node->GetTag(), "CursorStyler") == 0;
}
ClonablePtr<ui::style::CursorStyler> CursorStylerMapper::DoMapFromXml(
diff --git a/src/ui/mapper/style/FocusConditionMapper.cpp b/src/ui/mapper/style/FocusConditionMapper.cpp
index 9aa1d6ce..b21ac250 100644
--- a/src/ui/mapper/style/FocusConditionMapper.cpp
+++ b/src/ui/mapper/style/FocusConditionMapper.cpp
@@ -1,22 +1,24 @@
#include "cru/ui/mapper/style/FocusConditionMapper.h"
#include "cru/base/ClonablePtr.h"
+#include "cru/base/StringUtil.h"
#include "cru/ui/style/Condition.h"
#include "cru/xml/XmlNode.h"
namespace cru::ui::mapper::style {
bool FocusConditionMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
- return node->GetTag().CaseInsensitiveEqual(u"FocusCondition");
+ return cru::string::CaseInsensitiveCompare(node->GetTag(),
+ "FocusCondition") == 0;
}
ClonablePtr<ui::style::FocusCondition> FocusConditionMapper::DoMapFromXml(
xml::XmlElementNode* node) {
- auto value = node->GetAttributeValueCaseInsensitive(u"value");
- if (value.CaseInsensitiveEqual(u"true")) {
+ auto value = node->GetAttributeValueCaseInsensitive("value");
+ if (cru::string::CaseInsensitiveCompare(value, "true") == 0) {
return ui::style::FocusCondition::Create(true);
- } else if (value.CaseInsensitiveEqual(u"false")) {
+ } else if (cru::string::CaseInsensitiveCompare(value, "false") == 0) {
return ui::style::FocusCondition::Create(false);
} else {
- throw Exception("Invalid value for FocusCondition: " + value.ToUtf8());
+ throw Exception("Invalid value for FocusCondition: " + value);
}
}
} // namespace cru::ui::mapper::style
diff --git a/src/ui/mapper/style/HoverConditionMapper.cpp b/src/ui/mapper/style/HoverConditionMapper.cpp
index 27565192..1a7ffd95 100644
--- a/src/ui/mapper/style/HoverConditionMapper.cpp
+++ b/src/ui/mapper/style/HoverConditionMapper.cpp
@@ -1,23 +1,25 @@
#include "cru/ui/mapper/style/HoverConditionMapper.h"
#include "cru/base/ClonablePtr.h"
+#include "cru/base/StringUtil.h"
#include "cru/ui/style/Condition.h"
namespace cru::ui::mapper::style {
using namespace cru::ui::style;
bool HoverConditionMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
- return node->GetTag().CaseInsensitiveEqual(u"HoverCondition");
+ return cru::string::CaseInsensitiveCompare(node->GetTag(),
+ "HoverCondition") == 0;
}
ClonablePtr<HoverCondition> HoverConditionMapper::DoMapFromXml(
xml::XmlElementNode* node) {
- auto value = node->GetAttributeValueCaseInsensitive(u"value");
- if (value.CaseInsensitiveEqual(u"true")) {
+ auto value = node->GetAttributeValueCaseInsensitive("value");
+ if (cru::string::CaseInsensitiveCompare(value, "true") == 0) {
return ui::style::HoverCondition::Create(true);
- } else if (value.CaseInsensitiveEqual(u"false")) {
+ } else if (cru::string::CaseInsensitiveCompare(value, "false") == 0) {
return ui::style::HoverCondition::Create(false);
} else {
- throw Exception("Invalid value for HoverCondition: " + value.ToUtf8());
+ throw Exception("Invalid value for HoverCondition: " + value);
}
}
} // namespace cru::ui::mapper::style
diff --git a/src/ui/mapper/style/MarginStylerMapper.cpp b/src/ui/mapper/style/MarginStylerMapper.cpp
index 4c5952bd..0968b53e 100644
--- a/src/ui/mapper/style/MarginStylerMapper.cpp
+++ b/src/ui/mapper/style/MarginStylerMapper.cpp
@@ -14,7 +14,7 @@ ClonablePtr<ui::style::MarginStyler> MarginStylerMapper::DoMapFromXml(
auto thickness_mapper = MapperRegistry::GetInstance()->GetMapper<Thickness>();
- auto value_attribute = node->GetOptionalAttributeValueCaseInsensitive(u"value");
+ auto value_attribute = node->GetOptionalAttributeValueCaseInsensitive("value");
if (value_attribute) {
thickness = thickness_mapper->MapFromString(*value_attribute);
}
diff --git a/src/ui/mapper/style/NoConditionMapper.cpp b/src/ui/mapper/style/NoConditionMapper.cpp
index a36e70d2..d38e187b 100644
--- a/src/ui/mapper/style/NoConditionMapper.cpp
+++ b/src/ui/mapper/style/NoConditionMapper.cpp
@@ -4,7 +4,7 @@
namespace cru::ui::mapper::style {
bool NoConditionMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
- return node->GetTag().CaseInsensitiveEqual(u"NoCondition");
+ return cru::string::CaseInsensitiveCompare(node->GetTag(), "NoCondition") == 0;
}
ClonablePtr<ui::style::NoCondition> NoConditionMapper::DoMapFromXml(
diff --git a/src/ui/mapper/style/OrConditionMapper.cpp b/src/ui/mapper/style/OrConditionMapper.cpp
index 521c57ae..9c983d83 100644
--- a/src/ui/mapper/style/OrConditionMapper.cpp
+++ b/src/ui/mapper/style/OrConditionMapper.cpp
@@ -7,7 +7,7 @@
namespace cru::ui::mapper::style {
bool OrConditionMapper::XmlElementIsOfThisType(xml::XmlElementNode *node) {
- return node->GetTag().CaseInsensitiveEqual(u"OrCondition");
+ return cru::string::CaseInsensitiveCompare(node->GetTag(), "OrCondition") == 0;
}
ClonablePtr<ui::style::OrCondition> OrConditionMapper::DoMapFromXml(
diff --git a/src/ui/mapper/style/PaddingStylerMapper.cpp b/src/ui/mapper/style/PaddingStylerMapper.cpp
index 919669b7..0f0f87d7 100644
--- a/src/ui/mapper/style/PaddingStylerMapper.cpp
+++ b/src/ui/mapper/style/PaddingStylerMapper.cpp
@@ -16,7 +16,8 @@ ClonablePtr<ui::style::PaddingStyler> PaddingStylerMapper::DoMapFromXml(
auto thickness_mapper = MapperRegistry::GetInstance()->GetMapper<Thickness>();
- auto value_attribute = node->GetOptionalAttributeValueCaseInsensitive(u"value");
+ auto value_attribute =
+ node->GetOptionalAttributeValueCaseInsensitive("value");
if (value_attribute) {
thickness = thickness_mapper->MapFromString(*value_attribute);
}
diff --git a/src/ui/mapper/style/PreferredSizeStylerMapper.cpp b/src/ui/mapper/style/PreferredSizeStylerMapper.cpp
index e7cfc35b..2fe71025 100644
--- a/src/ui/mapper/style/PreferredSizeStylerMapper.cpp
+++ b/src/ui/mapper/style/PreferredSizeStylerMapper.cpp
@@ -6,7 +6,7 @@
namespace cru::ui::mapper::style {
bool PreferredSizeStylerMapper::XmlElementIsOfThisType(
xml::XmlElementNode* node) {
- return node->GetTag().CaseInsensitiveEqual(u"PreferredSizeStyler");
+ return cru::string::CaseInsensitiveCompare(node->GetTag(), "PreferredSizeStyler") == 0;
}
ClonablePtr<ui::style::PreferredSizeStyler>
@@ -16,12 +16,12 @@ PreferredSizeStylerMapper::DoMapFromXml(xml::XmlElementNode* node) {
auto measure_length_mapper =
MapperRegistry::GetInstance()->GetMapper<render::MeasureLength>();
- auto width_attribute = node->GetOptionalAttributeValueCaseInsensitive(u"width");
+ auto width_attribute = node->GetOptionalAttributeValueCaseInsensitive("width");
if (width_attribute) {
size.width = measure_length_mapper->MapFromString(*width_attribute);
}
- auto height_attribute = node->GetOptionalAttributeValueCaseInsensitive(u"height");
+ auto height_attribute = node->GetOptionalAttributeValueCaseInsensitive("height");
if (height_attribute) {
size.height = measure_length_mapper->MapFromString(*height_attribute);
}
diff --git a/src/ui/mapper/style/StyleRuleMapper.cpp b/src/ui/mapper/style/StyleRuleMapper.cpp
index f80d27db..345728d2 100644
--- a/src/ui/mapper/style/StyleRuleMapper.cpp
+++ b/src/ui/mapper/style/StyleRuleMapper.cpp
@@ -12,7 +12,7 @@
namespace cru::ui::mapper::style {
using namespace ui::style;
bool StyleRuleMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
- return node->GetTag().CaseInsensitiveEqual(u"StyleRule");
+ return cru::string::CaseInsensitiveCompare(node->GetTag(), "StyleRule") == 0;
}
ClonablePtr<ui::style::StyleRule> StyleRuleMapper::DoMapFromXml(
@@ -49,7 +49,7 @@ ClonablePtr<ui::style::StyleRule> StyleRuleMapper::DoMapFromXml(
}
if (!resolved) {
- throw Exception("Unknown element in StyleRule: " + c->GetTag().ToUtf8());
+ throw Exception("Unknown element in StyleRule: " + c->GetTag());
}
}
}
diff --git a/src/ui/mapper/style/StyleRuleSetMapper.cpp b/src/ui/mapper/style/StyleRuleSetMapper.cpp
index 1067f8f8..d4bc7c37 100644
--- a/src/ui/mapper/style/StyleRuleSetMapper.cpp
+++ b/src/ui/mapper/style/StyleRuleSetMapper.cpp
@@ -8,7 +8,7 @@ namespace cru::ui::mapper::style {
using namespace cru::ui::style;
bool StyleRuleSetMapper::XmlElementIsOfThisType(xml::XmlElementNode* node) {
- return node->GetTag().CaseInsensitiveEqual(u"StyleRuleSet");
+ return cru::string::CaseInsensitiveCompare(node->GetTag(), "StyleRuleSet") == 0;
}
std::shared_ptr<ui::style::StyleRuleSet> StyleRuleSetMapper::DoMapFromXml(
diff --git a/src/xml/XmlNode.cpp b/src/xml/XmlNode.cpp
index 41bbed4d..c9b73c50 100644
--- a/src/xml/XmlNode.cpp
+++ b/src/xml/XmlNode.cpp
@@ -31,7 +31,7 @@ XmlElementNode::~XmlElementNode() {
}
}
-void XmlElementNode::AddAttribute(String key, String value) {
+void XmlElementNode::AddAttribute(std::string key, std::string value) {
attributes_[std::move(key)] = std::move(value);
}
diff --git a/src/xml/XmlParser.cpp b/src/xml/XmlParser.cpp
index 9256dac7..9bfd5441 100644
--- a/src/xml/XmlParser.cpp
+++ b/src/xml/XmlParser.cpp
@@ -1,8 +1,9 @@
#include "cru/xml/XmlParser.h"
+#include "cru/base/StringUtil.h"
#include "cru/xml/XmlNode.h"
namespace cru::xml {
-XmlParser::XmlParser(String xml) : xml_(std::move(xml)) {}
+XmlParser::XmlParser(std::string xml) : xml_(std::move(xml)) {}
XmlParser::~XmlParser() { delete pseudo_root_node_; }
@@ -20,7 +21,7 @@ char16_t XmlParser::Read1() {
return xml_[current_position_++];
}
-String XmlParser::ReadWithoutAdvance(int count) {
+std::string XmlParser::ReadWithoutAdvance(int count) {
if (current_position_ + count > xml_.size()) {
count = xml_.size() - current_position_;
}
@@ -35,8 +36,8 @@ void XmlParser::ReadSpacesAndDiscard() {
}
}
-String XmlParser::ReadSpaces() {
- String spaces;
+std::string XmlParser::ReadSpaces() {
+ std::string spaces;
while (current_position_ < xml_.size() &&
(xml_[current_position_] == ' ' || xml_[current_position_] == '\t' ||
xml_[current_position_] == '\n' || xml_[current_position_] == '\r')) {
@@ -46,8 +47,8 @@ String XmlParser::ReadSpaces() {
return spaces;
}
-String XmlParser::ReadIdenitifier() {
- String identifier;
+std::string XmlParser::ReadIdenitifier() {
+ std::string identifier;
while (current_position_ < xml_.size() &&
(xml_[current_position_] >= 'a' && xml_[current_position_] <= 'z' ||
xml_[current_position_] >= 'A' && xml_[current_position_] <= 'Z' ||
@@ -59,12 +60,12 @@ String XmlParser::ReadIdenitifier() {
return identifier;
}
-String XmlParser::ReadAttributeString() {
+std::string XmlParser::ReadAttributeString() {
if (Read1() != '"') {
throw XmlParsingException("Expected \".");
}
- String string;
+ std::string string;
while (true) {
char16_t c = Read1();
@@ -87,15 +88,15 @@ XmlElementNode* XmlParser::DoParse() {
break;
}
- if (ReadWithoutAdvance() == u"<") {
+ if (ReadWithoutAdvance() == "<") {
current_position_ += 1;
- if (ReadWithoutAdvance() == u"/") {
+ if (ReadWithoutAdvance() == "/") {
current_position_ += 1;
ReadSpacesAndDiscard();
- String tag = ReadIdenitifier();
+ std::string tag = ReadIdenitifier();
if (tag != current_->GetTag()) {
throw XmlParsingException("Tag mismatch.");
@@ -108,23 +109,23 @@ XmlElementNode* XmlParser::DoParse() {
}
current_ = current_->GetParent();
- } else if (ReadWithoutAdvance(3) == u"!--") {
+ } else if (ReadWithoutAdvance(3) == "!--") {
current_position_ += 3;
- String text;
+ std::string text;
while (true) {
auto str = ReadWithoutAdvance(3);
- if (str == u"-->") break;
+ if (str == "-->") break;
if (str.empty()) throw XmlParsingException("Unexpected end of xml");
text += Read1();
}
current_position_ += 3;
- current_->AddChild(new XmlCommentNode(text.Trim()));
+ current_->AddChild(new XmlCommentNode(cru::string::Trim(text)));
} else {
ReadSpacesAndDiscard();
- String tag = ReadIdenitifier();
+ std::string tag = ReadIdenitifier();
XmlElementNode* node = new XmlElementNode(tag);
@@ -133,10 +134,10 @@ XmlElementNode* XmlParser::DoParse() {
while (true) {
ReadSpacesAndDiscard();
auto c = ReadWithoutAdvance();
- if (c == u">") {
+ if (c == ">") {
current_position_ += 1;
break;
- } else if (c == u"/") {
+ } else if (c == "/") {
current_position_ += 1;
if (Read1() != '>') {
@@ -146,7 +147,7 @@ XmlElementNode* XmlParser::DoParse() {
is_self_closing = true;
break;
} else {
- String attribute_name = ReadIdenitifier();
+ std::string attribute_name = ReadIdenitifier();
ReadSpacesAndDiscard();
@@ -156,7 +157,7 @@ XmlElementNode* XmlParser::DoParse() {
ReadSpacesAndDiscard();
- String attribute_value = ReadAttributeString();
+ std::string attribute_value = ReadAttributeString();
node->AddAttribute(attribute_name, attribute_value);
}
@@ -170,15 +171,15 @@ XmlElementNode* XmlParser::DoParse() {
}
} else {
- String text;
+ std::string text;
- while (ReadWithoutAdvance() != u"<") {
+ while (ReadWithoutAdvance() != "<") {
char16_t c = Read1();
text += c;
}
- if (!text.empty()) current_->AddChild(new XmlTextNode(text.TrimEnd()));
+ if (!text.empty()) current_->AddChild(new XmlTextNode(cru::string::TrimEnd(text)));
}
}