setupPropertyTree: avoid use of sstream

This commit is contained in:
Arne Morten Kvarving 2023-01-02 15:21:42 +01:00
parent 48bdf6f14c
commit f00ebc8b1c

View File

@ -47,18 +47,18 @@ setupPropertyTree(FlowLinearSolverParameters p, // Note: copying the parameters
if (conf.size() > 5 && conf.substr(conf.size() - 5, 5) == ".json") { // the ends_with() method is not available until C++20 if (conf.size() > 5 && conf.substr(conf.size() - 5, 5) == ".json") { // the ends_with() method is not available until C++20
#if BOOST_VERSION / 100 % 1000 > 48 #if BOOST_VERSION / 100 % 1000 > 48
if ( !std::filesystem::exists(conf) ) { if ( !std::filesystem::exists(conf) ) {
OPM_THROW(std::invalid_argument, "JSON file " << conf << " does not exist."); OPM_THROW(std::invalid_argument, "JSON file " + conf + " does not exist.");
} }
try { try {
return PropertyTree(conf); return PropertyTree(conf);
} }
catch (...) { catch (...) {
OPM_THROW(std::invalid_argument, "Failed reading linear solver configuration from JSON file " << conf); OPM_THROW(std::invalid_argument, "Failed reading linear solver configuration from JSON file " + conf);
} }
#else #else
OPM_THROW(std::invalid_argument, OPM_THROW(std::invalid_argument,
"--linear-solver-configuration=file.json not supported with " "--linear-solver-configuration=file.json not supported with "
<< "boost version. Needs version > 1.48."); "boost version. Needs version > 1.48.");
#endif #endif
} }
@ -110,8 +110,8 @@ setupPropertyTree(FlowLinearSolverParameters p, // Note: copying the parameters
// No valid configuration option found. // No valid configuration option found.
OPM_THROW(std::invalid_argument, OPM_THROW(std::invalid_argument,
conf << " is not a valid setting for --linear-solver-configuration." conf + " is not a valid setting for --linear-solver-configuration."
<< " Please use ilu0, cpr, cpr_trueimpes, cpr_quasiimpes or isai"); " Please use ilu0, cpr, cpr_trueimpes, cpr_quasiimpes or isai");
} }
std::string getSolverString(const FlowLinearSolverParameters& p) std::string getSolverString(const FlowLinearSolverParameters& p)