#2018 CSV data. First working version of CSV import

This commit is contained in:
Bjørn Erik Jensen
2017-11-22 20:34:18 +01:00
parent d7dc304eca
commit fb24a9f29b
26 changed files with 1058 additions and 188 deletions

View File

@@ -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;
}

View File

@@ -52,5 +52,7 @@ private:
}
}
}
static size_t findCharMatchCount(const std::string& s, char c);
};