aboutsummaryrefslogtreecommitdiff
path: root/include/cru/xml
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-01-23 21:07:03 +0800
committercrupest <crupest@outlook.com>2022-01-23 21:07:03 +0800
commitda9bdf2baced1ff51350c98047b7ade68fcae930 (patch)
treec51b9c8538c82b19d142eb1340e6dac0e88ff4e4 /include/cru/xml
parent13860c88910c00478abe3001cc80125e76767381 (diff)
downloadcru-da9bdf2baced1ff51350c98047b7ade68fcae930.tar.gz
cru-da9bdf2baced1ff51350c98047b7ade68fcae930.tar.bz2
cru-da9bdf2baced1ff51350c98047b7ade68fcae930.zip
...
Diffstat (limited to 'include/cru/xml')
-rw-r--r--include/cru/xml/XmlNode.hpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/cru/xml/XmlNode.hpp b/include/cru/xml/XmlNode.hpp
index 71753410..c9e538c0 100644
--- a/include/cru/xml/XmlNode.hpp
+++ b/include/cru/xml/XmlNode.hpp
@@ -91,6 +91,9 @@ class CRU_XML_API XmlElementNode : public XmlNode {
Index GetChildCount() const { return children_.size(); }
String GetAttribute(const String& key) const { return attributes_.at(key); }
+ String GetAttributeCaseInsensitive(const String& key) const {
+ return *GetOptionalAttributeCaseInsensitive(key);
+ }
std::optional<String> GetOptionalAttribute(const String& key) const {
auto it = attributes_.find(key);
if (it == attributes_.end()) {
@@ -99,6 +102,17 @@ class CRU_XML_API XmlElementNode : public XmlNode {
return it->second;
}
+ std::optional<String> GetOptionalAttributeCaseInsensitive(
+ const String& key) const {
+ for (auto it = attributes_.begin(); it != attributes_.end(); ++it) {
+ if (it->first.CaseInsensitiveCompare(key) == 0) {
+ return it->second;
+ }
+ }
+
+ return std::nullopt;
+ }
+
XmlNode* GetChildAt(Index index) const { return children_[index]; }
void AddAttribute(String key, String value);