37 #include <tfxx/commandline.h> 38 #include <tfxx/error.h> 47 Miargc(iargc), Margv(argv)
57 while (declarations[
Mnopt].opt_string != NULL) {
Mnopt++; }
62 struct option* long_options=
new struct option[
Mnopt];
70 while (declarations[iopt].opt_string != NULL)
72 long_options[iopt].name =declarations[iopt].
opt_string;
73 long_options[iopt].has_arg =declarations[iopt].
opt_arg_mode;
74 long_options[iopt].flag =NULL;
75 long_options[iopt].val =iopt;
77 Mresult[iopt].
arg =std::string(declarations[iopt].arg_default);
87 c=getopt_long_only(iargc, argv,
"", long_options, &iopt);
94 if ((c < 0) || (c >=
Mnopt))
96 std::cerr <<
"Commandline: ERROR on option '" 97 << long_options[iopt].name <<
"'" << std::endl;
112 delete[] long_options;
Result * Mresult
Array of command line contents.
bool opt_set
true if option was used on command line
const char * opt_string
option name
Eopt_arg_mode opt_arg_mode
option argument mode
int Mnopt
Total number of options evaluated ot Mresult.
Commandline(int &iargc, char **argv, Declare *declarations)
Constructor evaluates commandline by calling long_getopt.
Structure to store result of command line scanning.
int Moptind
Next option string to read after last defined option.
struct to define options ,This struct is used to define a list of options. An example is: ...
std::string arg
holds option argument
#define TFXX_abort(M)
Abort and give a message.
Namespace containing all code of library libtfxx.