summaryrefslogtreecommitdiff
path: root/lib/element.cpp
diff options
context:
space:
mode:
authorJosh Blum2013-03-22 01:58:34 -0700
committerJosh Blum2013-03-22 01:58:34 -0700
commit854cb19d99e8cce67fd30c5cfc78c02bbeb3bcd2 (patch)
tree683f0dc5699f936dc5e2d5e34849ffca0298bbae /lib/element.cpp
parent9ea77e78ade12ed5402ed9f3df1f10d9d4d27559 (diff)
downloadsandhi-854cb19d99e8cce67fd30c5cfc78c02bbeb3bcd2.tar.gz
sandhi-854cb19d99e8cce67fd30c5cfc78c02bbeb3bcd2.tar.bz2
sandhi-854cb19d99e8cce67fd30c5cfc78c02bbeb3bcd2.zip
gras: added extra sanity check to adopt call
Diffstat (limited to 'lib/element.cpp')
-rw-r--r--lib/element.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/element.cpp b/lib/element.cpp
index e6c8499..cc16fdf 100644
--- a/lib/element.cpp
+++ b/lib/element.cpp
@@ -59,7 +59,14 @@ void Element::adopt_element(const std::string &name, const Element &child)
% child.to_string()
% child->parent.to_string()
));
- //TODO check name not already taken
+
+ if ((*this)->children.count(name)) throw std::invalid_argument(str(boost::format(
+ "A child of name %s already registered to element %s"
+ )
+ % child.to_string()
+ % this->to_string()
+ ));
+
child->parent = *this;
(*this)->children[name] = child;
}