summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/stringutils.cpp16
-rw-r--r--src/utils/stringutils.h2
2 files changed, 18 insertions, 0 deletions
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 8c6d88d1c..7c7b76ea6 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -653,3 +653,19 @@ std::string getDateString()
strftime(buffer, 79, "%Y-%m-%d", timeinfo);
return std::string(buffer);
}
+
+signed char parseBoolean(const std::string &value)
+{
+ std::string opt = value.substr(0, 1);
+
+ if (opt == "1" ||
+ opt == "y" || opt == "Y" ||
+ opt == "t" || opt == "T")
+ return 1;
+ else if (opt == "0" ||
+ opt == "n" || opt == "N" ||
+ opt == "f" || opt == "F")
+ return 0;
+ else
+ return -1;
+}
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h
index cef7a9ccf..819b1a7c6 100644
--- a/src/utils/stringutils.h
+++ b/src/utils/stringutils.h
@@ -221,4 +221,6 @@ bool strStartWith(std::string str, std::string start) A_WARN_UNUSED;
std::string getDateString() A_WARN_UNUSED;
+signed char parseBoolean(const std::string &value);
+
#endif // UTILS_STRINGUTILS_H