diff --git a/DesignEvaluator/src/main.cpp b/DesignEvaluator/src/main.cpp index 313bf3e6ccf1cbe88be04b1cc90edbed3a7fd45f..9b3c765bcadc2a1d51263665aa9e37f6c22fda1b 100644 --- a/DesignEvaluator/src/main.cpp +++ b/DesignEvaluator/src/main.cpp @@ -3,9 +3,9 @@ #include <boost/property_tree/xml_parser.hpp> #include <boost/property_tree/ptree.hpp> -void printNodeNames(const boost::property_tree::ptree& tree, const std::string& indent = "") { +void printNodeNames(const boost::property_tree::ptree& myPtree, const std::string& indent = "") { // Iterate through each child node of the given tree - for (const auto& node : tree) { + for (const auto& node : myPtree) { // Print the node's name std::cout << indent << node.first; @@ -23,14 +23,28 @@ void printNodeNames(const boost::property_tree::ptree& tree, const std::string& } } -int containsSymbol(const std::string& myString, const std::string& mySymbol) { - if (myString.find(mySymbol) != std::string::npos) { +int containsSymbol(const std::string& my_string, const std::string& my_symbol) { + if (my_string.find(my_symbol) != std::string::npos) { return 1; } else { return 0; } } +boost::property_tree::ptree extractNodesFromPtree(const boost::property_tree::ptree& ptree, const std::string& target_node) { + boost::property_tree::ptree reduced_ptree{}; + + for (const auto& parent_node : ptree) { + if (parent_node.first == target_node) { + reduced_ptree.add_child(parent_node.first, parent_node.second); + } + boost::property_tree::ptree myPtree{}; + myPtree = extractNodesFromPtree(parent_node.second, target_node); + } + + return reduced_ptree; +} + enum State { DefiningFilePaths, LoadingXMLsIntoTrees, @@ -119,16 +133,17 @@ int main () { std::cout << "Current State: " << state << std::endl; // Iterate through the children of <ConfigFile.ProgramSettings.Parameters> - for (const boost::property_tree::ptree::value_type& parent_nodes : config_tree.get_child("ConfigFile.ProgramSettings.Parameters")) { - boost::property_tree::ptree temporary_tree{}; - // Iterate through the children of parent_node - for (const auto &child_nodes : parent_nodes.second) { - if (child_nodes.first == "SubPath") { - temporary_tree.add_child(child_nodes.first, child_nodes.second); - } - } - reduced_config_tree.add_child(parent_nodes.first, temporary_tree); - } + // for (const boost::property_tree::ptree::value_type& parent_nodes : config_tree.get_child("ConfigFile.ProgramSettings.Parameters")) { + // boost::property_tree::ptree temporary_tree{}; + // // Iterate through the children of parent_node + // for (const auto &child_nodes : parent_nodes.second) { + // if (child_nodes.first == "SubPath") { + // temporary_tree.add_child(child_nodes.first, child_nodes.second); + // } + // } + // reduced_config_tree.add_child(parent_nodes.first, temporary_tree); + // } + reduced_config_tree = extractNodesFromPtree(config_tree, "SubPath"); // printNodeNames(reduced_config_tree); state = State::SubstractingNodeValues; break;