diff options
author | crupest <crupest@outlook.com> | 2022-01-19 23:14:21 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-01-19 23:14:21 +0800 |
commit | 31422f87f729bd35bcebfb277d08b230424e3618 (patch) | |
tree | f4479c6da9dcc64a9a39e165ed0459efff051eb3 /include/cru/xml/XmlNode.hpp | |
parent | 2028bc4914638360fb756079dbddbdbe52676821 (diff) | |
download | cru-31422f87f729bd35bcebfb277d08b230424e3618.tar.gz cru-31422f87f729bd35bcebfb277d08b230424e3618.tar.bz2 cru-31422f87f729bd35bcebfb277d08b230424e3618.zip |
...
Diffstat (limited to 'include/cru/xml/XmlNode.hpp')
-rw-r--r-- | include/cru/xml/XmlNode.hpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/cru/xml/XmlNode.hpp b/include/cru/xml/XmlNode.hpp index 38f09d14..0972037a 100644 --- a/include/cru/xml/XmlNode.hpp +++ b/include/cru/xml/XmlNode.hpp @@ -90,6 +90,14 @@ class CRU_XML_API XmlElementNode : public XmlNode { Index GetChildCount() const { return children_.size(); } String GetAttribute(const String& key) const { return attributes_.at(key); } + std::optional<String> GetOptionalAttribute(const String& key) const { + auto it = attributes_.find(key); + if (it == attributes_.end()) { + return std::nullopt; + } + + return it->second; + } XmlNode* GetChildAt(Index index) const { return children_[index]; } void AddAttribute(String key, String value); |