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

Function SplitStringIntoKeyValuePairs

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

Source from the content-addressed store, hash-verified

998}
999
1000bool SplitStringIntoKeyValuePairs(const string& line,
1001 const string& key_value_delimiters,
1002 const string& key_value_pair_delimiters,
1003 vector<pair<string, string> >* kv_pairs) {
1004 kv_pairs->clear();
1005
1006 vector<string> pairs;
1007 SplitStringUsing(line, key_value_pair_delimiters.c_str(), &pairs);
1008
1009 bool success = true;
1010 for (const auto& pair : pairs) {
1011 string key;
1012 vector<string> value;
1013 if (!SplitStringIntoKeyValues(pair,
1014 key_value_delimiters,
1015 "", &key, &value)) {
1016 // Don't return here, to allow for keys without associated
1017 // values; just record that our split failed.
1018 success = false;
1019 }
1020 // we expect atmost one value because we passed in an empty vsep to
1021 // SplitStringIntoKeyValues
1022 DCHECK_LE(value.size(), 1);
1023 kv_pairs->push_back(make_pair(key, value.empty()? "" : value[0]));
1024 }
1025 return success;
1026}
1027
1028// ----------------------------------------------------------------------
1029// SplitLeadingDec32Values()

Callers

nothing calls this directly

Calls 6

SplitStringUsingFunction · 0.85
SplitStringIntoKeyValuesFunction · 0.85
push_backMethod · 0.80
clearMethod · 0.65
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected