mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2018 CSV data. First working version of CSV import
This commit is contained in:
@@ -34,7 +34,13 @@ std::string RiaStdStringTools::trimString(const std::string& s)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaStdStringTools::isNumber(const std::string& s)
|
||||
{
|
||||
return (s.find_first_not_of("0123456789.eE-") != std::string::npos);
|
||||
if (s.size() == 0) return false;
|
||||
if (findCharMatchCount(s, '.') > 1) return false;
|
||||
if (findCharMatchCount(s, '-') > 1) return false;
|
||||
if (findCharMatchCount(s, 'e') > 1) return false;
|
||||
if (findCharMatchCount(s, 'E') > 1) return false;
|
||||
|
||||
return (s.find_first_not_of("0123456789.eE-") == std::string::npos);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -79,3 +85,17 @@ std::vector<std::string> RiaStdStringTools::splitStringBySpace(const std::string
|
||||
|
||||
return words;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RiaStdStringTools::findCharMatchCount(const std::string& s, char c)
|
||||
{
|
||||
size_t count = 0;
|
||||
size_t pos = 0;
|
||||
while ((pos = s.find_first_of(c, pos + 1)) != std::string::npos)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -52,5 +52,7 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static size_t findCharMatchCount(const std::string& s, char c);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user