aboutsummaryrefslogtreecommitdiff
path: root/src/xml
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-01-27 23:28:18 +0800
committercrupest <crupest@outlook.com>2022-01-27 23:28:18 +0800
commitaf43f72adcb6738eebaad505389084c17411a694 (patch)
treee5d729bd8b096b0a66fb70f75e39adc910bd5b32 /src/xml
parent103bcb137273729a0f23ff3771e26150a64454ba (diff)
downloadcru-af43f72adcb6738eebaad505389084c17411a694.tar.gz
cru-af43f72adcb6738eebaad505389084c17411a694.tar.bz2
cru-af43f72adcb6738eebaad505389084c17411a694.zip
...
Diffstat (limited to 'src/xml')
-rw-r--r--src/xml/XmlNode.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/xml/XmlNode.cpp b/src/xml/XmlNode.cpp
index 79847544..00437f9b 100644
--- a/src/xml/XmlNode.cpp
+++ b/src/xml/XmlNode.cpp
@@ -1,4 +1,5 @@
#include "cru/xml/XmlNode.hpp"
+#include <algorithm>
namespace cru::xml {
@@ -32,6 +33,12 @@ void XmlElementNode::AddChild(XmlNode* child) {
child->parent_ = this;
}
+Index XmlElementNode::GetChildElementCount() const {
+ return std::count_if(
+ children_.cbegin(), children_.cend(),
+ [](xml::XmlNode* node) { return node->IsElementNode(); });
+}
+
XmlElementNode* XmlElementNode::GetFirstChildElement() const {
for (auto child : children_) {
if (child->GetType() == XmlNode::Type::Element) {