MCPcopy Create free account
hub / github.com/cyrusbehr/tensorrt-cpp-api / tryGetNextArgument

Function tryGetNextArgument

src/cmd_line_parser.h:25–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23};
24
25inline bool tryGetNextArgument(int argc, char *argv[], int &currentIndex, std::string &value, std::string flag, bool printErrors = true) {
26 if (currentIndex + 1 >= argc) {
27 if (printErrors)
28 std::cout << "Error: No arguments provided for flag '" << flag << "'" << std::endl;
29 return false;
30 }
31
32 std::string nextArgument = argv[currentIndex + 1];
33 if (nextArgument.substr(0, 2) == "--") {
34 if (printErrors)
35 std::cout << "Error: No arguments provided for flag '" << flag << "'" << std::endl;
36 return false;
37 }
38
39 value = argv[++currentIndex];
40 return true;
41};
42
43inline bool parseArguments(int argc, char *argv[], CommandLineArguments &arguments) {
44 if (argc == 1) {

Callers 1

parseArgumentsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected