From 25c1286925b2dfb7afa2859b5e68e4fe969c8c93 Mon Sep 17 00:00:00 2001 From: Christoph Lehmann <christoph.lehmann@ufz.de> Date: Sat, 23 Jan 2016 22:08:42 +0100 Subject: [PATCH] [BL] minor fix --- BaseLib/ConfigTreeNew-impl.h | 5 +++-- BaseLib/ConfigTreeNew.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/BaseLib/ConfigTreeNew-impl.h b/BaseLib/ConfigTreeNew-impl.h index fc3213d6d9a..fa006aa0db7 100644 --- a/BaseLib/ConfigTreeNew-impl.h +++ b/BaseLib/ConfigTreeNew-impl.h @@ -144,10 +144,11 @@ ConfigTreeNew:: getConfAttribute(std::string const& attr) const { checkUniqueAttr(attr); - markVisited<T>(attr, true); + auto& ct = markVisited<T>(attr, true, true); if (auto attrs = _tree->get_child_optional("<xmlattr>")) { if (auto a = attrs->get_child_optional(attr)) { + ++ct.count; // count only if attribute has been found if (auto v = a->get_value_optional<T>()) { return *v; } else { @@ -156,7 +157,7 @@ getConfAttribute(std::string const& attr) const + "' not convertible to the desired type."); } } else { - error("No XML attribute named \"" + attr + "\""); + error("Did not find XML attribute with name \"" + attr + "\""); } } else { error("This parameter has no XML attributes"); diff --git a/BaseLib/ConfigTreeNew.cpp b/BaseLib/ConfigTreeNew.cpp index 67aef29c99c..8d461e2233a 100644 --- a/BaseLib/ConfigTreeNew.cpp +++ b/BaseLib/ConfigTreeNew.cpp @@ -85,6 +85,16 @@ getConfParam(std::string const& root) const return ct; } +boost::optional<ConfigTreeNew> +ConfigTreeNew:: +getConfParamOptional(std::string const& root) const +{ + auto ct = getConfSubtreeOptional(root); + if (ct && hasChildren(*ct)) + error("Requested parameter <" + root + "> actually is a subtree."); + return ct; +} + ConfigTreeNew ConfigTreeNew:: getConfSubtree(std::string const& root) const -- GitLab