| Index: base/string_split.cc
|
| diff --git a/base/string_split.cc b/base/string_split.cc
|
| index dc7e7adbc3a22abb44cd9d0f859d382d9b395674..b2b70eab10575bafe5dfa2e96664b101e5b4a983 100644
|
| --- a/base/string_split.cc
|
| +++ b/base/string_split.cc
|
| @@ -71,4 +71,38 @@ bool SplitStringIntoKeyValuePairs(
|
| return success;
|
| }
|
|
|
| +template <typename STR>
|
| +static void SplitStringUsingSubstrT(const STR& str,
|
| + const STR& s,
|
| + std::vector<STR>* r) {
|
| + typename STR::size_type begin_index = 0;
|
| + while (true) {
|
| + const typename STR::size_type end_index = str.find(s, begin_index);
|
| + if (end_index == STR::npos) {
|
| + const STR term = str.substr(begin_index);
|
| + STR tmp;
|
| + TrimWhitespace(term, TRIM_ALL, &tmp);
|
| + r->push_back(tmp);
|
| + return;
|
| + }
|
| + const STR term = str.substr(begin_index, end_index - begin_index);
|
| + STR tmp;
|
| + TrimWhitespace(term, TRIM_ALL, &tmp);
|
| + r->push_back(tmp);
|
| + begin_index = end_index + s.size();
|
| + }
|
| +}
|
| +
|
| +void SplitStringUsingSubstr(const string16& str,
|
| + const string16& s,
|
| + std::vector<string16>* r) {
|
| + SplitStringUsingSubstrT(str, s, r);
|
| +}
|
| +
|
| +void SplitStringUsingSubstr(const std::string& str,
|
| + const std::string& s,
|
| + std::vector<std::string>* r) {
|
| + SplitStringUsingSubstrT(str, s, r);
|
| +}
|
| +
|
| } // namespace base
|
|
|