Commit e6e520f8 authored by Hahn, Steven's avatar Hahn, Steven
Browse files

Use to_string instead of lexical_cast.

parent 085529ef
......@@ -232,8 +232,7 @@ public:
throw std::runtime_error(ostr.str());
}
if (row >= this->rowCount()) {
throw std::range_error("Table does not have row " +
boost::lexical_cast<std::string>(row));
throw std::range_error("Table does not have row " + std::to_string(row));
}
return *(static_cast<T *>(c->void_pointer(row)));
}
......
......@@ -81,7 +81,7 @@ void AnalysisDataServiceImpl::add(
std::string wsName = ws->name();
// if anonymous make up a name and add
if (wsName.empty()) {
wsName = name + "_" + boost::lexical_cast<std::string>(i + 1);
wsName = name + "_" + std::to_string(i + 1);
} else if (doesExist(wsName)) { // if ws is already there do nothing
wsName.clear();
}
......@@ -120,7 +120,7 @@ void AnalysisDataServiceImpl::addOrReplace(
std::string wsName = ws->name();
// make up a name for an anonymous workspace
if (wsName.empty()) {
wsName = name + "_" + boost::lexical_cast<std::string>(i + 1);
wsName = name + "_" + std::to_string(i + 1);
} else if (doesExist(wsName)) { // if ws is already there do nothing
wsName.clear();
}
......
......@@ -345,7 +345,7 @@ ExperimentInfo::getGroupMembers(const detid_t detID) const {
} else {
throw std::runtime_error(
"ExperimentInfo::getGroupMembers - Unable to find ID " +
boost::lexical_cast<std::string>(detID) + " in lookup");
std::to_string(detID) + " in lookup");
}
}
......
......@@ -643,7 +643,7 @@ FileFinderImpl::findRuns(const std::string &hintstr) const {
throw std::invalid_argument("Malformed range of runs: " + *h);
}
for (int irun = runNumber; irun <= runEndNumber; ++irun) {
run = boost::lexical_cast<std::string>(irun);
run = std::to_string(irun);
while (run.size() < nZero)
run.insert(0, "0");
std::string path = findRun(p1.first + run);
......
......@@ -251,7 +251,7 @@ Grouping::Grouping(ITableWorkspace_sptr table) {
// Convert to a range string, i.e. 1-5,6-8,9
std::string detectorRange = Kernel::Strings::toString(detectors);
this->groupNames.push_back(boost::lexical_cast<std::string>(row + 1));
this->groupNames.push_back(std::to_string(row + 1));
this->groups.push_back(detectorRange);
}
......
......@@ -13,7 +13,7 @@ const std::string IEventWorkspace::toString() const {
std::ostringstream os;
os << MatrixWorkspace::toString() << "\n";
os << "Events: " + boost::lexical_cast<std::string>(getNumberEvents());
os << "Events: " + std::to_string(getNumberEvents());
switch (getEventType()) {
case WEIGHTED:
os << " (weighted)\n";
......
......@@ -33,8 +33,7 @@ bool IFuncMinimizer::minimize(size_t maxIterations) {
m_errorString += '\n';
}
m_errorString += "Failed to converge after " +
boost::lexical_cast<std::string>(maxIterations) +
" iterations.";
std::to_string(maxIterations) + " iterations.";
}
return success;
......
......@@ -314,9 +314,7 @@ protected:
return (m_quoteString) ? std::string("\"" + str + "\"") : str;
}
/// Apply if int
std::string apply(const int &i) const override {
return boost::lexical_cast<std::string>(i);
}
std::string apply(const int &i) const override { return std::to_string(i); }
/// Apply if double
std::string apply(const double &d) const override {
return boost::lexical_cast<std::string>(d);
......
......@@ -93,7 +93,7 @@ void IFunctionMD::evaluateFunction(const FunctionDomainMD &domain,
for (const IMDIterator *r = domain.getNextIterator(); r != nullptr;
r = domain.getNextIterator()) {
this->reportProgress("Evaluating function for box " +
boost::lexical_cast<std::string>(i + 1));
std::to_string(i + 1));
values.setCalculated(i, functionMD(*r));
i++;
};
......
......@@ -155,7 +155,7 @@ void IPeakFunction::functionDeriv1D(Jacobian *out, const double *xValues,
void IPeakFunction::setPeakRadius(const int &r) {
if (r > 0) {
s_peakRadius = r;
std::string setting = boost::lexical_cast<std::string>(r);
std::string setting = std::to_string(r);
Kernel::ConfigService::Instance().setString("curvefitting.peakRadius",
setting);
}
......
......@@ -16,8 +16,8 @@ ITableWorkspace::clone(const std::vector<std::string> &colNames) const {
const std::string ITableWorkspace::toString() const {
std::ostringstream os;
os << id() << "\n";
os << "Columns: " << boost::lexical_cast<std::string>(columnCount()) << "\n";
os << "Rows: " << boost::lexical_cast<std::string>(rowCount()) << "\n";
os << "Columns: " << std::to_string(columnCount()) << "\n";
os << "Rows: " << std::to_string(rowCount()) << "\n";
os << getMemorySizeAsStr();
return os.str();
}
......
......@@ -1523,7 +1523,7 @@ signal_t MatrixWorkspace::getSignalAtCoord(
if (this->axes() != 2)
throw std::invalid_argument("MatrixWorkspace::getSignalAtCoord() - "
"Workspace can only have 2 axes, found " +
boost::lexical_cast<std::string>(this->axes()));
std::to_string(this->axes()));
coord_t x = coords[0];
coord_t y = coords[1];
......
......@@ -104,11 +104,10 @@ void MultiDomainFunction::function(const FunctionDomain &domain,
const CompositeDomain &cd = dynamic_cast<const CompositeDomain &>(domain);
// domain must not have less parts than m_maxIndex
if (cd.getNParts() <= m_maxIndex) {
throw std::invalid_argument(
"CompositeDomain has too few parts (" +
boost::lexical_cast<std::string>(cd.getNParts()) +
") for MultiDomainFunction (max index " +
boost::lexical_cast<std::string>(m_maxIndex) + ").");
throw std::invalid_argument("CompositeDomain has too few parts (" +
std::to_string(cd.getNParts()) +
") for MultiDomainFunction (max index " +
std::to_string(m_maxIndex) + ").");
}
// domain and values must be consistent
if (cd.size() != values.size()) {
......@@ -148,11 +147,10 @@ void MultiDomainFunction::functionDeriv(const FunctionDomain &domain,
const CompositeDomain &cd = dynamic_cast<const CompositeDomain &>(domain);
// domain must not have less parts than m_maxIndex
if (cd.getNParts() < m_maxIndex) {
throw std::invalid_argument(
"CompositeDomain has too few parts (" +
boost::lexical_cast<std::string>(cd.getNParts()) +
") for MultiDomainFunction (max index " +
boost::lexical_cast<std::string>(m_maxIndex) + ").");
throw std::invalid_argument("CompositeDomain has too few parts (" +
std::to_string(cd.getNParts()) +
") for MultiDomainFunction (max index " +
std::to_string(m_maxIndex) + ").");
}
countValueOffsets(cd);
......@@ -207,9 +205,9 @@ MultiDomainFunction::getLocalAttribute(size_t i,
} else if (it->second.size() == 1 && it->second.front() == i) {
return IFunction::Attribute("i");
} else if (!it->second.empty()) {
std::string out(boost::lexical_cast<std::string>(it->second.front()));
std::string out(std::to_string(front()));
for (auto i = it->second.begin() + 1; i != it->second.end(); ++it) {
out += "," + boost::lexical_cast<std::string>(*i);
out += "," + std::to_string(*i);
}
return IFunction::Attribute(out);
}
......@@ -339,7 +337,7 @@ MultiDomainFunction::createEquivalentFunctions() const {
auto fun = compositeFunctions[i];
if (!fun || fun->nFunctions() == 0) {
throw std::runtime_error("There is no function for domain " +
boost::lexical_cast<std::string>(i));
std::to_string(i));
}
if (fun->nFunctions() > 1) {
outFunctions[i] = fun;
......
......@@ -100,7 +100,7 @@ void ParameterTie::set(const std::string &expr) {
m_expression = "";
while (boost::regex_search(start, end, res, rx)) {
m_expression.append(start, res[0].first);
m_expression += "#" + boost::lexical_cast<std::string>(varNames[res[1]]);
m_expression += "#" + std::to_string(varNames[res[1]]);
start = res[0].second;
}
m_expression.append(start, end);
......
......@@ -160,7 +160,7 @@ bool SpectraAxis::operator==(const Axis &axis2) const {
* @return label of requested axis index
*/
std::string SpectraAxis::label(const std::size_t &index) const {
return "sp-" + boost::lexical_cast<std::string>(spectraNo(index));
return "sp-" + std::to_string(spectraNo(index));
}
/// returns min value defined on axis
......
......@@ -154,7 +154,7 @@ void CalculateFlatBackground::exec() {
// not every spectra is the monitor or detector, some spectra have no
// instrument components attached.
g_log.information(" Can not find detector for spectra N: " +
boost::lexical_cast<std::string>(currentSpec) +
std::to_string(currentSpec) +
" Processing background anyway\n");
}
}
......
......@@ -51,7 +51,7 @@ size_t getIndexFromDetectorID(MatrixWorkspace_sptr ws, detid_t detid) {
if (result.empty())
throw std::invalid_argument(
"Could not find the spectra corresponding to detector ID " +
boost::lexical_cast<std::string>(detid));
std::to_string(detid));
return result[0];
}
......@@ -192,10 +192,10 @@ void CalculateTransmission::exec() {
BOOST_FOREACH (size_t transmissionIndex, transmissionIndices)
if (transmissionIndex == beamMonitorIndex)
throw std::invalid_argument(
"The IncidentBeamMonitor UDET (" +
boost::lexical_cast<std::string>(transmissionIndex) +
") matches a UDET given in " + transPropName + ".");
throw std::invalid_argument("The IncidentBeamMonitor UDET (" +
std::to_string(transmissionIndex) +
") matches a UDET given in " +
transPropName + ".");
}
MatrixWorkspace_sptr sampleInc;
......@@ -495,8 +495,7 @@ CalculateTransmission::rebin(std::vector<double> &binParams,
void CalculateTransmission::logIfNotMonitor(API::MatrixWorkspace_sptr sampleWS,
API::MatrixWorkspace_sptr directWS,
size_t index) {
const std::string message = "The detector at index " +
boost::lexical_cast<std::string>(index) +
const std::string message = "The detector at index " + std::to_string(index) +
" is not a monitor in the ";
if (!sampleWS->getDetector(index)->isMonitor())
g_log.information(message + "sample workspace.");
......
......@@ -177,7 +177,7 @@ void ConvertEmptyToTof::validateWorkspaceIndices(std::vector<int> &v) {
for (auto index : v) {
if (index < 0 || static_cast<size_t>(index) >= nHist) {
throw std::runtime_error("Spectra index out of limits: " +
boost::lexical_cast<std::string>(index));
std::to_string(index));
}
}
}
......@@ -202,7 +202,7 @@ void ConvertEmptyToTof::validateChannelIndices(std::vector<int> &v) {
for (auto &index : v) {
if (index < 0 || static_cast<size_t>(index) >= blockSize) {
throw std::runtime_error("Channel index out of limits: " +
boost::lexical_cast<std::string>(index));
std::to_string(index));
}
}
}
......
......@@ -142,17 +142,16 @@ void CreateTransmissionWorkspaceAuto::exec() {
instrument->getNumberParameter("PointDetectorStop")[0]);
if (analysis_mode == "PointDetectorAnalysis") {
if (start == stop) {
processing_commands = boost::lexical_cast<std::string>(start);
processing_commands = std::to_string(start);
} else {
processing_commands = boost::lexical_cast<std::string>(start) + ":" +
boost::lexical_cast<std::string>(stop);
processing_commands =
std::to_string(start) + ":" + std::to_string(stop);
}
} else {
processing_commands =
boost::lexical_cast<std::string>(static_cast<int>(
std::to_string(static_cast<int>(
instrument->getNumberParameter("MultiDetectorStart")[0])) +
":" +
boost::lexical_cast<std::string>(firstWS->getNumberHistograms() - 1);
":" + std::to_string(firstWS->getNumberHistograms() - 1);
}
} else {
std::string processing_commands_temp =
......
......@@ -285,7 +285,7 @@ void GetAllEi::exec() {
}
}
g_log.debug() << "*From all chopper opening only: " +
boost::lexical_cast<std::string>(guess_ei.size()) +
std::to_string(guess_ei.size()) +
" fell within both monitor's recording energy range\n";
g_log.debug() << " Guess Energies are:\n";
for (double ei : guess_ei) {
......@@ -323,7 +323,7 @@ void GetAllEi::exec() {
irange1_max.assign(irange_max.begin(), irange_max.end());
}
g_log.debug()
<< "*Identified: " + boost::lexical_cast<std::string>(guess_ei.size()) +
<< "*Identified: " + std::to_string(guess_ei.size()) +
" peaks with sufficient signal around guess chopper opening\n";
std::vector<peakKeeper> peaks;
......@@ -557,21 +557,18 @@ bool GetAllEi::peakGuess(const API::MatrixWorkspace_sptr &inputWS, size_t index,
}
if (iterations_fail) {
g_log.information() << "*No peak search convergence after " +
boost::lexical_cast<std::string>(ic) +
std::to_string(ic) +
" smoothing iterations at still_count: " +
boost::lexical_cast<std::string>(
stay_still_count) +
std::to_string(stay_still_count) +
" Wrong energy or noisy peak at Ei=" +
boost::lexical_cast<std::string>(Ei)
<< std::endl;
}
g_log.debug() << "*Performed: " + boost::lexical_cast<std::string>(ic) +
" averages for spectra " +
boost::lexical_cast<std::string>(index) +
g_log.debug() << "*Performed: " + std::to_string(ic) +
" averages for spectra " + std::to_string(index) +
" at energy: " + boost::lexical_cast<std::string>(Ei) +
"\n and found: " +
boost::lexical_cast<std::string>(nPeaks) + "peaks and " +
boost::lexical_cast<std::string>(nHills) + " hills\n";
"\n and found: " + std::to_string(nPeaks) +
"peaks and " + std::to_string(nHills) + " hills\n";
if (nPeaks != 1) {
g_log.debug() << "*Peak rejected as n-peaks !=1 after averaging\n";
return false;
......@@ -586,10 +583,8 @@ bool GetAllEi::peakGuess(const API::MatrixWorkspace_sptr &inputWS, size_t index,
peakTwoSigma = hillsPos[1] - hillsPos[0];
} else {
g_log.debug() << "*Peak rejected as averaging gives: " +
boost::lexical_cast<std::string>(nPeaks) +
" peaks and " +
boost::lexical_cast<std::string>(nHills) +
" heals\n";
std::to_string(nPeaks) + " peaks and " +
std::to_string(nHills) + " heals\n";
return false;
}
......@@ -1249,7 +1244,7 @@ std::map<std::string, std::string> GetAllEi::validateInputs() {
} catch (std::runtime_error &) {
result["Monitor1SpecID"] =
"Input workspace does not contain spectra with ID: " +
boost::lexical_cast<std::string>(specNum1);
std::to_string(specNum1);
}
specnum_t specNum2 = getProperty("Monitor2SpecID");
try {
......@@ -1257,7 +1252,7 @@ std::map<std::string, std::string> GetAllEi::validateInputs() {
} catch (std::runtime_error &) {
result["Monitor2SpecID"] =
"Input workspace does not contain spectra with ID: " +
boost::lexical_cast<std::string>(specNum2);
std::to_string(specNum2);
}
// check chopper and initiate it if present (for debugging)
m_chopper = inputWS->getInstrument()->getComponentByName("chopper-position");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment