summaryrefslogtreecommitdiff
path: root/src/utils/stringutils.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-11-27 02:59:26 +0300
committerAndrei Karas <akaras@inbox.ru>2012-11-27 23:32:12 +0300
commit1fd495484bb43a1e0b0d088874d7bc588d8d38c9 (patch)
tree1c975620150a8e30196379748871338fa89720ac /src/utils/stringutils.cpp
parent42d107be2ecb0cf81c1a291bb4e63e78094bd62e (diff)
downloadplus-1fd495484bb43a1e0b0d088874d7bc588d8d38c9.tar.gz
plus-1fd495484bb43a1e0b0d088874d7bc588d8d38c9.tar.bz2
plus-1fd495484bb43a1e0b0d088874d7bc588d8d38c9.tar.xz
plus-1fd495484bb43a1e0b0d088874d7bc588d8d38c9.zip
Simplify command handlers.
Diffstat (limited to 'src/utils/stringutils.cpp')
-rw-r--r--src/utils/stringutils.cpp16
1 files changed, 16 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;
+}