| 26 | |
| 27 | template <typename Func> |
| 28 | void for_each_pair(std::string_view s, const char* delims, Func&& f) |
| 29 | { |
| 30 | auto pos = s.find_first_not_of(delims); |
| 31 | while (pos != s.npos) { |
| 32 | s.remove_prefix(pos); // trim delims from the front |
| 33 | auto end = s.find_first_of(delims); |
| 34 | auto kv = s.substr(0, end); |
| 35 | if (auto equal = kv.find('='); equal != kv.npos) { |
| 36 | f(kv.substr(0, equal), kv.substr(equal + 1)); |
| 37 | } else { |
| 38 | f(kv.substr(0, equal), std::string_view()); |
| 39 | } |
| 40 | pos = s.find_first_not_of(delims, end); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | using str_map_t = std::map<std::string,std::string>; |
| 45 |
no test coverage detected