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

Function SplitStringIntoKeyValuePairsT

src/butil/strings/string_split.cc:166–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164
165template<typename STR>
166bool SplitStringIntoKeyValuePairsT(const STR& line,
167 char key_value_delimiter,
168 char key_value_pair_delimiter,
169 std::vector<std::pair<STR, STR> >* key_value_pairs) {
170 key_value_pairs->clear();
171
172 std::vector<STR> pairs;
173 SplitString(line, key_value_pair_delimiter, &pairs);
174
175 bool success = true;
176 for (size_t i = 0; i < pairs.size(); ++i) {
177 // Don't add empty pairs into the result.
178 if (pairs[i].empty())
179 continue;
180
181 STR key;
182 STR value;
183 if (!SplitStringIntoKeyValueT(pairs[i], key_value_delimiter, &key, &value)) {
184 // Don't return here, to allow for pairs without associated
185 // value or key; just record that the split failed.
186 success = false;
187 }
188 key_value_pairs->emplace_back(key, value);
189 }
190 return success;
191}
192
193bool SplitStringIntoKeyValuePairs(const std::string& line,
194 char key_value_delimiter,

Callers 1

Calls 5

SplitStringIntoKeyValueTFunction · 0.85
SplitStringFunction · 0.70
clearMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected