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

Function add_fluids_from_JSON_string

src/Backends/PCSAFT/PCSAFTLibrary.cpp:31–46  ·  view source on GitHub ↗

Schema-validate a JSON blob and merge it into the given library instance. File-private so the constructor can populate `*this` without going through the get_library() singleton (which would recurse into its own constructor).

Source from the content-addressed store, hash-verified

29/// File-private so the constructor can populate `*this` without going through
30/// the get_library() singleton (which would recurse into its own constructor).
31void add_fluids_from_JSON_string(PCSAFTLibraryClass& dest, const std::string_view& JSON) {
32 std::string errstr;
33 cpjson::schema_validation_code val_code = cpjson::validate_schema(pcsaft_fluids_schema_JSON, JSON, errstr);
34 if (val_code == cpjson::SCHEMA_VALIDATION_OK) {
35 nlohmann::json dd = cpjson::parse(JSON);
36 try {
37 dest.add_many(dd);
38 } catch (std::exception& e) {
39 std::cout << e.what() << '\n';
40 }
41 } else {
42 if (get_debug_level() > 0) {
43 throw ValueError(format("Unable to load PC-SAFT library with error: %s", errstr.c_str()));
44 }
45 }
46}
47} // anonymous namespace
48
49PCSAFTLibraryClass& get_library() {

Callers 2

PCSAFTLibraryClassMethod · 0.70
add_fluids_as_JSONFunction · 0.70

Calls 6

validate_schemaFunction · 0.85
parseFunction · 0.85
whatMethod · 0.80
get_debug_levelFunction · 0.50
formatFunction · 0.50
add_manyMethod · 0.45

Tested by

no test coverage detected