| 15 | |
| 16 | template <typename STR> |
| 17 | void SplitStringT(const STR& str, |
| 18 | const typename STR::value_type s, |
| 19 | bool trim_whitespace, |
| 20 | std::vector<STR>* r) { |
| 21 | r->clear(); |
| 22 | size_t last = 0; |
| 23 | size_t c = str.size(); |
| 24 | for (size_t i = 0; i <= c; ++i) { |
| 25 | if (i == c || str[i] == s) { |
| 26 | STR tmp(str, last, i - last); |
| 27 | if (trim_whitespace) |
| 28 | TrimWhitespace(tmp, TRIM_ALL, &tmp); |
| 29 | // Avoid converting an empty or all-whitespace source string into a vector |
| 30 | // of one empty string. |
| 31 | if (i != c || !r->empty() || !tmp.empty()) |
| 32 | r->push_back(tmp); |
| 33 | last = i + 1; |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | template <typename STR> |
| 39 | bool SplitStringIntoKeyValueT(const STR& line, |
no test coverage detected