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

Function get_names

simcore/framework/src/cli/cli.hpp:1924–1954  ·  view source on GitHub ↗

Get a vector of short names, one of long names, and a single name

Source from the content-addressed store, hash-verified

1922
1923/// Get a vector of short names, one of long names, and a single name
1924inline std::tuple<std::vector<std::string>, std::vector<std::string>, std::string> get_names(
1925 const std::vector<std::string> &input) {
1926 std::vector<std::string> short_names;
1927 std::vector<std::string> long_names;
1928 std::string pos_name;
1929
1930 for (std::string name : input) {
1931 if (name.length() == 0) {
1932 continue;
1933 }
1934 if (name.length() > 1 && name[0] == '-' && name[1] != '-') {
1935 if (name.length() == 2 && valid_first_char(name[1]))
1936 short_names.emplace_back(1, name[1]);
1937 else
1938 throw BadNameString::OneCharName(name);
1939 } else if (name.length() > 2 && name.substr(0, 2) == "--") {
1940 name = name.substr(2);
1941 if (valid_name_string(name))
1942 long_names.push_back(name);
1943 else
1944 throw BadNameString::BadLongName(name);
1945 } else if (name == "-" || name == "--") {
1946 throw BadNameString::DashesOnly(name);
1947 } else {
1948 if (pos_name.length() > 0) throw BadNameString::MultiPositionalNames(name);
1949 pos_name = name;
1950 }
1951 }
1952
1953 return std::tuple<std::vector<std::string>, std::vector<std::string>, std::string>(short_names, long_names, pos_name);
1954}
1955
1956} // namespace detail
1957} // namespace CLI

Callers 1

OptionMethod · 0.85

Calls 5

valid_first_charFunction · 0.85
valid_name_stringFunction · 0.85
emplace_backMethod · 0.80
lengthMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected