NAME
OTC_Program -
Class to encapsulate information about a programs options.
SYNOPSIS
#include <OTC/program/program.hh>
class OTC_Program
{
public:
static void initialise(int argc, char* argv[]);
static OTC_String const& name();
static int numOptions();
static OTC_String const& option(u_int theNum=1);
static OTC_Boolean match(char const* thePattern, u_int theNum=1);
static OTC_Iterator<OTC_String> options(
OTC_Direction theDirection=OTCLIB_FORWARD
);
static OTC_Iterator<OTC_String> options(
u_int theStart,
u_int theLength,
OTC_Direction theDirection=OTCLIB_FORWARD
);
static OTC_Iterator<OTC_String> options(
OTC_Range const& theRange,
OTC_Direction theDirection=OTCLIB_FORWARD
);
static void shift(u_int theNum=1);
static void restore();
};
CLASS TYPE
Static
DESCRIPTION
This class should be initialised once using initialise() at the
start of main(). Upon doing this it will maintain a copy of the
name of the program and the options to the program.
PUBLIC MEMBERS
static void initialise(int argc, char* argv[]);
Initialise the name of the program and its
options.
static OTC_String const& name();
Returns the name of the program.
static int numOptions();
Returns the number of options supplied to
the program. Unlike argc this does not
include the name of the program in the
count. If this class has not been
initialised, then -1 will be returned.
static OTC_String const& option(u_int theNum=1);
Return the option at position theNum.
Generates an exception if theNum is
greater than the number of options.
If theNum is 0 then the name of the
program is returned.
static OTC_Boolean match(char const* thePattern, u_int theNum=1);
Performs a glob style match against the
option at position theNum and returns
OTCLIB_TRUE if sucessful.
Generates an exception if theNum is
greater than the number of options.
If theNum is 0 then the name of the
program will be matched against.
static OTC_Iterator<OTC_String> options(
OTC_Direction theDirection=OTCLIB_FORWARD
);
Returns an iterator over just the
options to the program.
static OTC_Iterator<OTC_String> options(
u_int theStart,
u_int theLength,
OTC_Direction theDirection=OTCLIB_FORWARD
);
Returns an iterator over the options
in the range commencing at theStart
and with length theLength.
static OTC_Iterator<OTC_String> options(
OTC_Range const& theRange,
OTC_Direction theDirection=OTCLIB_FORWARD
);
Returns an iterator over the options in
theRange.
static void shift(u_int theNum=1);
Discard the theNum options and shift all
other options down one spot. This is
analagous to the shift operator in shell
scripts.
static void restore();
Restores the set of options after
any were discarded using shift().
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1991 1992 OTC LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED