From 11c4a60fbe9d471618e0579f588706746ff3e439 Mon Sep 17 00:00:00 2001 From: Treeston Date: Mon, 24 Aug 2020 16:17:56 +0200 Subject: [3.3.5] Core/ChatCommands: C++17 cleanup (if constexpr + std::string_view) --- src/common/Utilities/Util.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/common/Utilities/Util.cpp') 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 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) -- cgit v1.2.3