diff options
| author | iwubcode <iwubcode@users.noreply.github.com> | 2020-05-23 18:40:10 -0500 |
|---|---|---|
| committer | iwubcode <iwubcode@users.noreply.github.com> | 2020-05-23 18:40:10 -0500 |
| commit | 85e11cd4ab900b1c4bdb705b577fad7c25f2ae65 (patch) | |
| tree | be675c0cd18d806f3f313815da8656454afa7667 /Source/Core/Common/StringUtil.h | |
| parent | 393ce529af87b1b11877eb6e376c54592f4160ee (diff) | |
Common / Core: Update StringUtil to allow specifying the base, default to 0. Fix ActionReplay code to use this instead of prepending '0x' in front
Diffstat (limited to 'Source/Core/Common/StringUtil.h')
| -rw-r--r-- | Source/Core/Common/StringUtil.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Source/Core/Common/StringUtil.h b/Source/Core/Common/StringUtil.h index 969c6e9ea1..8c3db9ce34 100644 --- a/Source/Core/Common/StringUtil.h +++ b/Source/Core/Common/StringUtil.h @@ -55,7 +55,7 @@ std::string ReplaceAll(std::string result, std::string_view src, std::string_vie bool TryParse(const std::string& str, bool* output); template <typename T, std::enable_if_t<std::is_integral_v<T> || std::is_enum_v<T>>* = nullptr> -bool TryParse(const std::string& str, T* output) +bool TryParse(const std::string& str, T* output, int base = 0) { char* end_ptr = nullptr; @@ -67,9 +67,9 @@ bool TryParse(const std::string& str, T* output) ReadType value; if constexpr (std::is_unsigned_v<T>) - value = std::strtoull(str.c_str(), &end_ptr, 0); + value = std::strtoull(str.c_str(), &end_ptr, base); else - value = std::strtoll(str.c_str(), &end_ptr, 0); + value = std::strtoll(str.c_str(), &end_ptr, base); // Fail if the end of the string wasn't reached. if (end_ptr == nullptr || *end_ptr != '\0') |
