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

Use to_string instead of lexical_cast.

parent 085529ef
......@@ -135,7 +135,7 @@ void LoadAscii2::parseLine(const std::string &line,
// there were more separators than there should have been, which isn't
// right, or something went rather wrong
throw std::runtime_error(
"Line " + boost::lexical_cast<std::string>(m_lineNo) +
"Line " + std::to_string(m_lineNo) +
": Sets of values must have between 1 and 3 delimiters");
} else if (cols == 1) {
// a size of 1 is a spectra ID as long as there are no alphabetic
......@@ -151,7 +151,7 @@ void LoadAscii2::parseLine(const std::string &line,
// if not then they've ommitted IDs in the the file previously and just
// decided to include one (which is wrong and confuses everything)
throw std::runtime_error(
"Line " + boost::lexical_cast<std::string>(m_lineNo) +
"Line " + std::to_string(m_lineNo) +
": Inconsistent inclusion of spectra IDs. All spectra must have "
"IDs or all spectra must not have IDs. "
"Check for blank lines, as they symbolize the end of one spectra "
......@@ -168,7 +168,7 @@ void LoadAscii2::parseLine(const std::string &line,
}
} else if (badLine(line)) {
throw std::runtime_error(
"Line " + boost::lexical_cast<std::string>(m_lineNo) +
"Line " + std::to_string(m_lineNo) +
": Unexpected character found at beginning of line. Lines must either "
"be a single integer, a list of numeric values, blank, or a text line "
"beginning with the specified comment indicator: " +
......@@ -176,7 +176,7 @@ void LoadAscii2::parseLine(const std::string &line,
} else {
// strictly speaking this should never be hit, but just being sure
throw std::runtime_error(
"Line " + boost::lexical_cast<std::string>(m_lineNo) +
"Line " + std::to_string(m_lineNo) +
": Unknown format at line. Lines must either be a single integer, a "
"list of numeric values, blank, or a text line beginning with the "
"specified comment indicator: " +
......@@ -257,7 +257,7 @@ void LoadAscii2::setcolumns(std::ifstream &file, std::string &line,
// isn't right, or something went rather wrong
throw std::runtime_error(
"Sets of values must have between 1 and 3 delimiters. Found " +
boost::lexical_cast<std::string>(cols) + ".");
std::to_string(cols) + ".");
} else if (cols != 1) {
try {
fillInputValues(values, columns);
......
......@@ -177,8 +177,7 @@ void LoadDetectorInfo::loadFromRAW(const std::string &filename) {
} else {
throw std::invalid_argument(
"RAW file contains unexpected number of user tables=" +
boost::lexical_cast<std::string>(numUserTables) +
". Expected 10 or 14.");
std::to_string(numUserTables) + ". Expected 10 or 14.");
}
// Is ut01 (=phi) present? Sometimes an array is present but has wrong values
......
......@@ -147,7 +147,7 @@ void LoadDetectorsGroupingFile::exec() {
std::map<int, std::string> groupNamesMap = loader.getGroupNamesMap();
for (auto &group : groupNamesMap) {
std::string groupIdStr = boost::lexical_cast<std::string>(group.first);
std::string groupIdStr = std::to_string(first);
m_groupWS->mutableRun().addProperty("GroupName_" + groupIdStr,
group.second);
}
......
......@@ -2690,8 +2690,8 @@ void LoadEventNexus::loadTimeOfFlight(EventWorkspaceCollection_sptr WS,
}
if (time_channels_number > 0) // the numbers start with 1
{
m_file->openGroup("time_channels_" + boost::lexical_cast<std::string>(
time_channels_number),
m_file->openGroup("time_channels_" +
std::to_string(time_channels_number),
"IXtime_channels");
entries = m_file->getEntries();
for (string_map_t::const_iterator it = entries.begin();
......
......@@ -245,7 +245,7 @@ void LoadFITS::loadHeader(const std::string &filePath, FITSInfo &header) {
"bits per pixel as allowed in the FITS standard. The header of "
"file '" +
filePath + "' says that its bit depth is: " +
boost::lexical_cast<std::string>(header.bitsPerPixel));
std::to_string(header.bitsPerPixel));
} catch (std::exception &e) {
throw std::runtime_error(
"Failed to process the '" + m_headerBitDepthKey +
......@@ -445,12 +445,11 @@ void LoadFITS::doLoadFiles(const std::vector<std::string> &paths,
for (int i = 0; i < headers[0].numberOfAxis; ++i) {
if (0 != (headers[0].axisPixelLengths[i] % binSize)) {
throw std::runtime_error(
"Cannot rebin this image in blocks of " +
boost::lexical_cast<std::string>(binSize) + " x " +
boost::lexical_cast<std::string>(binSize) +
"Cannot rebin this image in blocks of " + std::to_string(binSize) +
" x " + std::to_string(binSize) +
" pixels as requested because the size of dimension " +
boost::lexical_cast<std::string>(i + 1) + " (" +
boost::lexical_cast<std::string>(headers[0].axisPixelLengths[i]) +
std::to_string(i + 1) + " (" +
std::to_string(headers[0].axisPixelLengths[i]) +
") is not a multiple of the bin size.");
}
}
......@@ -467,7 +466,7 @@ void LoadFITS::doLoadFiles(const std::vector<std::string> &paths,
} catch (std::exception &) {
throw std::runtime_error(
"Could not allocate enough memory to run when trying to allocate " +
boost::lexical_cast<std::string>(bytes) + " bytes.");
std::to_string(bytes) + " bytes.");
}
// Create a group for these new workspaces, if the group already exists, add
......@@ -536,8 +535,8 @@ void LoadFITS::doLoadFiles(const std::vector<std::string> &paths,
imgWS = makeWorkspace(headers[i], fileNumberInGroup, buffer, imageY, imageE,
imgWS, loadAsRectImg, binSize, noiseThresh);
progress.report("Loaded file " + boost::lexical_cast<std::string>(i + 1) +
" of " + boost::lexical_cast<std::string>(totalWS));
progress.report("Loaded file " + std::to_string(i + 1) + " of " +
std::to_string(totalWS));
wsGroup->addWorkspace(imgWS);
}
......@@ -979,8 +978,8 @@ void LoadFITS::readInBuffer(const FITSInfo &fileInfo, std::vector<char> &buffer,
if (!file) {
throw std::runtime_error(
"Error while reading file: " + filename + ". Tried to read " +
boost::lexical_cast<std::string>(len) + " bytes but got " +
boost::lexical_cast<std::string>(file.gcount()) +
std::to_string(len) + " bytes but got " +
std::to_string(file.gcount()) +
" bytes. The file and/or its headers may be wrong.");
}
// all is loaded
......
......@@ -347,9 +347,9 @@ void LoadHelper::recurseAndAddNexusFieldsToWsRun(NXhandle nxfileID,
property_double_value =
(reinterpret_cast<double *>(dataBuffer))[dim_index];
}
std::string indexed_property_name =
property_name + std::string("_") +
boost::lexical_cast<std::string>(dim_index);
std::string indexed_property_name = property_name +
std::string("_") +
std::to_string(dim_index);
if (units_status != NX_ERROR)
runDetails.addProperty(indexed_property_name,
property_double_value,
......
......@@ -400,7 +400,7 @@ void LoadILLIndirect::moveSingleDetectors() {
std::string prefix("single_tube_");
for (int i = 1; i <= 8; i++) {
std::string componentName = prefix + boost::lexical_cast<std::string>(i);
std::string componentName = prefix + std::to_string(i);
moveComponent(componentName, i * 20.0, 2.0 + i / 10.0);
}
......
......@@ -534,7 +534,7 @@ void LoadILLSANS::loadMetaData(const NeXus::NXEntry &entry,
API::Run &runDetails = m_localWorkspace->mutableRun();
int runNum = entry.getInt("run_number");
std::string run_num = boost::lexical_cast<std::string>(runNum);
std::string run_num = std::to_string(runNum);
runDetails.addProperty("run_number", run_num);
if (entry.getFloat("mode") == 0.0) { // Not TOF
......
......@@ -511,7 +511,7 @@ bool LoadISISNexus2::checkOptionalProperties(bool bseparateMonitors,
std::string err =
"Inconsistent range property. SpectrumMax is larger than number of "
"spectra: " +
boost::lexical_cast<std::string>(m_loadBlockInfo.getMaxSpectrumID());
std::to_string(m_loadBlockInfo.getMaxSpectrumID());
throw std::invalid_argument(err);
}
......@@ -519,10 +519,9 @@ bool LoadISISNexus2::checkOptionalProperties(bool bseparateMonitors,
m_entrynumber = getProperty("EntryNumber");
if (static_cast<int>(m_entrynumber) > m_loadBlockInfo.getNumberOfPeriods() ||
m_entrynumber < 0) {
std::string err =
"Invalid entry number entered. File contains " +
boost::lexical_cast<std::string>(m_loadBlockInfo.getNumberOfPeriods()) +
" period. ";
std::string err = "Invalid entry number entered. File contains " +
std::to_string(m_loadBlockInfo.getNumberOfPeriods()) +
" period. ";
throw std::invalid_argument(err);
}
......@@ -971,8 +970,7 @@ void LoadISISNexus2::loadRunDetails(
m_proton_charge = static_cast<double>(entry.getFloat("proton_charge"));
runDetails.setProtonCharge(m_proton_charge);
std::string run_num =
boost::lexical_cast<std::string>(entry.getInt("run_number"));
std::string run_num = std::to_string(entry.getInt("run_number"));
runDetails.addProperty("run_number", run_num);
//
......
......@@ -313,8 +313,7 @@ void LoadMLZ::loadRunDetails(NXEntry &entry) {
double ei = m_mlzloader.calculateEnergy(m_wavelength);
runDetails.addProperty<double>("Ei", ei, true); // overwrite
std::string duration =
boost::lexical_cast<std::string>(entry.getInt("duration"));
std::string duration = std::to_string(entry.getInt("duration"));
runDetails.addProperty("duration", duration);
std::string mode = entry.getString("mode");
......@@ -331,13 +330,13 @@ void LoadMLZ::loadRunDetails(NXEntry &entry) {
runDetails.addProperty("temperature", temperature);
}
std::string monitorCounts = boost::lexical_cast<std::string>(m_monitorCounts);
std::string monitorCounts = std::to_string(m_monitorCounts);
runDetails.addProperty("monitor_counts", monitorCounts);
std::string chopper_speed = boost::lexical_cast<std::string>(m_chopper_speed);
runDetails.addProperty("chopper_speed", chopper_speed);
std::string chopper_ratio = boost::lexical_cast<std::string>(m_chopper_ratio);
std::string chopper_ratio = std::to_string(m_chopper_ratio);
runDetails.addProperty("chopper_ratio", chopper_ratio);
std::string channel_width = boost::lexical_cast<std::string>(m_channelWidth);
......
......@@ -392,8 +392,7 @@ void LoadMcStas::readEventData(
std::string nameOfGroupWS = getProperty("OutputWorkspace");
std::string nameUserSee = std::string("EventData_") + nameOfGroupWS;
std::string extraProperty =
"Outputworkspace_dummy_" +
boost::lexical_cast<std::string>(m_countNumWorkspaceAdded);
"Outputworkspace_dummy_" + std::to_string(m_countNumWorkspaceAdded);
declareProperty(Kernel::make_unique<WorkspaceProperty<Workspace>>(
extraProperty, nameUserSee, Direction::Output));
setProperty(extraProperty, boost::static_pointer_cast<Workspace>(eventWS));
......@@ -532,8 +531,7 @@ void LoadMcStas::readHistogramData(
std::string nameOfGroupWS = getProperty("OutputWorkspace");
std::string nameUserSee = nameAttrValueTITLE + "_" + nameOfGroupWS;
std::string extraProperty =
"Outputworkspace_dummy_" +
boost::lexical_cast<std::string>(m_countNumWorkspaceAdded);
"Outputworkspace_dummy_" + std::to_string(m_countNumWorkspaceAdded);
declareProperty(Kernel::make_unique<WorkspaceProperty<Workspace>>(
extraProperty, nameUserSee, Direction::Output));
setProperty(extraProperty, boost::static_pointer_cast<Workspace>(ws));
......
......@@ -113,7 +113,7 @@ void LoadMuonNexus1::exec() {
}
std::string run_num;
try {
run_num = boost::lexical_cast<std::string>(nxRun.getInt("number"));
run_num = std::to_string(nxRun.getInt("number"));
} catch (...) {
}
......
......@@ -349,8 +349,7 @@ void LoadMuonNexus2::loadLogs(API::MatrixWorkspace_sptr ws, NXEntry &entry,
ws->setComment(entry.getString("notes"));
}
std::string run_num =
boost::lexical_cast<std::string>(entry.getInt("run_number"));
std::string run_num = std::to_string(entry.getInt("run_number"));
// The sample is left to delete the property
ws->mutableRun().addLogData(
new PropertyWithValue<std::string>("run_number", run_num));
......
......@@ -546,7 +546,7 @@ std::string LoadNexusProcessed::buildWorkspaceName(const std::string &name,
int64_t wsIndex,
bool commonStem) {
std::string wsName;
std::string index = boost::lexical_cast<std::string>(wsIndex);
std::string index = std::to_string(wsIndex);
// if we don't have a common stem then use name tag
if (!commonStem) {
......@@ -587,7 +587,7 @@ void LoadNexusProcessed::correctForWorkspaceNameClash(std::string &wsName) {
std::string wsIndex = ""; // dont use an index if there is no other
// workspace
if (i > 0) {
wsIndex = "_" + boost::lexical_cast<std::string>(i);
wsIndex = "_" + std::to_string(i);
}
bool wsExists = AnalysisDataService::Instance().doesExist(wsName + wsIndex);
......@@ -831,8 +831,7 @@ API::Workspace_sptr LoadNexusProcessed::loadTableEntry(NXEntry &entry) {
int columnNumber = 1;
do {
std::string dataSetName =
"column_" + boost::lexical_cast<std::string>(columnNumber);
std::string dataSetName = "column_" + std::to_string(columnNumber);
NXInfo info = nx_tw.getDataSetInfo(dataSetName.c_str());
if (info.stat == NX_ERROR) {
......@@ -861,7 +860,7 @@ API::Workspace_sptr LoadNexusProcessed::loadTableEntry(NXEntry &entry) {
loadNumericColumn<bool, bool>(nx_tw, dataSetName, workspace, "bool");
} else {
throw std::logic_error("Column with Nexus data type " +
boost::lexical_cast<std::string>(info.type) +
std::to_string(info.type) +
" cannot be loaded.");
}
} else if (info.rank == 2) {
......@@ -997,8 +996,7 @@ API::Workspace_sptr LoadNexusProcessed::loadPeaksEntry(NXEntry &entry) {
int numberPeaks = 0;
std::vector<std::string> columnNames;
do {
std::string str =
"column_" + boost::lexical_cast<std::string>(columnNumber);
std::string str = "column_" + std::to_string(columnNumber);
NXInfo info = nx_tw.getDataSetInfo(str.c_str());
if (info.stat == NX_ERROR) {
......
......@@ -95,9 +95,8 @@ void LoadQKK::exec() {
size_t nx = hmm.dim2(); // third dimension
size_t nHist = ny * nx; // number of spectra in the dataset
if (nHist == 0) {
throw std::runtime_error("Error in data dimensions: " +
boost::lexical_cast<std::string>(ny) + " X " +
boost::lexical_cast<std::string>(nx));
throw std::runtime_error("Error in data dimensions: " + std::to_string(ny) +
" X " + std::to_string(nx));
}
// Set the workspace structure. The workspace will contain nHist spectra each
......
......@@ -492,7 +492,7 @@ const std::string LoadRKH::readUnit(const std::string &line) {
// accepted.
// cppcheck-suppress stlIfStrFind
if (unit.find('(') != 0 || unit.find(')') != unit.size()) {
std::string qCode = boost::lexical_cast<std::string>(SaveRKH::Q_CODE);
std::string qCode = std::to_string(SaveRKH::Q_CODE);
if (symbol == qCode && theQuantity == "q" &&
unit == "(1/Angstrom)") { // 6 q (1/Angstrom) is the synatx for
// MomentumTransfer
......
......@@ -164,7 +164,7 @@ void LoadRawHelper::setProtonCharge(API::Run &run) {
* @param run :: the workspace's run object
*/
void LoadRawHelper::setRunNumber(API::Run &run) {
std::string run_num = boost::lexical_cast<std::string>(isisRaw->r_number);
std::string run_num = std::to_string(isisRaw->r_number);
run.addLogData(new PropertyWithValue<std::string>("run_number", run_num));
}
/**reads workspace dimensions,number of periods etc from raw data
......
......@@ -159,7 +159,7 @@ ITableWorkspace_sptr LoadSavuTomoConfig::loadFile(std::string &fname,
for (size_t j = 0; j < pluginsLen; j++) {
API::TableRow table = ws->appendRow();
std::string entryIdx = boost::lexical_cast<std::string>(j);
std::string entryIdx = std::to_string(j);
try {
f->openGroup(entryIdx, "NXnote");
} catch (NeXus::Exception &e) {
......
......@@ -176,10 +176,9 @@ void LoadTBL::csvParse(std::string line, std::vector<std::string> &cols,
}
if (cols.size() != expectedCommas + 1) {
std::string message = "A line must contain " +
boost::lexical_cast<std::string>(expectedCommas) +
std::to_string(expectedCommas) +
" cell-delimiting commas. Found " +
boost::lexical_cast<std::string>(cols.size() - 1) +
".";
std::to_string(cols.size() - 1) + ".";
throw std::length_error(message);
}
}
......@@ -209,10 +208,9 @@ size_t LoadTBL::getCells(std::string line, std::vector<std::string> &cols,
boost::token_compress_off);
} else if (found < expectedCommas) {
// less than 16 means the line isn't properly formatted. So Throw
std::string message = "A line must contain " +
boost::lexical_cast<std::string>(expectedCommas) +
" cell-delimiting commas. Found " +
boost::lexical_cast<std::string>(found) + ".";
std::string message =
"A line must contain " + std::to_string(expectedCommas) +
" cell-delimiting commas. Found " + std::to_string(found) + ".";
throw std::length_error(message);
} else {
// More than 16 will need further checks as more is only ok when pairs of
......@@ -222,10 +220,9 @@ size_t LoadTBL::getCells(std::string line, std::vector<std::string> &cols,
// if we didn't find any quotes, then there are too many commas and we
// definitely have too many delimiters
if (quoteBounds.empty()) {
std::string message = "A line must contain " +
boost::lexical_cast<std::string>(expectedCommas) +
" cell-delimiting commas. Found " +
boost::lexical_cast<std::string>(found) + ".";
std::string message =
"A line must contain " + std::to_string(expectedCommas) +
" cell-delimiting commas. Found " + std::to_string(found) + ".";
throw std::length_error(message);
}
// now go through and split it up manually. Throw if we find ourselves in
......@@ -243,10 +240,9 @@ size_t LoadTBL::getCells(std::string line, std::vector<std::string> &cols,
boost::lexical_cast<std::string>("," + cols[i]));
}
} else if (cols.size() < expectedCommas) {
std::string message = "A line must contain " +
boost::lexical_cast<std::string>(expectedCommas) +
" cell-delimiting commas. Found " +
boost::lexical_cast<std::string>(found) + ".";
std::string message =
"A line must contain " + std::to_string(expectedCommas) +
" cell-delimiting commas. Found " + std::to_string(found) + ".";
throw std::length_error(message);
}
}
......
......@@ -445,7 +445,7 @@ void SaveAscii2::populateSpectrumNumberMetaData() {
const size_t nHist = m_ws->getNumberHistograms();
for (size_t i = 0; i < nHist; i++) {
const auto specNum = m_ws->getSpectrum(i)->getSpectrumNo();
const auto specNumStr = boost::lexical_cast<std::string>(specNum);
const auto specNumStr = std::to_string(specNum);
spectrumNumbers.push_back(specNumStr);
}
m_metaDataMap["spectrumnumber"] = spectrumNumbers;
......
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