summaryrefslogtreecommitdiff
path: root/src/common/string_util.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2018-11-13 14:09:05 -0500
committerGravatar Lioncash2018-11-13 18:13:45 -0500
commitf1219e3a874bb16f2928e8b9e879f2a4ddf22ab7 (patch)
treef74eecf8914cc377b8b7af64f6d50d33edafba1f /src/common/string_util.cpp
parentstring_util: Remove ThousandSeparate() (diff)
downloadyuzu-f1219e3a874bb16f2928e8b9e879f2a4ddf22ab7.tar.gz
yuzu-f1219e3a874bb16f2928e8b9e879f2a4ddf22ab7.tar.xz
yuzu-f1219e3a874bb16f2928e8b9e879f2a4ddf22ab7.zip
string_util: Remove TryParse()
This is an unused hold-over from Dolphin that was primarily used to parse values out of the .ini files. Given we already have libraries that do this for us, we don't need to keep this around.
Diffstat (limited to 'src/common/string_util.cpp')
-rw-r--r--src/common/string_util.cpp40
1 files changed, 3 insertions, 37 deletions
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index 731d1db34..5b004ef48 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -4,11 +4,11 @@
4 4
5#include <algorithm> 5#include <algorithm>
6#include <cctype> 6#include <cctype>
7#include <cerrno>
8#include <codecvt> 7#include <codecvt>
9#include <cstdio>
10#include <cstdlib> 8#include <cstdlib>
11#include <cstring> 9#include <iomanip>
10#include <locale>
11#include <sstream>
12#include "common/common_paths.h" 12#include "common/common_paths.h"
13#include "common/logging/log.h" 13#include "common/logging/log.h"
14#include "common/string_util.h" 14#include "common/string_util.h"
@@ -75,40 +75,6 @@ std::string StripQuotes(const std::string& s) {
75 return s; 75 return s;
76} 76}
77 77
78bool TryParse(const std::string& str, u32* const output) {
79 char* endptr = nullptr;
80
81 // Reset errno to a value other than ERANGE
82 errno = 0;
83
84 unsigned long value = strtoul(str.c_str(), &endptr, 0);
85
86 if (!endptr || *endptr)
87 return false;
88
89 if (errno == ERANGE)
90 return false;
91
92#if ULONG_MAX > UINT_MAX
93 if (value >= 0x100000000ull && value <= 0xFFFFFFFF00000000ull)
94 return false;
95#endif
96
97 *output = static_cast<u32>(value);
98 return true;
99}
100
101bool TryParse(const std::string& str, bool* const output) {
102 if ("1" == str || "true" == ToLower(str))
103 *output = true;
104 else if ("0" == str || "false" == ToLower(str))
105 *output = false;
106 else
107 return false;
108
109 return true;
110}
111
112std::string StringFromBool(bool value) { 78std::string StringFromBool(bool value) {
113 return value ? "True" : "False"; 79 return value ? "True" : "False";
114} 80}