52 return value ==
"true";
62 std::ifstream
inFile(file.c_str());
65 const std::string
error =
"Cannot read configuration file " + file +
"! Your current directory is " +
66 std::filesystem::current_path().string() +
"\n" +
67 "For further information on how to run VirtualFluids please visit: "
68 "https://irmb.gitlab-pages.rz.tu-bs.de/VirtualFluids/build-and-run.html#run-the-examples";
70 throw std::invalid_argument(
error);
79 size_t pos = line.find(
'#');
81 if (
pos != std::string::npos) {
82 line = line.substr(0,
pos);
88 size_t pos = line.find(
'=');
90 if (
pos != std::string::npos) {
91 std::string key = trim(line.substr(0,
pos));
92 std::string value = trim(line.substr(
pos + 1));
94 if (!key.empty() && !value.empty()) {
105 return data.find(key) !=
data.end();
110 std::map<std::string, std::string>::const_iterator
iter =
data.find(key);
118std::string ConfigurationFile::trim(
const std::string&
str)
120 size_t first =
str.find_first_not_of(
" \t\n\r");
122 if (
first != std::string::npos) {
123 size_t last =
str.find_last_not_of(
" \t\n\r");
130void ConfigurationFile::split(std::vector<std::string>&
lst,
const std::string&
input,
const std::string&
separators,
133 std::ostringstream
word;
134 for (
size_t n = 0;
n <
input.size(); ++
n) {
#define VF_LOG_TRACE(...)
std::map< std::string, std::string > data
the container is public to test this class
bool contains(const std::string &key) const
check if value associated with given key exists
void load(const std::string &File)
load a configuration file
void clear()
clear all values
T getValue(const std::string &key) const
get value with key
std::shared_ptr< T > SPtr
Simple configuration file.
ConfigurationFile loadConfig(int argc, char *argv[], std::string configPath)
bool convert_to< bool >(const std::string &value)