mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Move headers to include/openmc directory and openmc.h -> openmc/capi.h
This commit is contained in:
parent
1f760461a3
commit
9f0ea52d1a
83 changed files with 283 additions and 261 deletions
42
include/openmc/xml_interface.h
Normal file
42
include/openmc/xml_interface.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#ifndef OPENMC_XML_INTERFACE_H
|
||||
#define OPENMC_XML_INTERFACE_H
|
||||
|
||||
#include <sstream> // for stringstream
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "pugixml.hpp"
|
||||
|
||||
|
||||
namespace openmc {
|
||||
|
||||
inline bool
|
||||
check_for_node(pugi::xml_node node, const char *name)
|
||||
{
|
||||
return node.attribute(name) || node.child(name);
|
||||
}
|
||||
|
||||
std::string get_node_value(pugi::xml_node node, const char* name,
|
||||
bool lowercase=false, bool strip=false);
|
||||
|
||||
bool get_node_value_bool(pugi::xml_node node, const char* name);
|
||||
|
||||
template <typename T>
|
||||
std::vector<T> get_node_array(pugi::xml_node node, const char* name,
|
||||
bool lowercase=false)
|
||||
{
|
||||
// Get value of node attribute/child
|
||||
std::string s {get_node_value(node, name, lowercase)};
|
||||
|
||||
// Read values one by one into vector
|
||||
std::stringstream iss {s};
|
||||
T value;
|
||||
std::vector<T> values;
|
||||
while (iss >> value)
|
||||
values.push_back(value);
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
} // namespace openmc
|
||||
#endif // OPENMC_XML_INTERFACE_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue