#include <CNCL/GetOpt.h>
CN_GETOPT
CNObject
None
None
This class manages the interface to the GNU getopt() functionality.
As an example for its use please see the file tGetOpt.c
at the
directory CNCL/lib/misc/test
.
Constructors:
CNGetOpt();
CNGetOpt(CNParam *);
CNGetOpt(int argc, char **argv, char *copts=NIL);
In addition to the member functions required by CNCL, CNGetOpt
provides:
enum ParamType { NOPARAM=0, WPARAM=1, OPTPARAM=2 };
struct option { char *name; int has_arg; int *flag; int val; };
has_arg
is NOPARAM (0) if the option does not take an
argument, WPARAM (1) if the option requires an argument, or OPTPARAM (2)
if the option takes an optional argument.
If flag
is not NULL, it points to a variable that is set to the
value given in val
when the option is found, but left
unchanged if the option is not found.
To have a long-named option do something other than set an `int' to a
compiled-in constant, such as set a value from `optarg', set flag
to zero and val
to a nonzero value (the equivalent single-letter
option character, if there is one). For long options that have a zero
flag
, GetOpt
returns the contents of val
.
void set_args(int argc, char **argv);
argc
and argv
options.
void set_char_options(char *copts);
void set_long_options(option *lopts);
void add_long_option (char *lopt, ParamType pt, char copt);
{ "help", 0, 0, 'h'}, /* Help */
int getopt();
int getopt(int argc, char *const *argv, const char *optstring);
int operator() ();
int getopt_long(int argc, char *const *argv, const char *options, const struct option *long_options,
int *opt_index);
int getopt_long_only(int argc, char *const *argv, const char *options, const struct option *long_options,
int *opt_index);
char *optarg();
double optarg_double();
int optarg_int()
int optind();
int optopt();
void opterr(int err);
Go to the first, previous, next, last section, table of contents.