1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2025-01-08 18:09:45 +01:00

Add fallback parameter to UtilityClass::Int()

If necessary, the caller can provide a fallback to be returned in case
the input given isn't a valid integer, instead of having to duplicate
the is_number() check.
This commit is contained in:
Misa 2020-08-06 21:56:35 -07:00 committed by Ethan Lee
parent 78e87effe7
commit d1938a151f
2 changed files with 3 additions and 3 deletions

View file

@ -99,11 +99,11 @@ std::string UtilityClass::String( int _v )
return(os.str());
}
int UtilityClass::Int(const char* str)
int UtilityClass::Int(const char* str, int fallback /*= 0*/)
{
if (!is_number(str))
{
return 0;
return fallback;
}
return SDL_atoi(str);

View file

@ -37,7 +37,7 @@ public:
static std::string String(int _v);
static int Int(const char* str);
static int Int(const char* str, int fallback = 0);
static std::string GCString(std::vector<SDL_GameControllerButton> buttons);