00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef COMMANDLINE_H
00025 #define COMMANDLINE_H
00026
00027
00028 #define parseFlag(name,value)\
00029 if (!strcmp(argv[c],name)){\
00030 value=true;\
00031 cout << name << " on"<< endl;\
00032 recognized=true;\
00033 }\
00034
00035 #define parseString(name,value)\
00036 if (!strcmp(argv[c],name) && c<argc-1){\
00037 c++;\
00038 value=argv[c];\
00039 cout << name << "=" << value << endl;\
00040 recognized=true;\
00041 }\
00042
00043
00044 #define parseDouble(name,value)\
00045 if (!strcmp(argv[c],name) && c<argc-1){\
00046 c++;\
00047 value=atof(argv[c]);\
00048 cout << name << "=" << value << endl;\
00049 recognized=true;\
00050 }\
00051
00052 #define parseInt(name,value)\
00053 if (!strcmp(argv[c],name) && c<argc-1){\
00054 c++;\
00055 value=atoi(argv[c]);\
00056 cout << name << "=" << value << endl;\
00057 recognized=true;\
00058 }\
00059
00060 #define CMD_PARSE_BEGIN(i, count)\
00061 {\
00062 int c=i;\
00063 while (c<count){\
00064 bool recognized=false;
00065
00066 #define CMD_PARSE_END\
00067 if (!recognized)\
00068 cout << "COMMAND LINE: parameter " << argv[c] << " not recognized" << endl;\
00069 c++;\
00070 }\
00071 }
00072
00073 #define CMD_PARSE_BEGIN_SILENT(i, count)\
00074 {\
00075 int c=i;\
00076 while (c<count){\
00077 bool recognized=false;
00078
00079 #define CMD_PARSE_END_SILENT\
00080 c++;\
00081 }\
00082 }
00083
00084
00085 #define parseFlagSilent(name,value)\
00086 if (!strcmp(argv[c],name)){\
00087 value=true;\
00088 recognized=true;\
00089 }\
00090
00091 #define parseStringSilent(name,value)\
00092 if (!strcmp(argv[c],name) && c<argc-1){\
00093 c++;\
00094 value=argv[c];\
00095 recognized=true;\
00096 }\
00097
00098
00099 #define parseDoubleSilent(name,value)\
00100 if (!strcmp(argv[c],name) && c<argc-1){\
00101 c++;\
00102 value=atof(argv[c]);\
00103 recognized=true;\
00104 }\
00105
00106 #define parseIntSilent(name,value)\
00107 if (!strcmp(argv[c],name) && c<argc-1){\
00108 c++;\
00109 value=atoi(argv[c]);\
00110 recognized=true;\
00111 }\
00112
00113
00114 #endif
00115