1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-26 14:38:30 +02:00

Add is_positive_num() to UtilityClass.cpp

This is a convenience function to tell if a string is not only a number
(and can thus be passed into atoi()), but is also positive in
particular.
This commit is contained in:
Misa 2020-04-17 14:52:09 -07:00 committed by Ethan Lee
parent a28f68968c
commit 9b4975e396
2 changed files with 14 additions and 0 deletions

View File

@ -207,3 +207,15 @@ void UtilityClass::updateglow()
if (glow < 2) glowdir = 0;
}
}
bool is_positive_num(const std::string& str)
{
for (size_t i = 0; i < str.length(); i++)
{
if (!std::isdigit(str[i]))
{
return false;
}
}
return true;
}

View File

@ -11,6 +11,8 @@ std::vector<std::string> split(const std::string &s, char delim, std::vector<std
std::vector<std::string> split(const std::string &s, char delim);
bool is_positive_num(const std::string& str);
//helperClass
class UtilityClass