This class allows the parsing of a set of program arguments.
![]() | Construction |
![]() | Setting & Parsing |
![]() | Getting parsed arguments |
![]() | Errors |
![]() | argumentArray The original program arguments. |
![]() | optionLetters The specification letters for options |
![]() | optionNames The specification strings for options |
![]() | optionCount The count of the number of times an option appeared in the command line. |
![]() | optionString The array of associated strings to options. |
![]() | parameterIndex The index of each . |
![]() | shift Shift count for the parameters in the argument list. |
Run Time Type functions
Comparison functions
I/O functions
Miscellaneous functions
This class allows the parsing of a set of program arguments. This translates the standard argc/argv style variables passed into the main() function into a set of options (preceded by a '-' character) 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.
PArgList( const PString & theArgStr, const char * argumentSpecPtr = NULL, BOOL optionsBeforeParams = TRUE )
argumentSpecPtr - The specification C string for argument options. See description for
details.
optionsBeforeParams - Parse options only before parameters PArgList( const PString & theArgStr, const PString & argumentSpecStr, BOOL optionsBeforeParams = TRUE )
argumentSpecStr - The specification string for argument options. See description for
details.
optionsBeforeParams - Parse options only before parameters PArgList( int theArgc, char ** theArgv, const char * argumentSpecPtr = NULL, BOOL optionsBeforeParams = TRUE )
theArgv - An array of strings constituting the arguments
argumentSpecPtr - The specification C string for argument options. See description for
details.
optionsBeforeParams - Parse options only before parameters PArgList( int theArgc, char ** theArgv, const PString & argumentSpecStr, BOOL optionsBeforeParams = TRUE )
theArgv - An array of strings constituting the arguments
argumentSpecStr - The specification string for argument options. See description for
details.
optionsBeforeParams - Parse options only before parameters
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, äb:c" allows for "-a -b arg -barg -c" and
ä-an-arg.b-option:c;" allows for "-a --an-arg --option arg -c -copt".
void SetArgs( int theArgc, char ** theArgv )
theArgv - An array of strings constituting the argumentsvoid SetArgs( const PStringArray & theArgs )
virtual BOOL Parse( const char * theArgumentSpec, BOOL optionsBeforeParams = TRUE )
optionsBeforeParams - Parse options only before parametersvirtual BOOL Parse( const PString & theArgumentStr, BOOL optionsBeforeParams = TRUE )
optionsBeforeParams - Parse options only before parameters
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
dflt - Default value of the option stringvirtual PString GetOptionString( const char * optionStr, const char * dflt = NULL ) const
dflt - Default value of the option stringvirtual PString GetOptionString( const PString & optionName, const char * dflt = NULL ) const
dflt - Default value of the option stringPINDEX GetCount() const
PString GetParameter( PINDEX num ) const
PString operator[]( PINDEX num ) const
void Shift( int sh )
PArgList& operator<<( int sh )
PArgList& operator>>( int sh )
virtual void UnknownOption( const PString & option ) const
virtual void MissingArgument( const PString & option ) const
PString optionLetters
PStringArray optionNames
PIntArray optionCount
PStringArray optionString
PIntArray parameterIndex
int shift
Alphabetic index HTML hierarchy of classes or Java