Mercurial > minori
comparison src/core/strings.cc @ 116:254b1d2b7096
settings: add torrents page, make rss feed configurable
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Tue, 07 Nov 2023 13:52:13 -0500 |
parents | ab191e28e69d |
children | 39521c47c7a3 |
comparison
equal
deleted
inserted
replaced
115:c72b907b9bef | 116:254b1d2b7096 |
---|---|
154 tmp = def; | 154 tmp = def; |
155 } | 155 } |
156 return tmp; | 156 return tmp; |
157 } | 157 } |
158 | 158 |
159 bool ToBool(const std::string& s, const bool def) { | |
160 if (s.length() < 4) | |
161 return def; | |
162 std::string l = Strings::ToLower(s); | |
163 if (Strings::BeginningMatchesSubstring(l, "true")) | |
164 return true; | |
165 else if (Strings::BeginningMatchesSubstring(l, "false")) | |
166 return false; | |
167 return def; | |
168 } | |
169 | |
170 std::string ToUtf8String(const bool b) { | |
171 return b ? "true" : "false"; | |
172 } | |
173 | |
159 uint64_t HumanReadableSizeToBytes(const std::string& str) { | 174 uint64_t HumanReadableSizeToBytes(const std::string& str) { |
160 const std::unordered_map<std::string, uint64_t> bytes_map = { | 175 const std::unordered_map<std::string, uint64_t> bytes_map = { |
161 {"KB", 1 << 10}, | 176 {"KB", 1 << 10}, |
162 {"MB", 1 << 20}, | 177 {"MB", 1 << 20}, |
163 {"GB", 1 << 30}, | 178 {"GB", 1 << 30}, |