diff --git a/desktop_version/src/UtilityClass.cpp b/desktop_version/src/UtilityClass.cpp index 9ff685f6..8d27de2a 100644 --- a/desktop_version/src/UtilityClass.cpp +++ b/desktop_version/src/UtilityClass.cpp @@ -205,6 +205,18 @@ void UtilityClass::updateglow() } } +bool is_number(const char* str) +{ + for (int i = 0; str[i] != '\0'; i++) + { + if (!SDL_isdigit(static_cast(str[i])) && (i != 0 || str[0] != '-')) + { + return false; + } + } + return true; +} + bool is_positive_num(const std::string& str, bool hex) { for (size_t i = 0; i < str.length(); i++) diff --git a/desktop_version/src/UtilityClass.h b/desktop_version/src/UtilityClass.h index 42558fe1..923f8d64 100644 --- a/desktop_version/src/UtilityClass.h +++ b/desktop_version/src/UtilityClass.h @@ -11,6 +11,8 @@ std::vector split(const std::string &s, char delim, std::vector split(const std::string &s, char delim); +bool is_number(const char* str); + bool is_positive_num(const std::string& str, bool hex); bool endsWith(const std::string& str, const std::string& suffix);