MCPcopy Create free account
hub / github.com/apache/impala / SplitStringIntoNPiecesAllowEmpty

Function SplitStringIntoNPiecesAllowEmpty

be/src/gutil/strings/split.cc:308–323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306}
307
308void SplitStringIntoNPiecesAllowEmpty(const string& full,
309 const char* delim,
310 int pieces,
311 vector<string>* result) {
312 if (pieces == 0) {
313 // No limit when pieces is 0.
314 AppendTo(result, strings::Split(full, AnyOf(delim)));
315 } else {
316 // The input argument "pieces" specifies the max size that *result should
317 // be. However, the argument to the Limit() delimiter is the max number of
318 // delimiters, which should be one less than "pieces". Example: "a,b,c" has
319 // 3 pieces and two comma delimiters.
320 int limit = std::max(pieces - 1, 0);
321 AppendTo(result, strings::Split(full, Limit(AnyOf(delim), limit)));
322 }
323}
324
325// ----------------------------------------------------------------------
326// SplitStringAllowEmpty

Callers

nothing calls this directly

Calls 5

AppendToFunction · 0.85
SplitFunction · 0.85
AnyOfClass · 0.85
maxFunction · 0.85
LimitFunction · 0.85

Tested by

no test coverage detected