MCPcopy Create free account
hub / github.com/arrayfire/forge / parse_options

Function parse_options

CMakeModules/glsl2cpp.cpp:75–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75static
76opt_t parse_options(const vector<string>& args)
77{
78 opt_t options;
79
80 options["--name"] = "";
81 options["--type"] = "";
82 options["--file"] = "";
83 options["--output"] = "";
84 options["--namespace"] = "";
85 options["--eof"] = "";
86
87 //Parse Arguments
88 string curr_opt;
89 bool verbose = false;
90 for(auto arg : args) {
91 if(arg == "--verbose") {
92 verbose = true;
93 } else if(arg == "--formatted") {
94 formatted = true;
95 } else if(arg == "--version") {
96 cout << args[0] << " Original Author: Umar Arshad;\n Modified later by: Pradeep Garigipati." << endl;
97 } else if(arg == "--help") {
98 print_usage();
99 } else if(options.find(arg) != options.end()) {
100 curr_opt = arg;
101 } else if(curr_opt.empty()) {
102 //cerr << "Invalid Argument: " << arg << endl;
103 } else {
104 if(options[curr_opt] != "") {
105 options[curr_opt] += " " + arg;
106 }
107 else {
108 options[curr_opt] += arg;
109 }
110 }
111 }
112
113 if(verbose) {
114 for(auto opts : options) {
115 cout << get<0>(opts) << " " << get<1>(opts) << endl;
116 }
117 }
118 return options;
119}
120
121int main(int argc, const char * const * const argv)
122{

Callers 1

mainFunction · 0.85

Calls 1

print_usageFunction · 0.85

Tested by

no test coverage detected