Permalink
Browse files

Validation fixes

  • Loading branch information...
1 parent 71aaf01 commit 1d2df659efa4ded89c5d24e8876cb6dcf3d9a4ec @saleyn committed Jul 15, 2014
Showing with 10 additions and 2 deletions.
  1. +1 −2 bin/config_validator_codegen.py
  2. +7 −0 include/utxx/variant_tree.hpp
  3. +2 −0 src/config_validator.cpp
@@ -368,8 +368,7 @@ def run(self):
f.write(" friend class config::validator;\n\n")
f.write(" virtual ~%s() {}\n\n" % name)
f.write(" %s() {\n" % name)
- f.write(' m_root = "%s";\n' % root.attrib['namespace'])
-
+ f.write(' m_root = "%s";\n' % (root.attrib['root'] if root.attrib.get('root') else ""))
self.process_options(f, root)
@@ -514,6 +514,13 @@ class basic_variant_tree : public basic_variant_tree_base<Ch>
/// Validate content of this tree against the custom validator
/// @param a_schema if not NULL use this schema validator otherwise
/// use internal validator().
+ void validate(const config::custom_validator& a_custom_validator) const {
+ validate(NULL, a_custom_validator);
+ }
+
+ /// Validate content of this tree against the custom validator
+ /// @param a_schema if not NULL use this schema validator otherwise
+ /// use internal validator().
void validate(
const config::validator* a_schema = NULL,
const config::custom_validator& a_custom_validator = NULL
@@ -145,6 +145,8 @@ strip_root(const tree_path& a_root_path) const throw(variant_tree_error)
if (s.size() < r.size())
throw variant_tree_error(a_root_path, "Path is shorter than root!");
+ if (r.empty())
+ return a_root_path;
if (s.substr(0, r.size()) != r || (s.size() > r.size() && s[r.size()] != sep))
throw variant_tree_error(a_root_path, "Sub-path not found in root path");

0 comments on commit 1d2df65

Please sign in to comment.