diff options
| author | Lioncash <mathew1800@gmail.com> | 2017-02-24 22:56:33 -0500 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2017-02-25 00:03:20 -0500 |
| commit | beec40f178f3eb324d96378a5a9b18ebe407f171 (patch) | |
| tree | 18ccad5fd2075ad1c948668cf87919b9453d53e7 /Source/Core/Common/StringUtil.cpp | |
| parent | 51136681dfa77c88f548d187c9c7954f0ad6ac32 (diff) | |
IniFile: Handle s64/u64 values
Diffstat (limited to 'Source/Core/Common/StringUtil.cpp')
| -rw-r--r-- | Source/Core/Common/StringUtil.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Source/Core/Common/StringUtil.cpp b/Source/Core/Common/StringUtil.cpp index 67f88be160..d08e98b7ff 100644 --- a/Source/Core/Common/StringUtil.cpp +++ b/Source/Core/Common/StringUtil.cpp @@ -247,6 +247,25 @@ bool TryParse(const std::string& str, u32* const output) 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; |
