mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2003 Move conversion from string to integer into RiaStdStringTools
This commit is contained in:
@@ -28,3 +28,29 @@ std::string RiaStdStringTools::trimString(const std::string& s)
|
||||
|
||||
return sCopy;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaStdStringTools::isNumber(const std::string& s)
|
||||
{
|
||||
return (s.find_first_not_of("0123456789.eE-") != std::string::npos);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiaStdStringTools::toInt(const std::string& s)
|
||||
{
|
||||
int intValue = -1;
|
||||
|
||||
try
|
||||
{
|
||||
intValue = std::stoi(s);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
return intValue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user