From 31422f87f729bd35bcebfb277d08b230424e3618 Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 19 Jan 2022 23:14:21 +0800 Subject: ... --- include/cru/xml/XmlNode.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/cru/xml/XmlNode.hpp') 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 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); -- cgit v1.2.3