MCPcopy Create free account
hub / github.com/apache/brpc / SplitStringUsingSubstrT

Function SplitStringUsingSubstrT

src/butil/strings/string_split.cc:66–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64
65template <typename STR>
66void SplitStringUsingSubstrT(const STR& str,
67 const STR& s,
68 std::vector<STR>* r) {
69 r->clear();
70 typename STR::size_type begin_index = 0;
71 while (true) {
72 const typename STR::size_type end_index = str.find(s, begin_index);
73 if (end_index == STR::npos) {
74 const STR term = str.substr(begin_index);
75 STR tmp;
76 TrimWhitespace(term, TRIM_ALL, &tmp);
77 r->push_back(tmp);
78 return;
79 }
80 const STR term = str.substr(begin_index, end_index - begin_index);
81 STR tmp;
82 TrimWhitespace(term, TRIM_ALL, &tmp);
83 r->push_back(tmp);
84 begin_index = end_index + s.size();
85 }
86}
87
88template<typename STR>
89void SplitStringAlongWhitespaceT(const STR& str, std::vector<STR>* result) {

Callers 1

SplitStringUsingSubstrFunction · 0.85

Calls 6

TrimWhitespaceFunction · 0.85
substrMethod · 0.80
clearMethod · 0.45
findMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected