mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-11-14 05:43:29 +00:00
@@ -189,15 +189,25 @@ string &replace_all(string &str, string_view from, string_view to) {
|
||||
return str;
|
||||
}
|
||||
|
||||
vector<string> split(const string& s, const string& delimiters) {
|
||||
vector<string> result;
|
||||
template <class T>
|
||||
static auto split_impl(T s, T delims) {
|
||||
vector<std::decay_t<T>> result;
|
||||
size_t base = 0;
|
||||
size_t found;
|
||||
while (true) {
|
||||
found = s.find_first_of(delimiters, base);
|
||||
found = s.find_first_of(delims, base);
|
||||
result.push_back(s.substr(base, found - base));
|
||||
if (found == string::npos) break;
|
||||
if (found == string::npos)
|
||||
break;
|
||||
base = found + 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
vector<string> split(const string &s, const string &delims) {
|
||||
return split_impl<const string&>(s, delims);
|
||||
}
|
||||
|
||||
vector<string_view> split_ro(string_view s, string_view delims) {
|
||||
return split_impl<string_view>(s, delims);
|
||||
}
|
||||
|
||||
@@ -159,7 +159,8 @@ uint32_t binary_gcd(uint32_t u, uint32_t v);
|
||||
int switch_mnt_ns(int pid);
|
||||
int gen_rand_str(char *buf, int len, bool varlen = true);
|
||||
std::string &replace_all(std::string &str, std::string_view from, std::string_view to);
|
||||
std::vector<std::string> split(const std::string& s, const std::string& delimiters);
|
||||
std::vector<std::string> split(const std::string &s, const std::string &delims);
|
||||
std::vector<std::string_view> split_ro(std::string_view, std::string_view delims);
|
||||
|
||||
struct exec_t {
|
||||
bool err = false;
|
||||
|
||||
Reference in New Issue
Block a user