cmSystemTools: Add StringToInt helper
Convert a string to a signed integer and reject any extra input. Co-Author: Rolf Eike Beer <eike@sf-mail.de>
This commit is contained in:
parent
3350e4d209
commit
05d6531c7a
|
@ -2923,3 +2923,11 @@ std::vector<std::string> cmSystemTools::tokenize(const std::string& str,
|
||||||
}
|
}
|
||||||
return tokens;
|
return tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool cmSystemTools::StringToInt(const char* str, int* value)
|
||||||
|
{
|
||||||
|
char *endp;
|
||||||
|
*value = static_cast<int>(strtol(str, &endp, 10));
|
||||||
|
return (*endp == '\0') && (endp != str);
|
||||||
|
}
|
||||||
|
|
|
@ -458,6 +458,9 @@ public:
|
||||||
static std::vector<std::string> tokenize(const std::string& str,
|
static std::vector<std::string> tokenize(const std::string& str,
|
||||||
const std::string& sep);
|
const std::string& sep);
|
||||||
|
|
||||||
|
/** Convert string to int. Expected that the whole string is an integer */
|
||||||
|
static bool StringToInt(const char* str, int* value);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
struct WindowsFileRetry
|
struct WindowsFileRetry
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue