Skip to content

Commit

Permalink
Fixing various gcc compiler errors
Browse files Browse the repository at this point in the history
Changed a nuber of variables from int to size_t.

Changed instanced of std::to_string to boost::lexical_cast<std::string>

Cahnged a call to getProperty so taht it assigned to a new varaible.

Refs #7732
  • Loading branch information
keithnbrown committed Oct 24, 2013
1 parent 3b42125 commit 69495fb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
Expand Up @@ -99,12 +99,12 @@ namespace Mantid
/// Map the separator options to their string equivalents
std::map<std::string,std::string> m_separatorIndex;
std::string m_comment;
int m_baseCols;
size_t m_baseCols;
int m_specNo;
int m_lastBins;
int m_curBins;
size_t m_lastBins;
size_t m_curBins;
bool m_spectraStart;
int m_specIDs;
size_t m_spectrumIDcount;
std::vector<DataObjects::Histogram1D> m_spectra;
DataObjects::Histogram1D *m_curSpectra;
};
Expand Down
25 changes: 13 additions & 12 deletions Code/Mantid/Framework/DataHandling/src/LoadAscii2.cpp
Expand Up @@ -110,7 +110,7 @@ namespace Mantid
m_lastBins = 0;
m_curBins = 0;
m_spectraStart = true;
m_specIDs = 0;
m_spectrumIDcount = 0;

int lineNo = 0;
m_spectra.clear();
Expand Down Expand Up @@ -159,22 +159,22 @@ namespace Mantid
if (cols > 4 || cols < 0)
{
//there were more separators than there should have been, which isn't right, or something went rather wrong
throw std::runtime_error("Line " + std::to_string(lineNo) + ": Sets of values must have between 1 and 3 delimiters");
throw std::runtime_error("Line " + boost::lexical_cast<std::string>(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 characters in it. Signifies the start of a new spectra if it wasn't preceeded with a blank line
newSpectra();

//at this point both vectors should be the same size (or the ID counter should be 0, but as we're here then that's out the window),
if (m_spectra.size() == m_specIDs)
if (m_spectra.size() == m_spectrumIDcount)
{
m_specIDs++;
m_spectrumIDcount++;
}
else
{
//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 " + std::to_string(lineNo) + ": Inconsistent inclusion of spectra IDs. All spectra must have IDs or all spectra must not have IDs. "
throw std::runtime_error("Line " + boost::lexical_cast<std::string>(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 and the start of another. Also check for spectra IDs with no associated bins.");
}
m_curSpectra->setSpectrumNo(boost::lexical_cast<int>(*(columns.begin())));
Expand All @@ -190,12 +190,12 @@ namespace Mantid
}
else if (badLine(line))
{
throw std::runtime_error("Line " + std::to_string(lineNo) + ": Unexpected character found at beggining of line. Lines muct either be a single integer, a list of numeric values, blank, or a text line beggining with the specified comment indicator:" + m_comment +".");
throw std::runtime_error("Line " + boost::lexical_cast<std::string>(lineNo) + ": Unexpected character found at beggining of line. Lines muct either be a single integer, a list of numeric values, blank, or a text line beggining with the specified comment indicator:" + m_comment +".");
}
else
{
//strictly speaking this should never be hit, but just being sure
throw std::runtime_error("Line " + std::to_string(lineNo) + ": Unknown format at line. Lines muct either be a single integer, a list of numeric values, blank, or a text line beggining with the specified comment indicator:" + m_comment +".");
throw std::runtime_error("Line " + boost::lexical_cast<std::string>(lineNo) + ": Unknown format at line. Lines muct either be a single integer, a list of numeric values, blank, or a text line beggining with the specified comment indicator:" + m_comment +".");
}
}

Expand Down Expand Up @@ -230,7 +230,7 @@ namespace Mantid
//DX in file
localWorkspace->dataDx(i) = m_spectra[i].readDx();
}
if (m_specIDs!= 0)
if (m_spectrumIDcount!= 0)
{
localWorkspace->getSpectrum(i)->setSpectrumNo(m_spectra[i].getSpectrumNo());
}
Expand Down Expand Up @@ -262,7 +262,7 @@ namespace Mantid
if (cols > 4 || cols < 1)
{
//there were more separators than there should have been, which isn't right, or something went rather wrong
throw std::runtime_error("Sets of values must have between 1 and 3 delimiters. Found " + std::to_string(cols) + ".");
throw std::runtime_error("Sets of values must have between 1 and 3 delimiters. Found " + boost::lexical_cast<std::string>(cols) + ".");
}
else if (cols != 1)
{
Expand Down Expand Up @@ -338,7 +338,7 @@ namespace Mantid
//is this the first bin in the spectra? if not this check has already been done for this spectra
//If the ID vector is completly empty then it's ok we're assigning them later
//if there are equal or less IDs than there are spectra, then there's been no ID assigned to this spectra and there should be
if (m_spectraStart && m_specIDs != 0 && !(m_spectra.size() < m_specIDs))
if (m_spectraStart && m_spectrumIDcount != 0 && !(m_spectra.size() < m_spectrumIDcount))
{
throw std::runtime_error("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 and the start of another.");
Expand Down Expand Up @@ -538,13 +538,14 @@ namespace Mantid
throw std::invalid_argument("Separators cannot contain numeric characters, plus signs, hyphens or 'e'");
}

m_comment = getProperty("CommentIndicator");
std::string tempcomment = getProperty("CommentIndicator");

if (!boost::regex_match(m_comment.begin(), m_comment.end(), boost::regex("[^0-9e"+ m_columnSep +"+-]+", boost::regex::perl)))
if (!boost::regex_match(tempcomment.begin(), tempcomment.end(), boost::regex("[^0-9e"+ m_columnSep +"+-]+", boost::regex::perl)))
{
throw std::invalid_argument("Comment markers cannot contain numeric characters, plus signs, hyphens,"
" 'e' or the selected separator character");
}
m_comment = tempcomment;

// Process the header information.
//processHeader(file);
Expand Down

0 comments on commit 69495fb

Please sign in to comment.