This commit is contained in:
Print3M
2023-09-15 22:06:35 +02:00
commit a3929ff50c
8 changed files with 459 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
#include "utils.hpp"
#include "detectors.hpp"
#include <string>
#include <codecvt>
#include <vector>
std::string utils::bstr_to_str(BSTR bstr) {
if (!bstr) return std::string("");
std::wstring ws(bstr, SysStringLen(bstr));
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
std::string narrow = converter.to_bytes(ws);
return narrow;
}
std::string utils::lowercase(std::string str) {
std::string result = "";
for (auto c : str) {
result += std::tolower(c);
}
return result;
}
bool utils::str_includes(std::string str, std::vector<std::string> includes) {
for (auto i : includes) {
if (str.find(i) != std::string::npos) {
return true;
}
}
return false;
}