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

Function split_program_name

simcore/framework/src/cli/cli.hpp:3133–3153  ·  view source on GitHub ↗

Split a string into a program name and command line arguments the string is assumed to contain a file name followed by other arguments the return value contains is a pair with the first argument containing the program name and the second everything else.

Source from the content-addressed store, hash-verified

3131/// the return value contains is a pair with the first argument containing the program name and the second
3132/// everything else.
3133inline std::pair<std::string, std::string> split_program_name(std::string commandline) {
3134 // try to determine the programName
3135 std::pair<std::string, std::string> vals;
3136 trim(commandline);
3137 auto esp = commandline.find_first_of(' ', 1);
3138 while (detail::check_path(commandline.substr(0, esp).c_str()) != path_type::file) {
3139 esp = commandline.find_first_of(' ', esp + 1);
3140 if (esp == std::string::npos) {
3141 // if we have reached the end and haven't found a valid file just assume the first argument is the
3142 // program name
3143 esp = commandline.find_first_of(' ', 1);
3144 break;
3145 }
3146 }
3147 vals.first = commandline.substr(0, esp);
3148 rtrim(vals.first);
3149 // strip the program name
3150 vals.second = (esp != std::string::npos) ? commandline.substr(esp + 1) : std::string{};
3151 ltrim(vals.second);
3152 return vals;
3153}
3154
3155} // namespace detail
3156/// @}

Callers 1

parseMethod · 0.85

Calls 5

check_pathFunction · 0.85
rtrimFunction · 0.85
ltrimFunction · 0.85
find_first_ofMethod · 0.80
trimFunction · 0.50

Tested by

no test coverage detected