aboutsummaryrefslogtreecommitdiff
path: root/src/common/Utilities/Util.cpp
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2018-09-07 20:31:04 +0200
committerShauren <shauren.trinity@gmail.com>2021-10-25 00:03:23 +0200
commit0c681b6509d4b517dc2e65a152753224df745605 (patch)
tree61c77765713f13d5d7006ef90e6c0a392ee6328a /src/common/Utilities/Util.cpp
parent42f366648f6b65753b3719f66b406e110ec9a871 (diff)
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* (cherry picked from commit 66a87c4642d25f27ca24254cfeb0a0c4b21036b1)
Diffstat (limited to 'src/common/Utilities/Util.cpp')
-rw-r--r--src/common/Utilities/Util.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp
index d5c1137cdd7..b8550c9a72e 100644
--- a/src/common/Utilities/Util.cpp
+++ b/src/common/Utilities/Util.cpp
@@ -22,6 +22,8 @@
#include <utf8.h>
#include <algorithm>
#include <sstream>
+#include <string>
+#include <cctype>
#include <cstdarg>
#include <ctime>
@@ -755,6 +757,12 @@ bool StringToBool(std::string const& str)
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); });
+}
+
float DegToRad(float degrees)
{
return degrees * (2.f * float(M_PI) / 360.f);