mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2018 CSV import. Fix decimal point/locale
This commit is contained in:
@@ -32,15 +32,17 @@ std::string RiaStdStringTools::trimString(const std::string& s)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaStdStringTools::isNumber(const std::string& s)
|
||||
bool RiaStdStringTools::isNumber(const std::string& s, char decimalPoint)
|
||||
{
|
||||
if (s.size() == 0) return false;
|
||||
if (findCharMatchCount(s, '.') > 1) return false;
|
||||
if (findCharMatchCount(s, decimalPoint) > 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);
|
||||
std::string matchChars("0123456789eE-");
|
||||
matchChars.append(1, decimalPoint);
|
||||
return (s.find_first_not_of(matchChars) == std::string::npos);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -31,7 +31,7 @@ class RiaStdStringTools
|
||||
{
|
||||
public:
|
||||
static std::string trimString(const std::string& s);
|
||||
static bool isNumber(const std::string& s);
|
||||
static bool isNumber(const std::string& s, char decimalPoint);
|
||||
|
||||
static int toInt(const std::string& s);
|
||||
static double toDouble(const std::string& s);
|
||||
|
||||
Reference in New Issue
Block a user