summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--project2/common/scripts.cpp9
-rw-r--r--project2/common/scripts.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/project2/common/scripts.cpp b/project2/common/scripts.cpp
index a7a6c23..2b52db5 100644
--- a/project2/common/scripts.cpp
+++ b/project2/common/scripts.cpp
@@ -1,4 +1,5 @@
#include "scripts.h"
+#include <algorithm>
#include "variables/fixed.h"
#include <boost/filesystem/convenience.hpp>
#include <boost/tuple/tuple_comparison.hpp>
@@ -32,6 +33,14 @@ ScriptNode::variable(const Glib::ustring & n, const VariableType & def) const
}
}
+ScriptNode::ScriptNodes
+ScriptNode::children(const Glib::ustring & name) const
+{
+ auto nodes = children();
+ nodes.erase(std::remove_if(nodes.begin(), nodes.end(), [&name](const ScriptNodePtr & n) { return n->get_name() != name; }), nodes.end());
+ return nodes;
+}
+
VariableType
ScriptNode::value(const Glib::ustring & n, const VariableType & def, ExecContext * ec) const
{
diff --git a/project2/common/scripts.h b/project2/common/scripts.h
index 92151f6..7d43a01 100644
--- a/project2/common/scripts.h
+++ b/project2/common/scripts.h
@@ -43,6 +43,7 @@ class ScriptNode : public IntrusivePtrBase {
virtual ScriptNodePtr child(const Glib::ustring & name, bool required = true) const = 0;
// All children
virtual ScriptNodes children() const = 0;
+ virtual ScriptNodes children(const Glib::ustring & name) const;
// All children in sub
virtual ScriptNodes childrenIn(const Glib::ustring & sub) const = 0;