#2003 Move conversion from string to integer into RiaStdStringTools

This commit is contained in:
Magne Sjaastad
2017-11-03 14:36:59 +01:00
parent 265c0ebb70
commit 713998fb38
5 changed files with 82 additions and 56 deletions

View File

@@ -17,6 +17,9 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RifEclipseSummaryAddress.h"
#include "RiaStdStringTools.h"
#include "cvfAssert.h"
//--------------------------------------------------------------------------------------------------
@@ -37,7 +40,7 @@ RifEclipseSummaryAddress::RifEclipseSummaryAddress(SummaryVarCategory category,
switch (category)
{
case SUMMARY_REGION:
m_regionNumber = std::stoi(identifiers[INPUT_REGION_NUMBER]);
m_regionNumber = RiaStdStringTools::toInt(identifiers[INPUT_REGION_NUMBER]);
break;
case SUMMARY_REGION_2_REGION:
reg2regPair = regionToRegionPairFromUiText(identifiers[INPUT_REGION_2_REGION]);
@@ -71,7 +74,7 @@ RifEclipseSummaryAddress::RifEclipseSummaryAddress(SummaryVarCategory category,
break;
case SUMMARY_WELL_SEGMENT:
m_wellName = identifiers[INPUT_WELL_NAME];
m_wellSegmentNumber = std::stoi(identifiers[INPUT_SEGMENT_NUMBER]);
m_wellSegmentNumber = RiaStdStringTools::toInt(identifiers[INPUT_SEGMENT_NUMBER]);
case SUMMARY_BLOCK:
ijkTuple = ijkTupleFromUiText(identifiers[INPUT_CELL_IJK]);
m_cellI = std::get<0>(ijkTuple);
@@ -303,7 +306,8 @@ std::tuple<int, int, int> RifEclipseSummaryAddress::ijkTupleFromUiText(const std
auto textI = s.substr(0, firstSep);
auto textJ = s.substr(firstSep + 1, lastSep - firstSep - 1);
auto textK = s.substr(lastSep + 1);
return std::make_tuple(std::stoi(textI), std::stoi(textJ), std::stoi(textK));
return std::make_tuple(RiaStdStringTools::toInt(textI), RiaStdStringTools::toInt(textJ), RiaStdStringTools::toInt(textK));
}
//--------------------------------------------------------------------------------------------------
@@ -324,7 +328,8 @@ std::pair<int, int> RifEclipseSummaryAddress::regionToRegionPairFromUiText(const
CVF_ASSERT(sep != std::string::npos );
auto textReg = s.substr(0, sep);
auto textReg2 = s.substr(sep + 2);
return std::make_pair(std::stoi(textReg), std::stoi(textReg2));
return std::make_pair(RiaStdStringTools::toInt(textReg), RiaStdStringTools::toInt(textReg2));
}
//--------------------------------------------------------------------------------------------------

View File

@@ -19,6 +19,7 @@
#include "RifEclipseUserDataKeywordTools.h"
#include "RiaLogging.h"
#include "RiaStdStringTools.h"
#include "RifEclipseUserDataParserTools.h"
@@ -151,7 +152,7 @@ RifEclipseSummaryAddress RifEclipseUserDataKeywordTools::makeAndFillAddress(cons
{
if (columnHeaderText.size() > 0)
{
regionNumber = std::stoi(columnHeaderText[0]);
regionNumber = RiaStdStringTools::toInt(columnHeaderText[0]);
}
break;
}
@@ -178,9 +179,9 @@ RifEclipseSummaryAddress RifEclipseUserDataKeywordTools::makeAndFillAddress(cons
if (columnHeaderText.size() > 3)
{
wellName = columnHeaderText[0];
cellI = std::stoi(columnHeaderText[1]);
cellJ = std::stoi(columnHeaderText[2]);
cellK = std::stoi(columnHeaderText[3]);
cellI = RiaStdStringTools::toInt(columnHeaderText[1]);
cellJ = RiaStdStringTools::toInt(columnHeaderText[2]);
cellK = RiaStdStringTools::toInt(columnHeaderText[3]);
}
break;
}
@@ -195,35 +196,35 @@ RifEclipseSummaryAddress RifEclipseUserDataKeywordTools::makeAndFillAddress(cons
case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR:
if (columnHeaderText.size() > 4)
{
wellName = columnHeaderText[0];
lgrName = columnHeaderText[1];
cellI = std::stoi(columnHeaderText[2]);
cellJ = std::stoi(columnHeaderText[3]);
cellK = std::stoi(columnHeaderText[4]);
wellName = columnHeaderText[0];
lgrName = columnHeaderText[1];
cellI = RiaStdStringTools::toInt(columnHeaderText[2]);
cellJ = RiaStdStringTools::toInt(columnHeaderText[3]);
cellK = RiaStdStringTools::toInt(columnHeaderText[4]);
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT:
if (columnHeaderText.size() > 1)
{
wellName = columnHeaderText[0];
wellSegmentNumber = std::stoi(columnHeaderText[1]);
wellName = columnHeaderText[0];
wellSegmentNumber = RiaStdStringTools::toInt(columnHeaderText[1]);
}
break;
case RifEclipseSummaryAddress::SUMMARY_BLOCK:
if (columnHeaderText.size() > 2)
{
cellI = std::stoi(columnHeaderText[0]);
cellJ = std::stoi(columnHeaderText[1]);
cellK = std::stoi(columnHeaderText[2]);
cellI = RiaStdStringTools::toInt(columnHeaderText[0]);
cellJ = RiaStdStringTools::toInt(columnHeaderText[1]);
cellK = RiaStdStringTools::toInt(columnHeaderText[2]);
}
break;
case RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR:
if (columnHeaderText.size() > 3)
{
lgrName = columnHeaderText[0];
cellI = std::stoi(columnHeaderText[1]);
cellJ = std::stoi(columnHeaderText[2]);
cellK = std::stoi(columnHeaderText[3]);
lgrName = columnHeaderText[0];
cellI = RiaStdStringTools::toInt(columnHeaderText[1]);
cellJ = RiaStdStringTools::toInt(columnHeaderText[2]);
cellK = RiaStdStringTools::toInt(columnHeaderText[3]);
}
break;
case RifEclipseSummaryAddress::SUMMARY_CALCULATED: