17 #ifndef OPTIONPARSER_H_ 18 #define OPTIONPARSER_H_ 42 template<
typename TYPE>
43 int getArg(
string key,
int argc,
char *argv[], TYPE &ret,
int i) {
45 int rv=getArgString(key, argc, argv, args, i);
57 template<
typename TYPE>
72 int getArgString(
string key,
int argc,
char *argv[],
string &ret,
int i) {
77 while (argv[i][startIndex]==
'-') startIndex++;
78 string arg(&argv[i][startIndex]);
79 istringstream input(arg);
80 input.ignore(arg.length(),
'=');
81 unsigned int length=arg.find(
'=');
82 if (length==string::npos)
84 if ((startIndex!=0) && (key.compare(0,key.length(),arg, 0, length)==0) && (arg.compare(0,length, key)==0)) {
88 if ((key.length()==arg.length()) & (i+1<argc)) {
89 if (argv[i+1][0]!=
'-')
92 if (length==key.length())
101 #endif // OPTIONPARSER_H_ int getArg(string key, int argc, char *argv[], TYPE &ret, int i)
void convertArg(const char *arg, TYPE &ret)
int getArgString(string key, int argc, char *argv[], string &ret, int i)