mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2797 Ensemble curves. Support for text ensemble parameters. Unit test
This commit is contained in:
@@ -139,7 +139,7 @@ bool RiaDateStringParser::tryParseMonthFirst(const std::string& s, int& year, in
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaDateStringParser::tryParseYear(const std::string& s, int &year)
|
||||
{
|
||||
if (containsAlphabetic(s)) return false;
|
||||
if (RiaStdStringTools::containsAlphabetic(s)) return false;
|
||||
|
||||
auto today = QDate::currentDate();
|
||||
int y = RiaStdStringTools::toInt(s);
|
||||
@@ -158,7 +158,7 @@ bool RiaDateStringParser::tryParseYear(const std::string& s, int &year)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaDateStringParser::tryParseMonth(const std::string& s, int &month)
|
||||
{
|
||||
if (containsAlphabetic(s))
|
||||
if (RiaStdStringTools::containsAlphabetic(s))
|
||||
{
|
||||
auto sMonth = s;
|
||||
sMonth = trimString(sMonth);
|
||||
@@ -190,7 +190,7 @@ bool RiaDateStringParser::tryParseMonth(const std::string& s, int &month)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaDateStringParser::tryParseDay(const std::string& s, int &day)
|
||||
{
|
||||
if (containsAlphabetic(s)) return false;
|
||||
if (RiaStdStringTools::containsAlphabetic(s)) return false;
|
||||
|
||||
int d = RiaStdStringTools::toInt(s);
|
||||
if (d >= 1 && d <= 31)
|
||||
@@ -203,14 +203,6 @@ bool RiaDateStringParser::tryParseDay(const std::string& s, int &day)
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaDateStringParser::containsAlphabetic(const std::string& s)
|
||||
{
|
||||
return std::find_if(s.begin(), s.end(), [](char c) { return isalpha(c); }) != s.end();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -42,7 +42,6 @@ private:
|
||||
static bool tryParseMonth(const std::string& s, int &month);
|
||||
static bool tryParseDay(const std::string& s, int &day);
|
||||
|
||||
static bool containsAlphabetic(const std::string& s);
|
||||
static std::string trimString(const std::string& s);
|
||||
};
|
||||
|
||||
|
||||
@@ -76,6 +76,24 @@ double RiaStdStringTools::toDouble(const std::string& s)
|
||||
return doubleValue;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaStdStringTools::containsAlphabetic(const std::string& s)
|
||||
{
|
||||
return std::find_if(s.begin(), s.end(), [](char c) { return isalpha(c); }) != s.end();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaStdStringTools::startsWithAlphabetic(const std::string& s)
|
||||
{
|
||||
if (s.empty()) return false;
|
||||
|
||||
return isalpha(s[0]);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -35,6 +35,8 @@ public:
|
||||
|
||||
static int toInt(const std::string& s);
|
||||
static double toDouble(const std::string& s);
|
||||
static bool containsAlphabetic(const std::string& s);
|
||||
static bool startsWithAlphabetic(const std::string& s);
|
||||
|
||||
static std::vector<std::string> splitStringBySpace(const std::string& s);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user