diff options
| author | Léo Lam <leo@leolam.fr> | 2020-01-05 12:12:09 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-05 12:12:09 +0100 |
| commit | f35f4f2bf06eefe20ee3338a84b82aa30fe20e3a (patch) | |
| tree | 7e425055f2cbfa4c81576a8990ecb3ef06758189 /Source/Core/Common/StringUtil.cpp | |
| parent | 04e9279f3d5ccefb45630fb3ddd4f00c5ed4bebc (diff) | |
| parent | 0e8d4cb6ac679fd52a320aae9d1a478e47728116 (diff) | |
Merge pull request #8541 from jordan-woyak/float-parse-fix
StringUtil: Make TryParse of floats handle comma and dot decimal separators.
Diffstat (limited to 'Source/Core/Common/StringUtil.cpp')
| -rw-r--r-- | Source/Core/Common/StringUtil.cpp | 45 |
1 files changed, 0 insertions, 45 deletions
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<u16>(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<u32>(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; |
