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

Function SplitStringT

src/butil/strings/string_split.cc:17–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15
16template <typename STR>
17void 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
38template <typename STR>
39bool SplitStringIntoKeyValueT(const STR& line,

Callers 2

SplitStringFunction · 0.85
SplitStringDontTrimFunction · 0.85

Calls 5

TrimWhitespaceFunction · 0.85
clearMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected