NAME
ACE_Get_Opt -
Iterator for parsing command-line arguments.
SYNOPSIS
#include <ace/Get_Opt.h>
class ACE_Get_Opt
{
public:
ACE_Get_Opt (
int argc,
char **argv,
char *optstring,
int skip = 1,
int report_errors = 0
);
int operator () (void);
char *optarg;
int optind;
int opterr;
int nargc;
char **nargv;
char *noptstring;
void dump (void) const;
ACE_ALLOC_HOOK_DECLARE;
private:
char *nextchar;
int first_nonopt;
int last_nonopt;
};
DESCRIPTION
This version of `get_opt' appears to the caller like standard
Unix `get_opt' but it behaves differently for the user, since it
allows the user to intersperse the options with the other
arguments.
As `get_opt' works, it permutes the elements of `argv' so that,
when it is done, all the options precede everything else. Thus
all application programs are extended to handle flexible argument order.
Setting the environment variable _POSIX_OPTION_ORDER disables permutation.
Then the behavior is completely standard.
GNU application programs can use a third alternative mode in which
they can distinguish the relative order of options and other arguments.
Public data members (should be hidden...).
char *optarg;
For communication from `get_opt' to the caller. When `get_opt'
finds an option that takes an argument, the argument value is
returned here. Also, when `ordering' is RETURN_IN_ORDER, each
non-option ARGV-element is returned here.
int optind;
Index in ARGV of the next element to be scanned. This is used
for communication to and from the caller and for communication
between successive calls to `get_opt'. On entry to `get_opt',
zero means this is the first call; initialize.
When `get_opt' returns EOF, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far.
int opterr;
Callers store zero here to inhibit the error message for
unrecognized options.
GNU extensions
int nargc;
char **nargv;
char *noptstring;
void dump (void) const;
Dump the state of an object.
ACE_ALLOC_HOOK_DECLARE;
Declare the dynamic allocation hooks.
AUTHOR
Doug Schmidt
LIBRARY
ace