From 24b3de8987f622b349cbe14dca99594f2c279902 Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Mon, 28 Feb 2011 18:25:01 -0800 Subject: add config template abstraction --- src/cnode/cnode.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src/cnode') diff --git a/src/cnode/cnode.cpp b/src/cnode/cnode.cpp index c88a495..f484fb1 100644 --- a/src/cnode/cnode.cpp +++ b/src/cnode/cnode.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -49,15 +50,15 @@ CfgNode::CfgNode(vector& path_comps, char *name, char *val, break; } - vtw_def def; - if (cstore->validateTmplPath(path_comps, false, def)) { + auto_ptr def(cstore->parseTmpl(path_comps, false)); + if (def.get()) { // got the def - _is_tag = def.tag; - _is_leaf = (!def.tag && def.def_type != ERROR_TYPE); + _is_tag = def->isTag(); + _is_leaf = (!_is_tag && !def->isTypeless()); // match constructor from cstore (leaf node never _is_value) - _is_value = (def.is_value && !_is_leaf); - _is_multi = def.multi; + _is_value = (def->isValue() && !_is_leaf); + _is_multi = def->isMulti(); /* XXX given the current definition of "default", the concept of * "default" doesn't really apply to config files. @@ -123,8 +124,8 @@ CfgNode::CfgNode(Cstore& cstore, vector& path_comps, * "root", treat it as an intermediate node. */ if (path_comps.size() > 0) { - vtw_def def; - if (cstore.validateTmplPath(path_comps, false, def)) { + auto_ptr def(cstore.parseTmpl(path_comps, false)); + if (def.get()) { // got the def if (!cstore.cfgPathExists(path_comps, active)) { // path doesn't exist @@ -132,10 +133,10 @@ CfgNode::CfgNode(Cstore& cstore, vector& path_comps, return; } - _is_value = def.is_value; - _is_tag = def.tag; - _is_leaf = (!def.tag && def.def_type != ERROR_TYPE); - _is_multi = def.multi; + _is_value = def->isValue(); + _is_tag = def->isTag(); + _is_leaf = (!_is_tag && !def->isTypeless()); + _is_multi = def->isMulti(); _is_default = cstore.cfgPathDefault(path_comps, active); _is_deactivated = cstore.cfgPathDeactivated(path_comps, active); cstore.cfgPathGetComment(path_comps, _comment, active); -- cgit v1.2.3