diff options
author | Treeston <treeston.mmoc@gmail.com> | 2020-08-24 16:17:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-24 16:17:56 +0200 |
commit | 11c4a60fbe9d471618e0579f588706746ff3e439 (patch) | |
tree | f34844cbc943b9e6aa1c9d78a1da318893dc8101 /src/common/Utilities/Util.cpp | |
parent | ec783fcbb59fcd6e657bc1a39c2b073fd7506ed4 (diff) |
[3.3.5] Core/ChatCommands: C++17 cleanup (if constexpr + std::string_view)
Diffstat (limited to 'src/common/Utilities/Util.cpp')
-rw-r--r-- | src/common/Utilities/Util.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp index da086c6b6cc..cb70cc114d3 100644 --- a/src/common/Utilities/Util.cpp +++ b/src/common/Utilities/Util.cpp @@ -651,9 +651,13 @@ void Trinity::Impl::HexStrToByteArray(std::string_view str, uint8* out, size_t o } } -bool StringToBool(std::string_view str) +Optional<bool> StringToBool(std::string_view str) { - return ((str == "1") || StringEqualI(str, "true") || StringEqualI(str, "yes")); + if (str == "1" || StringEqualI(str, "y") || StringEqualI(str, "on") || StringEqualI(str, "yes") || StringEqualI(str, "true")) + return true; + if (str == "0" || StringEqualI(str, "n") || StringEqualI(str, "off") || StringEqualI(str, "no") || StringEqualI(str, "false")) + return false; + return std::nullopt; } bool StringEqualI(std::string_view str1, std::string_view str2) |