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:
parent
78e87effe7
commit
d1938a151f
2 changed files with 3 additions and 3 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue