diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-11-27 02:59:26 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-11-27 23:32:12 +0300 |
commit | 1fd495484bb43a1e0b0d088874d7bc588d8d38c9 (patch) | |
tree | 1c975620150a8e30196379748871338fa89720ac /src/utils | |
parent | 42d107be2ecb0cf81c1a291bb4e63e78094bd62e (diff) | |
download | mv-1fd495484bb43a1e0b0d088874d7bc588d8d38c9.tar.gz mv-1fd495484bb43a1e0b0d088874d7bc588d8d38c9.tar.bz2 mv-1fd495484bb43a1e0b0d088874d7bc588d8d38c9.tar.xz mv-1fd495484bb43a1e0b0d088874d7bc588d8d38c9.zip |
Simplify command handlers.
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/stringutils.cpp | 16 | ||||
-rw-r--r-- | src/utils/stringutils.h | 2 |
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 |