Use cppformat instead of stringstream in some places
This commit is contained in:
parent
785b829b5d
commit
484da253da
3 changed files with 9 additions and 19 deletions
|
|
@ -54,17 +54,14 @@ std::string CanteraError::getMessage() const
|
|||
|
||||
std::string ArraySizeError::getMessage() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "Array size (" << sz_ << ") too small. Must be at least " << reqd_ << ".";
|
||||
return ss.str();
|
||||
return fmt::format("Array size ({}) too small. Must be at least {}.",
|
||||
sz_, reqd_);
|
||||
}
|
||||
|
||||
std::string IndexError::getMessage() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "IndexError: " << arrayName_ << "[" << m_ << "]" <<
|
||||
" outside valid range of 0 to " << (mmax_) << ".";
|
||||
return ss.str();
|
||||
return fmt::format("IndexError: {}[{}] outside valid range of 0 to {}.",
|
||||
arrayName_, m_, mmax_);
|
||||
}
|
||||
|
||||
} // namespace Cantera
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
#include "cantera/thermo/mix_defs.h"
|
||||
#include "cantera/base/stringUtils.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <cstdio>
|
||||
|
||||
namespace Cantera
|
||||
|
|
@ -204,9 +203,7 @@ void vcs_VolPhase::resize(const size_t phaseNum, const size_t nspecies,
|
|||
} else {
|
||||
VP_ID_ = phaseNum;
|
||||
if (!phaseName) {
|
||||
std::stringstream sstmp;
|
||||
sstmp << "Phase_" << VP_ID_;
|
||||
PhaseName = sstmp.str();
|
||||
PhaseName = fmt::format("Phase_{}", VP_ID_);
|
||||
} else {
|
||||
PhaseName = phaseName;
|
||||
}
|
||||
|
|
@ -1068,9 +1065,7 @@ size_t vcs_VolPhase::transferElementsFM(const ThermoPhase* const tPhase)
|
|||
if (cne) {
|
||||
std::string pname = tPhase->id();
|
||||
if (pname == "") {
|
||||
std::stringstream sss;
|
||||
sss << "phase" << VP_ID_;
|
||||
pname = sss.str();
|
||||
pname = fmt::format("phase{}", VP_ID_);
|
||||
}
|
||||
e = ChargeNeutralityElement;
|
||||
m_elementNames[e] = "cn_" + pname;
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@ typedef int sd_size_t;
|
|||
typedef long int sd_size_t;
|
||||
#endif
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
|
|
@ -460,10 +458,10 @@ string CVodesIntegrator::getErrorInfo(int N)
|
|||
|
||||
N = std::min(N, static_cast<int>(m_neq));
|
||||
sort(weightedErrors.begin(), weightedErrors.end());
|
||||
stringstream s;
|
||||
fmt::MemoryWriter s;
|
||||
for (int i=0; i<N; i++) {
|
||||
s << get<2>(weightedErrors[i]) << ": "
|
||||
<< get<1>(weightedErrors[i]) << endl;
|
||||
s.write("{}: {}\n",
|
||||
get<2>(weightedErrors[i]), get<1>(weightedErrors[i]));
|
||||
}
|
||||
return s.str();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue