From 66a87c4642d25f27ca24254cfeb0a0c4b21036b1 Mon Sep 17 00:00:00 2001 From: Treeston Date: Fri, 7 Sep 2018 20:31:04 +0200 Subject: Scripts/Commands: New argument parsing methodology (PR #22363) - Detect the arguments accepted by the command handler - Tokenize out those arguments automatically and feed them to the handler - Unmatched rest of the string can be accepted by trailing char const* or CommandArgs* --- src/common/Utilities/Util.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/common/Utilities/Util.cpp') diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp index eefa8bbf0a1..9b9474d3b59 100644 --- a/src/common/Utilities/Util.cpp +++ b/src/common/Utilities/Util.cpp @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include #include @@ -573,3 +575,9 @@ bool StringToBool(std::string const& str) std::transform(str.begin(), str.end(), lowerStr.begin(), ::tolower); return lowerStr == "1" || lowerStr == "true" || lowerStr == "yes"; } + +bool StringContainsStringI(std::string const& haystack, std::string const& needle) +{ + return haystack.end() != + std::search(haystack.begin(), haystack.end(), needle.begin(), needle.end(), [](char c1, char c2) { return std::toupper(c1) == std::toupper(c2); }); +} -- cgit v1.2.3