Template Function utils::getTOMLKeyWithError
Defined in File ParseUtils.hpp
Function Documentation
-
template<class T>
auto utils::getTOMLKeyWithError(const toml::table &inputDeck, const std::string &key, bool required = false) -> std::optional<T> Check for TOML key of type and return error if type is wrong.
This routine checks if the input key exists and can be retrieved as of type T. Behavior is as follows: (1) if the key exists and can be interpreted as type T, return a full optional<T>; (2) if the key exists and cannot be interpreted as T, throw a runtime error; (3) if the key does not exist and required is false, return ane empty optional; (4) if the key does not exist and required is true, throw a runtime error.
- Template Parameters:
T – The type to check for
- Parameters:
inputDeck – Input deck for simulation
key – Name of key
required – True if key is required