MCPcopy Create free account
hub / github.com/Tencent/TAD_Sim / find_member

Function find_member

simcore/framework/src/cli/cli.hpp:366–390  ·  view source on GitHub ↗

Check if a string is a member of a list of strings and optionally ignore case or ignore underscores

Source from the content-addressed store, hash-verified

364
365/// Check if a string is a member of a list of strings and optionally ignore case or ignore underscores
366inline std::ptrdiff_t find_member(std::string name, const std::vector<std::string> names, bool ignore_case = false,
367 bool ignore_underscore = false) {
368 auto it = std::end(names);
369 if (ignore_case) {
370 if (ignore_underscore) {
371 name = detail::to_lower(detail::remove_underscore(name));
372 it = std::find_if(std::begin(names), std::end(names), [&name](std::string local_name) {
373 return detail::to_lower(detail::remove_underscore(local_name)) == name;
374 });
375 } else {
376 name = detail::to_lower(name);
377 it = std::find_if(std::begin(names), std::end(names),
378 [&name](std::string local_name) { return detail::to_lower(local_name) == name; });
379 }
380
381 } else if (ignore_underscore) {
382 name = detail::remove_underscore(name);
383 it = std::find_if(std::begin(names), std::end(names),
384 [&name](std::string local_name) { return detail::remove_underscore(local_name) == name; });
385 } else {
386 it = std::find(std::begin(names), std::end(names), name);
387 }
388
389 return (it != std::end(names)) ? (it - std::begin(names)) : (-1);
390}
391
392/// Find a trigger string and call a modify callable function that takes the current string and starting position of the
393/// trigger and returns the position in the string to search for the next trigger string

Callers 4

check_snameMethod · 0.85
check_lnameMethod · 0.85
check_fnameMethod · 0.85
get_flag_valueMethod · 0.85

Calls 5

endFunction · 0.85
to_lowerFunction · 0.85
remove_underscoreFunction · 0.85
beginFunction · 0.85
findFunction · 0.85

Tested by

no test coverage detected