diff options
author | dec05eba <dec05eba@protonmail.com> | 2022-11-12 19:05:13 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2022-11-12 19:05:13 +0100 |
commit | 01f23292bf2451a0c7b9ada88c6314dcb09509b1 (patch) | |
tree | 2423c0abecd39f314f3475b2288d68a702fd6344 /src/StringUtils.cpp | |
parent | 224a5f3b2ed2141a94940fe73fc8ccb4b2f8d962 (diff) |
Matrix: add option to silence invites without declining them or hiding them (ignore)
Diffstat (limited to 'src/StringUtils.cpp')
-rw-r--r-- | src/StringUtils.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index 927c6e1..bc59730 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -3,15 +3,17 @@ namespace QuickMedia { template <typename T> - static void string_split_t(const std::string &str, const T &delimiter, StringSplitCallback callback_func) { + static void string_split_t(const std::string &str, const T &delimiter, StringSplitCallback callback_func, bool include_empty) { size_t index = 0; while(index < str.size()) { size_t new_index = str.find(delimiter, index); if(new_index == std::string::npos) new_index = str.size(); - if(!callback_func(str.data() + index, new_index - index)) - break; + if(include_empty || new_index - index > 0) { + if(!callback_func(str.data() + index, new_index - index)) + break; + } if constexpr(std::is_same<char, T>::value) index = new_index + 1; @@ -20,12 +22,12 @@ namespace QuickMedia { } } - void string_split(const std::string &str, const std::string &delimiter, StringSplitCallback callback_func) { - string_split_t(str, delimiter, callback_func); + void string_split(const std::string &str, const std::string &delimiter, StringSplitCallback callback_func, bool include_empty) { + string_split_t(str, delimiter, callback_func, include_empty); } - void string_split(const std::string &str, char delimiter, StringSplitCallback callback_func) { - string_split_t(str, delimiter, callback_func); + void string_split(const std::string &str, char delimiter, StringSplitCallback callback_func, bool include_empty) { + string_split_t(str, delimiter, callback_func, include_empty); } size_t string_replace_all(std::string &str, char old_char, char new_char) { |