From 0e8d4cb6ac679fd52a320aae9d1a478e47728116 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Mon, 30 Dec 2019 17:28:35 -0600 Subject: StringUtil: Make TryParse of floats handle comma and dot decimal separators. --- Source/Core/Common/StringUtil.cpp | 45 --------------------------------------- 1 file changed, 45 deletions(-) (limited to 'Source/Core/Common/StringUtil.cpp') diff --git a/Source/Core/Common/StringUtil.cpp b/Source/Core/Common/StringUtil.cpp index 3eeb6d04fe..2369208f45 100644 --- a/Source/Core/Common/StringUtil.cpp +++ b/Source/Core/Common/StringUtil.cpp @@ -235,51 +235,6 @@ std::string_view StripQuotes(std::string_view s) return s; } -bool TryParse(const std::string& str, u16* const output) -{ - u64 value; - if (!TryParse(str, &value)) - return false; - - if (value >= 0x10000ull && value <= 0xFFFFFFFFFFFF0000ull) - return false; - - *output = static_cast(value); - return true; -} - -bool TryParse(const std::string& str, u32* const output) -{ - u64 value; - if (!TryParse(str, &value)) - return false; - - if (value >= 0x100000000ull && value <= 0xFFFFFFFF00000000ull) - return false; - - *output = static_cast(value); - return true; -} - -bool TryParse(const std::string& str, u64* const output) -{ - char* end_ptr = nullptr; - - // Set errno to a clean slate - errno = 0; - - u64 value = strtoull(str.c_str(), &end_ptr, 0); - - if (end_ptr == nullptr || *end_ptr != '\0') - return false; - - if (errno == ERANGE) - return false; - - *output = value; - return true; -} - bool TryParse(const std::string& str, bool* const output) { float value; -- cgit v1.2.3