diff options
author | An-Cheng Huang <ancheng@vyatta.com> | 2010-08-26 16:46:07 -0700 |
---|---|---|
committer | An-Cheng Huang <ancheng@vyatta.com> | 2010-08-26 16:46:07 -0700 |
commit | 17f19681974fb4399d36ac43006efac9828dc5b9 (patch) | |
tree | a491beecb346149b4342cc3aaaa329ff8fe36517 /src/cstore | |
parent | ee6ed3b3869aa0b84c9c4f732f60dbbe31f414a0 (diff) | |
download | vyatta-cfg-17f19681974fb4399d36ac43006efac9828dc5b9.tar.gz vyatta-cfg-17f19681974fb4399d36ac43006efac9828dc5b9.zip |
don't show extra empty level for typeless leaf nodes.
Diffstat (limited to 'src/cstore')
-rw-r--r-- | src/cstore/cstore-node.cpp | 23 | ||||
-rw-r--r-- | src/cstore/cstore-node.hpp | 1 |
2 files changed, 17 insertions, 7 deletions
diff --git a/src/cstore/cstore-node.cpp b/src/cstore/cstore-node.cpp index 85d2fda..a67f291 100644 --- a/src/cstore/cstore-node.cpp +++ b/src/cstore/cstore-node.cpp @@ -47,6 +47,7 @@ CstoreCfgNode::CstoreCfgNode(Cstore& cstore, vector<string>& path_comps, _pfx_deact(PFX_DEACT_NONE.c_str()), _is_tag(false), _is_leaf(false), _is_multi(false), _is_value(false), _is_default(false), _is_invalid(false), _is_empty(false), + _is_leaf_typeless(false), _active_only(false), _comment(""), _comment_status(ST_STATIC) { init(); @@ -208,6 +209,12 @@ CstoreCfgNode::CstoreCfgNode(Cstore& cstore, vector<string>& path_comps, } if (cmap.empty()) { // empty subtree. finished. + vector<string> tcnodes; + _cstore->tmplGetChildNodes(path_comps, tcnodes); + if (tcnodes.size() == 0) { + // typeless leaf node + _is_leaf_typeless = true; + } _is_empty = true; return; } @@ -294,14 +301,16 @@ CstoreCfgNode::show(int level, bool show_def, bool hide_secret) // at tag value and there is a tag node parent => print node name printf("%s ", _tag_name.c_str()); } - printf("%s {\n", _name.c_str()); - } - for (size_t i = 0; i < _child_nodes.size(); i++) { - _child_nodes[i]->show(level + 1, show_def, hide_secret); + printf("%s%s\n", _name.c_str(), (_is_leaf_typeless ? "" : " {")); } - if (print_this) { - print_indent(level); - printf("}\n"); + if (!_is_leaf_typeless) { + for (size_t i = 0; i < _child_nodes.size(); i++) { + _child_nodes[i]->show(level + 1, show_def, hide_secret); + } + if (print_this) { + print_indent(level); + printf("}\n"); + } } } } diff --git a/src/cstore/cstore-node.hpp b/src/cstore/cstore-node.hpp index a7aa865..f58da4e 100644 --- a/src/cstore/cstore-node.hpp +++ b/src/cstore/cstore-node.hpp @@ -79,6 +79,7 @@ private: bool _is_default; bool _is_invalid; bool _is_empty; + bool _is_leaf_typeless; bool _active_only; string _tag_name; string _value; |