30 #ifndef PTLIB_ARGLIST_H
31 #define PTLIB_ARGLIST_H
59 const char * theArgPtr = NULL,
60 const char * argumentSpecPtr = NULL,
66 const char * argumentSpecPtr = NULL,
72 const PString & argumentSpecStr,
79 const char * argumentSpecPtr = NULL,
86 const PString & argumentSpecStr,
113 ) {
SetArgs((
const char *)theArgStr); }
115 const char * theArgStr
181 const char * theArgumentSpec = NULL,
186 const PString & theArgumentStr,
207 const char * usage = NULL,
208 const char * prefix =
"Usage: "
211 const char * usage = NULL,
212 const char * prefix =
"Usage: "
228 const char * optionStr
245 const char * optionStr
262 const char * dflt = NULL
266 const char * optionStr,
267 const char * dflt = NULL
272 const char * dflt = NULL
277 template <
typename ValueType,
typename OptionType>
415 const char * optionStr
432 const char * dflt = NULL
437 const char * optionStr,
438 const char * dflt = NULL
444 const char * dflt = NULL
492 #endif // P_CONFIG_FILE
495 #endif // PTLIB_ARGLIST_H
PString m_negationPrefix
Definition: args.h:489
size_t InternalFindOption(const PString &name) const
void SetArgs(const PString &theArgStr)
Set the internal copy of the program arguments.
Definition: args.h:111
PString m_commandName
Definition: args.h:346
PString operator[](PINDEX num) const
Get the parameter that was parsed in the argument list.
bool IsParsed() const
Determine if already parsed at least once.
Definition: args.h:192
int m_argsParsed
Definition: args.h:374
virtual bool Parse(const char *theArgumentSpec=NULL, PBoolean optionsBeforeParams=true)
Parse the arguments.
PString m_name
Definition: args.h:359
virtual PINDEX GetOptionCount(char optionChar) const
Get the count of the number of times the option was specified on the command line.
PStringArray GetParameters(PINDEX first=0, PINDEX last=P_MAX_INDEX) const
Get the parameters that were parsed in the argument list.
PArgList(const char *theArgPtr=NULL, const char *argumentSpecPtr=NULL, PBoolean optionsBeforeParams=true)
Create an argument list.
PConfig * m_config
Definition: args.h:487
PArgList & operator>>(int sh)
Shift the parameters by the specified amount.
PString m_usage
Definition: args.h:360
PString m_parseError
Definition: args.h:348
PConfigArgs(const PArgList &args)
A class representing a configuration for the application.
Definition: config.h:62
This class is a standard C++ stream class descendent for reading or writing streamed data to or from ...
Definition: pstring.h:2188
PString InternalGetOptionStringByIndex(size_t idx, const char *dflt) const
PString GetParameter(PINDEX num) const
Get the parameter that was parsed in the argument list.
PINDEX InternalGetOptionCountByIndex(size_t idx) const
PArgList & operator<<(int sh)
Shift the parameters by the specified amount.
void Save(const PString &optionName)
Save the current options to the PConfig.
PString m_string
Definition: args.h:365
This is an array collection class of PString objects.
Definition: pstring.h:2365
OptionSpec()
Definition: args.h:357
const PString & GetNegationPrefix() const
Get the prefix for option negation.
Definition: args.h:480
virtual PBoolean IsEmpty() const
Determine if the string is empty.
void SetSectionName(const PString §ion)
Set the PConfig section name for options.
Definition: args.h:462
PStringArray m_argumentArray
Definition: args.h:349
PBoolean HasOption(char optionChar) const
Get if option present.
PString CharToString(char ch) const
char m_letter
Definition: args.h:358
void SetNegationPrefix(const PString &prefix)
Set the prefix for option negation.
Definition: args.h:473
ValueType GetOptionAs(OptionType option, ValueType value=0) const
Get option as specicied type.
Definition: args.h:278
PString m_sectionName
Definition: args.h:488
vector< OptionSpec > m_options
Definition: args.h:367
bool PBoolean
Definition: object.h:174
virtual PString GetOptionString(char optionChar, const char *dflt=NULL) const
Get option string.
This class parse command line arguments with the ability to override them from a PConfig file/registr...
Definition: args.h:390
virtual void ReadFrom(istream &strm)
Input the string from the specified stream.
#define P_MAX_INDEX
Definition: object.h:80
unsigned m_count
Definition: args.h:364
The character string class.
Definition: pstring.h:108
virtual PINDEX GetOptionCount(char optionChar) const
Get the count of the number of times the option was specified on the command line.
int m_shift
Shift count for the parameters in the argument list.
Definition: args.h:373
This class allows the parsing of a set of program arguments.
Definition: args.h:41
bool InternalSpecificationError(bool isError, const PString &msg)
virtual void PrintOn(ostream &strm) const
Output the string to the specified stream.
int InternalParseOption(const PString &opt, PINDEX offset, PINDEX &arg)
const PString & GetSectionName() const
Get the PConfig section name for options.
Definition: args.h:468
const PString & GetCommandName() const
Get the command name.
Definition: args.h:135
PIntArray m_parameterIndex
The index of each parameter.
Definition: args.h:370
PString m_section
Definition: args.h:361
const PString & GetParseError() const
Return error message after a call to Parse().
Definition: args.h:198
PINDEX GetCount() const
Get the argument count.
Ultimate parent class for all objects in the class library.
Definition: object.h:2204
OptionType
Definition: args.h:351
void SetCommandName(const PString &name)
Set the comand name.
Definition: args.h:129
ostream & Usage(ostream &strm, const char *usage=NULL, const char *prefix="Usage: ") const
Output usage text for parsed arguments.
virtual PString GetOptionString(char optionChar, const char *dflt=NULL) const
Get option string.
OptionType m_type
Definition: args.h:362
void Shift(int sh)
Shift the parameters by the specified amount.
bool m_parsed
Definition: args.h:347