| 7 | // split("one:two::three", ':'); will return 4 items |
| 8 | |
| 9 | inline std::vector<std::string> |
| 10 | split(const std::string &s, char delim, bool skip_empty = false) { |
| 11 | std::vector<std::string> elems; |
| 12 | std::stringstream ss(s); |
| 13 | string item; |
| 14 | while (std::getline(ss, item, delim)) |
| 15 | if (!(skip_empty && item.empty())) |
| 16 | elems.push_back(item); |
| 17 | return elems; |
| 18 | } |
| 19 | |
| 20 | // TODO support bool skip_empty = false |
| 21 | inline std::string join(const std::vector<std::string> &elems, const string& delim) { |
no test coverage detected