From 1fd495484bb43a1e0b0d088874d7bc588d8d38c9 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 27 Nov 2012 02:59:26 +0300 Subject: Simplify command handlers. --- src/utils/stringutils.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/utils/stringutils.cpp') 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; +} -- cgit v1.2.3-70-g09d2