diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index c556d5040..c93418dbb 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -4,11 +4,11 @@ #include #include -#include #include -#include #include -#include +#include +#include +#include #include "common/common_paths.h" #include "common/logging/log.h" #include "common/string_util.h" @@ -71,40 +71,6 @@ std::string StripQuotes(const std::string& s) { return s; } -bool TryParse(const std::string& str, u32* const output) { - char* endptr = nullptr; - - // Reset errno to a value other than ERANGE - errno = 0; - - unsigned long value = strtoul(str.c_str(), &endptr, 0); - - if (!endptr || *endptr) - return false; - - if (errno == ERANGE) - return false; - -#if ULONG_MAX > UINT_MAX - if (value >= 0x100000000ull && value <= 0xFFFFFFFF00000000ull) - return false; -#endif - - *output = static_cast(value); - return true; -} - -bool TryParse(const std::string& str, bool* const output) { - if ("1" == str || "true" == ToLower(str)) - *output = true; - else if ("0" == str || "false" == ToLower(str)) - *output = false; - else - return false; - - return true; -} - std::string StringFromBool(bool value) { return value ? "True" : "False"; } diff --git a/src/common/string_util.h b/src/common/string_util.h index 43e73528d..38e457ae9 100644 --- a/src/common/string_util.h +++ b/src/common/string_util.h @@ -5,8 +5,6 @@ #pragma once #include -#include -#include #include #include #include "common/common_types.h" @@ -26,21 +24,6 @@ std::string StripQuotes(const std::string& s); std::string StringFromBool(bool value); -bool TryParse(const std::string& str, bool* output); -bool TryParse(const std::string& str, u32* output); - -template -static bool TryParse(const std::string& str, N* const output) { - std::istringstream iss(str); - - N tmp = 0; - if (iss >> tmp) { - *output = tmp; - return true; - } else - return false; -} - std::string TabsToSpaces(int tab_size, std::string in); void SplitString(const std::string& str, char delim, std::vector& output);