mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
Добавляем функции разбора строки через разделитель
с использованием векторов для быстрого доступа
This commit is contained in:
@@ -204,4 +204,23 @@ void cleanString(String& str) {
|
||||
for (size_t i = 0; i < str.length(); i++) {
|
||||
if (allowedChars.indexOf(str.charAt(i)) == -1) str.setCharAt(i, ' ');
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<String> splitStr(const String& str, const String& delimiter) {
|
||||
std::vector<String> result;
|
||||
size_t newPos, pos = 0;
|
||||
while ((newPos = str.indexOf(delimiter, pos)) != -1) {
|
||||
result.push_back(str.substring(pos, newPos));
|
||||
pos = newPos + delimiter.length();
|
||||
}
|
||||
result.push_back(str.substring(pos));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
bool strInVector(const String& str, const std::vector<String>& vec) {
|
||||
for (size_t i = 0; i < vec.size(); i++) {
|
||||
if (vec[i] == str) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user