MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / Split

Function Split

extern/re2/re2/testing/regexp_generator.cc:256–274  ·  view source on GitHub ↗

Split string everywhere a substring is found, returning vector of pieces.

Source from the content-addressed store, hash-verified

254// Split string everywhere a substring is found, returning
255// vector of pieces.
256std::vector<std::string> Split(const StringPiece& sep, const StringPiece& s) {
257 std::vector<std::string> v;
258
259 if (sep.empty())
260 return Explode(s);
261
262 const char *p = s.data();
263 for (const char *q = s.data(); q + sep.size() <= s.data() + s.size(); q++) {
264 if (StringPiece(q, sep.size()) == sep) {
265 v.push_back(std::string(p, q - p));
266 p = q + sep.size();
267 q = p - 1; // -1 for ++ in loop
268 continue;
269 }
270 }
271 if (p < s.data() + s.size())
272 v.push_back(std::string(p, s.data() + s.size() - p));
273 return v;
274}
275
276} // namespace re2

Callers 6

TESTFunction · 0.85
EgrepTestFunction · 0.85
TESTFunction · 0.85
TESTFunction · 0.85
TESTFunction · 0.85
TESTFunction · 0.85

Calls 6

ExplodeFunction · 0.85
StringPieceClass · 0.85
emptyMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by 6

TESTFunction · 0.68
EgrepTestFunction · 0.68
TESTFunction · 0.68
TESTFunction · 0.68
TESTFunction · 0.68
TESTFunction · 0.68