| 11 | namespace leveldb { |
| 12 | |
| 13 | void SplitString(const std::string& full, const std::string& delim, |
| 14 | std::vector<std::string>* result) { |
| 15 | result->clear(); |
| 16 | if (full.empty()) { |
| 17 | return; |
| 18 | } |
| 19 | |
| 20 | std::string tmp; |
| 21 | std::string::size_type pos_begin = full.find_first_not_of(delim); |
| 22 | std::string::size_type comma_pos = 0; |
| 23 | |
| 24 | while (pos_begin != std::string::npos) { |
| 25 | comma_pos = full.find(delim, pos_begin); |
| 26 | if (comma_pos != std::string::npos) { |
| 27 | tmp = full.substr(pos_begin, comma_pos - pos_begin); |
| 28 | pos_begin = comma_pos + delim.length(); |
| 29 | } else { |
| 30 | tmp = full.substr(pos_begin); |
| 31 | pos_begin = comma_pos; |
| 32 | } |
| 33 | |
| 34 | if (!tmp.empty()) { |
| 35 | result->push_back(tmp); |
| 36 | tmp.clear(); |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | void SplitStringEnd(const std::string& full, std::string* begin_part, std::string* end_part, |
| 42 | std::string delim) { |