MCPcopy Create free account
hub / github.com/apache/incubator-pegasus / parse_kv_map

Function parse_kv_map

src/utils/strings.cpp:317–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

315}
316
317bool parse_kv_map(const char *args,
318 /*out*/ std::map<std::string, std::string> &kv_map,
319 char item_splitter,
320 char kv_splitter,
321 bool allow_dup_key)
322{
323 kv_map.clear();
324 std::vector<std::string> splits;
325 split_args(args, splits, item_splitter);
326 for (std::string &i : splits) {
327 if (i.empty())
328 continue;
329 size_t pos = i.find(kv_splitter);
330 if (pos == std::string::npos) {
331 return false;
332 }
333 std::string key = i.substr(0, pos);
334 std::string value = i.substr(pos + 1);
335 if (!allow_dup_key && kv_map.find(key) != kv_map.end()) {
336 return false;
337 }
338 kv_map[key] = value;
339 }
340 return true;
341}
342
343void kv_map_to_stream(const std::map<std::string, std::string> &kv_map,
344 /*out*/ std::ostream &oss,

Callers 2

create_appFunction · 0.50

Calls 6

split_argsFunction · 0.85
substrMethod · 0.80
clearMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected