From 491b4c361f3a612835e76604fbd751e6e6905c3d Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Sat, 30 Apr 2011 21:42:12 +0800 Subject: preliminary implementation of new commit (cherry picked from commit 1b2a0fd1ae1e6dfc18e4f75f73cd7befb47cf538) --- src/cnode/cnode-algorithm.hpp | 53 +++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 14 deletions(-) (limited to 'src/cnode/cnode-algorithm.hpp') diff --git a/src/cnode/cnode-algorithm.hpp b/src/cnode/cnode-algorithm.hpp index 547b55c..509f875 100644 --- a/src/cnode/cnode-algorithm.hpp +++ b/src/cnode/cnode-algorithm.hpp @@ -17,12 +17,34 @@ #ifndef _CNODE_ALGORITHM_HPP_ #define _CNODE_ALGORITHM_HPP_ +#include +#include + +#include #include namespace cnode { +enum DiffState { + DIFF_ADD, + DIFF_DEL, + DIFF_UPD, + DIFF_NONE, + DIFF_NULL +}; + +bool cmp_multi_values(const CfgNode *cfg1, const CfgNode *cfg2, + std::vector& values, + std::vector& pfxs); +void cmp_non_leaf_nodes(const CfgNode *cfg1, const CfgNode *cfg2, + std::vector& rcnodes1, + std::vector& rcnodes2, + bool& not_tag_node, bool& is_value, + bool& is_leaf_typeless, std::string& name, + std::string& value); + void show_cfg_diff(const CfgNode& cfg1, const CfgNode& cfg2, - Cpath& cur_path, bool show_def = false, + cstore::Cpath& cur_path, bool show_def = false, bool hide_secret = false, bool context_diff = false); void show_cfg(const CfgNode& cfg, bool show_def = false, bool hide_secret = false); @@ -31,24 +53,27 @@ void show_cmds_diff(const CfgNode& cfg1, const CfgNode& cfg2); void show_cmds(const CfgNode& cfg); void get_cmds_diff(const CfgNode& cfg1, const CfgNode& cfg2, - vector& del_list, vector& set_list, - vector& com_list); -void get_cmds(const CfgNode& cfg, vector& set_list, - vector& com_list); + std::vector& del_list, + std::vector& set_list, + std::vector& com_list); +void get_cmds(const CfgNode& cfg, std::vector& set_list, + std::vector& com_list); -extern const string ACTIVE_CFG; -extern const string WORKING_CFG; +extern const std::string ACTIVE_CFG; +extern const std::string WORKING_CFG; -void showConfig(const string& cfg1, const string& cfg2, - const Cpath& path, bool show_def = false, +void showConfig(const std::string& cfg1, const std::string& cfg2, + const cstore::Cpath& path, bool show_def = false, bool hide_secret = false, bool context_diff = false, bool show_cmds = false, bool ignore_edit = false); -CfgNode *findCfgNode(CfgNode *root, const Cpath& path, bool& is_value); -CfgNode *findCfgNode(CfgNode *root, const Cpath& path); -bool getCfgNodeValue(CfgNode *root, const Cpath& path, string& value); -bool getCfgNodeValues(CfgNode *root, const Cpath& path, - vector& values); +CfgNode *findCfgNode(CfgNode *root, const cstore::Cpath& path, + bool& is_value); +CfgNode *findCfgNode(CfgNode *root, const cstore::Cpath& path); +bool getCfgNodeValue(CfgNode *root, const cstore::Cpath& path, + std::string& value); +bool getCfgNodeValues(CfgNode *root, const cstore::Cpath& path, + std::vector& values); } // namespace cnode -- cgit v1.2.3