#include <args.h>
Inheritance diagram for PArgList:
Public Member Functions | |
Construction | |
PArgList (const char *theArgPtr=NULL, const char *argumentSpecPtr=NULL, BOOL optionsBeforeParams=TRUE) | |
PArgList (const PString &theArgStr, const char *argumentSpecPtr=NULL, BOOL optionsBeforeParams=TRUE) | |
PArgList (const PString &theArgStr, const PString &argumentSpecStr, BOOL optionsBeforeParams=TRUE) | |
PArgList (int theArgc, char **theArgv, const char *argumentSpecPtr=NULL, BOOL optionsBeforeParams=TRUE) | |
PArgList (int theArgc, char **theArgv, const PString &argumentSpecStr, BOOL optionsBeforeParams=TRUE) | |
Overrides from class PObject | |
virtual void | PrintOn (ostream &strm) const |
virtual void | ReadFrom (istream &strm) |
Setting & Parsing | |
void | SetArgs (const PString &theArgStr) |
void | SetArgs (int theArgc, char **theArgv) |
void | SetArgs (const PStringArray &theArgs) |
virtual BOOL | Parse (const char *theArgumentSpec, BOOL optionsBeforeParams=TRUE) |
virtual BOOL | Parse (const PString &theArgumentStr, BOOL optionsBeforeParams=TRUE) |
Getting parsed arguments | |
virtual PINDEX | GetOptionCount (char optionChar) const |
virtual PINDEX | GetOptionCount (const char *optionStr) const |
virtual PINDEX | GetOptionCount (const PString &optionName) const |
BOOL | HasOption (char optionChar) const |
BOOL | HasOption (const char *optionStr) const |
BOOL | HasOption (const PString &optionName) const |
virtual PString | GetOptionString (char optionChar, const char *dflt=NULL) const |
virtual PString | GetOptionString (const char *optionStr, const char *dflt=NULL) const |
virtual PString | GetOptionString (const PString &optionName, const char *dflt=NULL) const |
PINDEX | GetCount () const |
PStringArray | GetParameters (PINDEX first=0, PINDEX last=P_MAX_INDEX) const |
PString | GetParameter (PINDEX num) const |
PString | operator[] (PINDEX num) const |
void | Shift (int sh) |
PArgList & | operator<< (int sh) |
PArgList & | operator>> (int sh) |
Errors | |
virtual void | IllegalArgumentIndex (PINDEX idx) const |
virtual void | UnknownOption (const PString &option) const |
virtual void | MissingArgument (const PString &option) const |
Protected Attributes | |
PStringArray | argumentArray |
The original program arguments. | |
PString | optionLetters |
The specification letters for options. | |
PStringArray | optionNames |
The specification strings for options. | |
PIntArray | optionCount |
The count of the number of times an option appeared in the command line. | |
PStringArray | optionString |
The array of associated strings to options. | |
PIntArray | parameterIndex |
The index of each . | |
int | shift |
Shift count for the parameters in the argument list. |
|
Create an argument list. An argument list is created given the standard arguments and a specification for options. The program arguments are parsed from this into options and parameters. The specification string consists of case significant letters for each option. If the letter is followed by the ':' character then the option has an associated string. This string must be in the argument or in the next argument.
|
|
Create an argument list.
|
|
Create an argument list.
|
|
Create an argument list.
|
|
Create an argument list.
|
|
Get the argument count. Get the number of parameters that may be obtained via the #GetParameter()# function. Note that this does not include options and option strings.
|
|
Get the count of option
Reimplemented in PConfigArgs. |
|
Get the count of option
Reimplemented in PConfigArgs. |
|
Get the count of the number of times the option was specified on the command line.
Reimplemented in PConfigArgs. |
|
Get option string.
Reimplemented in PConfigArgs. |
|
Get option string.
Reimplemented in PConfigArgs. |
|
Get option string. Gets the string associated with an option e.g. -ofile or -o file would return the string "file". An option may have an associated string if it had a ':' character folowing it in the specification string passed to the Parse() function.
Reimplemented in PConfigArgs. |
|
Get the parameter that was parsed in the argument list.
|
|
Get the parameters that were parsed in the argument list.
|
|
Get if option present.
|
|
Get if option present.
|
|
Get if option present. Determines whether the option was specified on the command line.
|
|
This function is called when access to illegal parameter index is made in the GetParameter function. The default behaviour is to output a message to the standard PError# stream.
|
|
This function is called when an option that requires an associated string was specified on the command line but no associated string was provided. The default behaviour is to output a message to the standard PError# stream.
|
|
Shift the parameters by the specified amount. This allows the parameters to be parsed at the same position in the argument list "array".
|
|
Shift the parameters by the specified amount. This allows the parameters to be parsed at the same position in the argument list "array".
|
|
Get the parameter that was parsed in the argument list. The argument list object can thus be treated as an "array" of parameters.
|
|
Parse the arguments.
|
|
Parse the arguments. Parse the standard C program arguments into an argument of options and parameters. Consecutive calls with #optionsBeforeParams# set to TRUE will parse out different options and parameters. If SetArgs() function is called then the Parse() function will restart from the beginning of the argument list. The specification string consists of case significant letters for each option. If the letter is followed by a '-' character then a long name version of the option is present. This is terminated either by a '.' or a ':' character. If the single letter or long name is followed by the ':' character then the option has may have an associated string. This string must be within the argument or in the next argument. If a single letter option is followed by a ';' character, then the option may have an associated string but this MUST follow the letter immediately, if it is present at all. For example, "ab:c" allows for "-a -b arg -barg -c" and "a-an-arg.b-option:c;" allows for "-a --an-arg --option arg -c -copt".
|
|
Output the string to the specified stream.
Reimplemented from PObject. |
|
Input the string from the specified stream. This will read all characters until a end of line is reached, then parsing the arguments.
Reimplemented from PObject. |
|
Set the internal copy of the program arguments.
|
|
Set the internal copy of the program arguments.
|
|
Set the internal copy of the program arguments.
|
|
Shift the parameters by the specified amount. This allows the parameters to be parsed at the same position in the argument list "array".
|
|
This function is called when an unknown option was specified on the command line. The default behaviour is to output a message to the standard PError# stream.
|
|
The original program arguments.
|
|
The count of the number of times an option appeared in the command line.
|
|
The specification letters for options.
|
|
The specification strings for options.
|
|
The array of associated strings to options.
|
|
The index of each .
|
|
Shift count for the parameters in the argument list.
|