diff options
author | An-Cheng Huang <ancheng@vyatta.com> | 2010-11-17 19:19:51 -0800 |
---|---|---|
committer | An-Cheng Huang <ancheng@vyatta.com> | 2010-11-17 19:19:51 -0800 |
commit | 6c21b63190de70898ee4eacd66687d9759242331 (patch) | |
tree | 530df0166eb0ce54f1d048330653a635a1cd6882 /src/cnode/cnode.cpp | |
parent | 1a2eac7485f52d93e1334a3818e5a4d420709db2 (diff) | |
download | vyatta-cfg-6c21b63190de70898ee4eacd66687d9759242331.tar.gz vyatta-cfg-6c21b63190de70898ee4eacd66687d9759242331.zip |
continue work on parser/output framework
* handle empty and leaf typeless nodes from parsed nodes.
* fix bug 6436 show level issue.
Diffstat (limited to 'src/cnode/cnode.cpp')
-rw-r--r-- | src/cnode/cnode.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/cnode/cnode.cpp b/src/cnode/cnode.cpp index 05dc07a..697c89b 100644 --- a/src/cnode/cnode.cpp +++ b/src/cnode/cnode.cpp @@ -26,16 +26,12 @@ using namespace std; using namespace cnode; -/* XXX - delayed processing for _is_empty, _is_leaf_typeless - */ - ////// constructors/destructors CfgNode::CfgNode(vector<string>& path_comps, char *name, char *val, char *comment, int deact, Cstore *cstore) : _is_tag(false), _is_leaf(false), _is_multi(false), _is_value(false), _is_default(false), _is_deactivated(false), _is_leaf_typeless(false), - _is_invalid(false), _is_empty(false) + _is_invalid(false), _is_empty(true), _exists(true) { if (name && name[0]) { // name must be non-empty @@ -77,6 +73,14 @@ CfgNode::CfgNode(vector<string>& path_comps, char *name, char *val, _value = val; } } + + vector<string> tcnodes; + cstore->tmplGetChildNodes(path_comps, tcnodes); + if (tcnodes.size() == 0) { + // typeless leaf node + _is_leaf_typeless = true; + } + if (comment) { _comment = comment; } @@ -103,12 +107,18 @@ CfgNode::CfgNode(Cstore& cstore, vector<string>& path_comps, bool active, bool recursive) : _is_tag(false), _is_leaf(false), _is_multi(false), _is_value(false), _is_default(false), _is_deactivated(false), _is_leaf_typeless(false), - _is_invalid(false), _is_empty(false) + _is_invalid(false), _is_empty(false), _exists(true) { /* first get the def (only if path is not empty). if path is empty, i.e., * "root", treat it as an intermediate node. */ if (path_comps.size() > 0) { + if (!cstore.cfgPathExists(path_comps, active)) { + // path doesn't exist + _exists = false; + return; + } + vtw_def def; if (cstore.validateTmplPath(path_comps, false, def)) { // got the def |