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