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).
| 29 | /// File-private so the constructor can populate `*this` without going through |
| 30 | /// the get_library() singleton (which would recurse into its own constructor). |
| 31 | void 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 | |
| 49 | PCSAFTLibraryClass& get_library() { |
no test coverage detected