mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-12 08:25:03 -05:00
#2003 Move conversion from string to double into RiaStdStringTools
This commit is contained in:
1 parent
713998fb38
commit
50b2717ed2
4 files changed
+19
-4
No files matched your search
@@ -54,3 +54,16 @@ int RiaStdStringTools::toInt(const std::string& s)
|
|||||||
|
|
||||||
return intValue;
|
return intValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
double RiaStdStringTools::toDouble(const std::string& s)
|
||||||
|
{
|
||||||
|
double doubleValue = -1.0;
|
||||||
|
|
||||||
|
char* end;
|
||||||
|
doubleValue = std::strtod(s.data(), &end);
|
||||||
|
|
||||||
|
return doubleValue;
|
||||||
|
}
|
||||||
@@ -30,5 +30,6 @@ public:
|
|||||||
static bool isNumber(const std::string& s);
|
static bool isNumber(const std::string& s);
|
||||||
|
|
||||||
static int toInt(const std::string& s);
|
static int toInt(const std::string& s);
|
||||||
|
static double toDouble(const std::string& s);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "RiaDateStringParser.h"
|
#include "RiaDateStringParser.h"
|
||||||
#include "RiaLogging.h"
|
#include "RiaLogging.h"
|
||||||
|
#include "RiaStdStringTools.h"
|
||||||
|
|
||||||
#include "RifEclipseUserDataKeywordTools.h"
|
#include "RifEclipseUserDataKeywordTools.h"
|
||||||
|
|
||||||
@@ -283,8 +284,6 @@ bool RifEclipseUserDataParserTools::hasTimeUnit(const std::string& word)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool RifEclipseUserDataParserTools::hasOnlyValidDoubleValues(const std::vector<std::string>& words, std::vector<double>* doubleValues)
|
bool RifEclipseUserDataParserTools::hasOnlyValidDoubleValues(const std::vector<std::string>& words, std::vector<double>* doubleValues)
|
||||||
{
|
{
|
||||||
char* end;
|
|
||||||
|
|
||||||
bool onlyValidValues = true;
|
bool onlyValidValues = true;
|
||||||
|
|
||||||
for (const auto& word : words)
|
for (const auto& word : words)
|
||||||
@@ -295,7 +294,7 @@ bool RifEclipseUserDataParserTools::hasOnlyValidDoubleValues(const std::vector<s
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double doubleVal = strtod(word.data(), &end);
|
double doubleVal = RiaStdStringTools::toDouble(word);
|
||||||
doubleValues->push_back(doubleVal);
|
doubleValues->push_back(doubleVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include "RifKeywordVectorParser.h"
|
#include "RifKeywordVectorParser.h"
|
||||||
|
|
||||||
|
#include "RiaStdStringTools.h"
|
||||||
|
|
||||||
#include "RifEclipseUserDataParserTools.h"
|
#include "RifEclipseUserDataParserTools.h"
|
||||||
|
|
||||||
#include "cvfAssert.h"
|
#include "cvfAssert.h"
|
||||||
@@ -90,7 +92,7 @@ void RifKeywordVectorParser::parseData(const QString& data)
|
|||||||
|
|
||||||
while (RifEclipseUserDataParserTools::isANumber(line))
|
while (RifEclipseUserDataParserTools::isANumber(line))
|
||||||
{
|
{
|
||||||
keywordBasedVector.values.push_back(std::stod(line));
|
keywordBasedVector.values.push_back(RiaStdStringTools::toDouble(line));
|
||||||
std::getline(streamData, line);
|
std::getline(streamData, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user