1#ifndef COOLPROP_CONFIGURATION
2#define COOLPROP_CONFIGURATION
7#include <unordered_map>
56 operator bool()
const {
61 operator double()
const {
66 operator std::string()
const {
71 operator int()
const {
123 if (type != this->type) {
134 std::string v_string;
141 std::unordered_map<configuration_keys, ConfigurationItem>
items;
152 auto it =
items.find(key);
154 if (it !=
items.end()) {
163 std::pair<configuration_keys, ConfigurationItem> pair(item.
get_key(), item);
168 std::unordered_map<configuration_keys, ConfigurationItem>&
get_items() {
175 const char* envval = std::getenv(envkey.c_str());
177 auto tobool = [](
const std::string& x) {
178 if (x ==
"True" || x ==
"true") {
181 if (x ==
"False" || x ==
"false") {
194 i = std::stoi(envval);
197 std::string msg =
"Unable to convert \"" + std::string(envval) +
"\" to int for key [" + skey +
"]";
198 std::cerr << msg <<
'\n';
208 d = std::stod(envval);
211 std::string msg =
"Unable to convert \"" + std::string(envval) +
"\" to double for key [" + skey +
"]";
212 std::cerr << msg <<
'\n';
225 std::string msg =
"Unable to convert \"" + std::string(envval) +
"\" to bool for key [" + skey +
"]";
226 std::cerr << msg <<
'\n';
235 throw ValueError(
"This key [" + skey +
"] has the wrong type; value was " + std::string(envval) +
" ");
249#define X(Enum, String, Default, Desc) add_item(ConfigurationItem(Enum, Default));
254#define X(Enum, String, Default, Desc) possibly_set_from_env(Enum);