MCPcopy Create free account
hub / github.com/ARM-software/armnn / ParseOptions

Function ParseOptions

samples/common/src/Utils/CmdArgsParser.cpp:34–70  ·  view source on GitHub ↗

* Parses all the command line options provided by the user and stores in a map. */

Source from the content-addressed store, hash-verified

32 * Parses all the command line options provided by the user and stores in a map.
33 */
34int ParseOptions(std::map<std::string, std::string>& options, std::map<std::string, std::string>& acceptedOptions,
35 char *argv[], int argc)
36{
37 for (int i = 1; i < argc; ++i)
38 {
39 std::string currentOption = std::string(argv[i]);
40 auto it = acceptedOptions.find(currentOption);
41 if (it != acceptedOptions.end())
42 {
43 if (i + 1 < argc && std::string(argv[i + 1]).rfind("--", 0) != 0)
44 {
45 std::string value = argv[++i];
46 options.insert({it->first, value});
47 }
48 else if (std::string(argv[i]) == "HELP")
49 {
50 std::cout << "Available options" << std::endl;
51 for (auto & acceptedOption : acceptedOptions)
52 {
53 std::cout << acceptedOption.first << " : " << acceptedOption.second << std::endl;
54 }
55 return 2;
56 }
57 else
58 {
59 std::cerr << std::string(argv[i]) << " option requires one argument." << std::endl;
60 return 1;
61 }
62 }
63 else
64 {
65 std::cerr << "Unrecognised option: " << std::string(argv[i]) << std::endl;
66 return 1;
67 }
68 }
69 return 0;
70}

Callers 11

mainFunction · 0.50
mainFunction · 0.50
mainFunction · 0.50
ClBackendModelContextMethod · 0.50
ClBackendContextMethod · 0.50
RuntimeImplMethod · 0.50
GetCpuAccNumberOfThreadsFunction · 0.50
CheckFastMathSupportFunction · 0.50
GetAllowExpandedDimsMethod · 0.50

Calls 1

endMethod · 0.45

Tested by

no test coverage detected