From 2bffc33452e01d1197a723f778db4f36864ec24b Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 10 Oct 2018 09:33:29 -0500 Subject: [PATCH] Adding get_child_nodes function to C++ xml_interface. --- include/openmc/xml_interface.h | 7 +++++++ src/xml_interface.cpp | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/openmc/xml_interface.h b/include/openmc/xml_interface.h index 85db26faa3..8bf0f21749 100644 --- a/include/openmc/xml_interface.h +++ b/include/openmc/xml_interface.h @@ -50,5 +50,12 @@ xt::xarray get_node_xarray(pugi::xml_node node, const char* name, return xt::adapt(v, shape); } +//=============================================================================== +// GET_NODE_LIST is used to get a pointer to a list of sub-element nodes +//=============================================================================== + +std::vector +get_child_nodes(pugi::xml_node node, const char* name); + } // namespace openmc #endif // OPENMC_XML_INTERFACE_H diff --git a/src/xml_interface.cpp b/src/xml_interface.cpp index 60ae7ffcab..c9b7bbcab3 100644 --- a/src/xml_interface.cpp +++ b/src/xml_interface.cpp @@ -56,4 +56,20 @@ get_node_value_bool(pugi::xml_node node, const char* name) return false; } + + +std::vector +get_child_nodes(pugi::xml_node node, const char* name) +{ + pugi::xml_node current; + std::vector node_list; + + for (pugi::xml_node current : node.children(name)) { + node_list.push_back(current); + } + + return node_list; +} + + } // namespace openmc