MCPcopy Create free account
hub / github.com/CoolProp/CoolProp / item_to_json

Function item_to_json

src/Configuration.cpp:7–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5namespace {
6
7void item_to_json(const CoolProp::ConfigurationItem& item, nlohmann::json& obj) {
8 const std::string name = CoolProp::config_key_to_string(item.get_key());
9 switch (item.get_type()) {
10 case CONFIGURATION_BOOL_TYPE:
11 obj[name] = static_cast<bool>(item);
12 break;
13 case CONFIGURATION_INTEGER_TYPE:
14 obj[name] = static_cast<int>(item);
15 break;
16 case CONFIGURATION_DOUBLE_TYPE:
17 obj[name] = static_cast<double>(item);
18 break;
19 case CONFIGURATION_STRING_TYPE:
20 obj[name] = static_cast<std::string>(item);
21 break;
22 case CONFIGURATION_ENDOFLIST_TYPE:
23 case CONFIGURATION_NOT_DEFINED_TYPE:
24 throw CoolProp::ValueError();
25 }
26}
27
28void item_from_json(CoolProp::ConfigurationItem& item, const nlohmann::json& val) {
29 switch (item.get_type()) {

Callers 1

Calls 3

config_key_to_stringFunction · 0.85
get_keyMethod · 0.80
get_typeMethod · 0.80

Tested by

no test coverage detected