mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-30 05:06:14 -05:00
Add helper to get int from variable
This commit is contained in:
@@ -44,4 +44,14 @@ std::optional<double> GetDouble(const std::string &str)
|
||||
return {};
|
||||
}
|
||||
|
||||
std::optional<int> GetInt(const std::string &str)
|
||||
{
|
||||
char *end = nullptr;
|
||||
int value = std::strtol(str.c_str(), &end, 10);
|
||||
if (end != str.c_str() && *end == '\0') {
|
||||
return value;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
|
||||
Reference in New Issue
Block a user