Skip to content

Commit

Permalink
Fix #138: make oxpy's get_bool() to handle non-lowercase booleans (#139)
Browse files Browse the repository at this point in the history
Make all boolean input lowercase, making it possible to have True, TRUE or similar values in input files.
This is the behavior of the C++ code.
  • Loading branch information
elija-feigl authored Oct 30, 2024
1 parent b191c3d commit 208049d
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions oxpy/bindings_includes/input_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,9 @@ To check if a specific option has been set you can use `in`::
)pbdoc");

input.def("get_bool", [](input_file &inp, std::string &key) {
bool found;
if (inp.true_values.find(inp.get_value(key, 0, found)) != inp.true_values.end()) {
return true;
}
else {
if (inp.false_values.find(inp.get_value(key, 0, found)) != inp.false_values.end()){
return false;
}
else {
throw std::invalid_argument("boolean key " + key + " is invalid");
}
}
bool res;
getInputBool(&inp, key.c_str(), &res, 0);
return res;
}, R"pbdoc(
Return the boolean value of an input option.
Expand Down

0 comments on commit 208049d

Please sign in to comment.