diff 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
line wrap: on
line diff
--- a/src/core/strings.cc	Tue Nov 07 12:04:51 2023 -0500
+++ b/src/core/strings.cc	Tue Nov 07 13:52:13 2023 -0500
@@ -156,6 +156,21 @@
 	return tmp;
 }
 
+bool ToBool(const std::string& s, const bool def) {
+	if (s.length() < 4)
+		return def;
+	std::string l = Strings::ToLower(s);
+	if (Strings::BeginningMatchesSubstring(l, "true"))
+		return true;
+	else if (Strings::BeginningMatchesSubstring(l, "false"))
+		return false;
+	return def;
+}
+
+std::string ToUtf8String(const bool b) {
+	return b ? "true" : "false";
+}
+
 uint64_t HumanReadableSizeToBytes(const std::string& str) {
 	const std::unordered_map<std::string, uint64_t> bytes_map = {
 		{"KB", 1 << 10},