PTLib Version 2.12.9

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Protected Member Functions | Protected Attributes | List of all members
PConfigArgs Class Reference

This class parse command line arguments with the ability to override them from a PConfig file/registry. More...

`#include <args.h>`

Inheritance diagram for PConfigArgs:
[legend]
Collaboration diagram for PConfigArgs:
[legend]

## Public Member Functions
Construction
| PConfigArgs (const PArgList &args)
Overrides from class PArgList
virtual PINDEX | GetOptionCount (char optionChar) const
| Get the count of the number of times the option was specified on the command line. More...
virtual PINDEX | GetOptionCount (const char *optionStr) const
| Get the count of option. More...
virtual PINDEX | GetOptionCount (const PString &optionName) const
| Get the count of option. More...
virtual PString | GetOptionString (char optionChar, const char *dflt=NULL) const
| Get option string. More...
virtual PString | GetOptionString (const char *optionStr, const char *dflt=NULL) const
| Get option string. More...
virtual PString | GetOptionString (const PString &optionName, const char *dflt=NULL) const
| Get option string. More...
void | Save (const PString &optionName)
| Save the current options to the PConfig. More...
void | SetSectionName (const PString &section)
| Set the PConfig section name for options. More...
const PString & | GetSectionName () const
| Get the PConfig section name for options. More...
void | SetNegationPrefix (const PString &prefix)
| Set the prefix for option negation. More...
const PString & | GetNegationPrefix () const
| Get the prefix for option negation. More...
Public Member Functions inherited from PArgList
| PArgList (const char *theArgPtr=NULL, const char *argumentSpecPtr=NULL, PBoolean optionsBeforeParams=true)
| Create an argument list. More...
| PArgList (const PString &theArgStr, const char *argumentSpecPtr=NULL, PBoolean optionsBeforeParams=true)
| Create an argument list. More...
| PArgList (const PString &theArgStr, const PString &argumentSpecStr, PBoolean optionsBeforeParams=true)
| Create an argument list. More...
| PArgList (int theArgc, char **theArgv, const char *argumentSpecPtr=NULL, PBoolean optionsBeforeParams=true)
| Create an argument list. More...
| PArgList (int theArgc, char **theArgv, const PString &argumentSpecStr, PBoolean optionsBeforeParams=true)
| Create an argument list. More...
virtual void | PrintOn (ostream &strm) const
| Output the string to the specified stream. More...
virtual void | ReadFrom (istream &strm)
| Input the string from the specified stream. More...
void | SetArgs (const PString &theArgStr)
| Set the internal copy of the program arguments. More...
void | SetArgs (int theArgc, char **theArgv)
| Set the internal copy of the program arguments. More...
void | SetArgs (const PStringArray &theArgs)
| Set the internal copy of the program arguments. More...
void | SetCommandName (const PString &name)
| Set the comand name. More...
const PString & | GetCommandName () const
| Get the command name. More...
virtual bool | Parse (const char *theArgumentSpec=NULL, PBoolean optionsBeforeParams=true)
| Parse the arguments. More...
virtual bool | Parse (const PString &theArgumentStr, PBoolean optionsBeforeParams=true)
| Parse the arguments. More...
bool | IsParsed () const
| Determine if already parsed at least once. More...
const PString & | GetParseError () const
| Return error message after a call to Parse(). More...
ostream & | Usage (ostream &strm, const char *usage=NULL) const
| Output usage text for parsed arguments. More...
PString | Usage () const
PBoolean | HasOption (char optionChar) const
| Get if option present. More...
PBoolean | HasOption (const char *optionStr) const
| Get if option present. More...
PBoolean | HasOption (const PString &optionName) const
| Get if option present. More...
PINDEX | GetCount () const
| Get the argument count. More...
PStringArray | GetParameters (PINDEX first=0, PINDEX last=P_MAX_INDEX) const
| Get the parameters that were parsed in the argument list. More...
PString | GetParameter (PINDEX num) const
| Get the parameter that was parsed in the argument list. More...
PString | operator[] (PINDEX num) const
| Get the parameter that was parsed in the argument list. More...
void | Shift (int sh)
| Shift the parameters by the specified amount. More...
PArgList & | operator<< (int sh)
| Shift the parameters by the specified amount. More...
PArgList & | operator>> (int sh)
| Shift the parameters by the specified amount. More...
Public Member Functions inherited from PObject
unsigned | GetTraceContextIdentifier () const
| Get PTRACE context identifier. More...
void | SetTraceContextIdentifier (unsigned id)
void | GetTraceContextIdentifier (PObject &obj)
void | GetTraceContextIdentifier (PObject *obj)
void | SetTraceContextIdentifier (const PObject &obj)
void | SetTraceContextIdentifier (const PObject *obj)
virtual | ~PObject ()
virtual PObject * | Clone () const
| Create a copy of the class on the heap. More...
template<class CLS >
CLS * | CloneAs () const
| As for Clone() but converts to specified type. More...
virtual PINDEX | HashFunction () const
| This function yields a hash value required by the `PDictionary` class. More...
virtual Comparison | Compare (const PObject &obj) const
| Compare the two objects and return their relative rank. More...
virtual Comparison | CompareObjectMemoryDirect (const PObject &obj) const
| Determine the byte wise comparison of two objects. More...
bool | operator== (const PObject &obj) const
| Compare the two objects. More...
bool | operator!= (const PObject &obj) const
| Compare the two objects. More...
bool | operator< (const PObject &obj) const
| Compare the two objects. More...
bool | operator> (const PObject &obj) const
| Compare the two objects. More...
bool | operator<= (const PObject &obj) const
| Compare the two objects. More...
bool | operator>= (const PObject &obj) const
| Compare the two objects. More...
virtual const char * | GetClass (unsigned ancestor=0) const
| Get the current dynamic type of the object instance. More...
PBoolean | IsClass (const char *cls) const
virtual PBoolean | InternalIsDescendant (const char *clsName) const
| Determine if the dynamic type of the current instance is a descendent of the specified class. More...
__inline const PObject * | PTraceObjectInstance () const
virtual void | PrintOn (ostream &strm) const
| Output the contents of the object to the stream. More...
virtual void | ReadFrom (istream &strm)
| Input the contents of the object from the stream. More...

## Protected Member Functions
PString | CharToString (char ch) const
Protected Member Functions inherited from PArgList
bool | InternalSpecificationError (bool isError, const PString &msg)
size_t | InternalFindOption (const PString &name) const
int | InternalParseOption (const PString &opt, PINDEX offset, PINDEX &arg)
PINDEX | InternalGetOptionCountByIndex (size_t idx) const
PString | InternalGetOptionStringByIndex (size_t idx, const char *dflt) const
Protected Member Functions inherited from PObject
| PObject ()
| Constructor for PObject, made protected so cannot ever create one on its own. More...

## Protected Attributes
PConfig | config
PString | sectionName
PString | negationPrefix
Protected Attributes inherited from PArgList
PString | m_commandName
bool | m_parsed
PString | m_parseError
PStringArray | m_argumentArray
vector< OptionSpec > | m_options
PIntArray | m_parameterIndex
| The index of each parameter. More...
int | m_shift
| Shift count for the parameters in the argument list. More...
int | m_argsParsed
Protected Attributes inherited from PObject
unsigned | m_traceContextIdentifier

## Additional Inherited Members
Public Types inherited from PObject
enum | Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }
| Result of the comparison operation performed by the `Compare()` function. More...
Static Public Member Functions inherited from PObject
static Comparison | InternalCompareObjectMemoryDirect (const PObject *obj1, const PObject *obj2, PINDEX size)
| Internal function caled from CompareObjectMemoryDirect() More...
static const char * | Class ()
| Get the name of the class as a C string. More...
static __inline const PObject * | PTraceObjectInstance (const char *)
static __inline const PObject * | PTraceObjectInstance (const PObject *obj)
Protected Types inherited from PArgList
enum | OptionType { NoString, HasString, StringWithLetter }
Friends inherited from PObject

## Detailed Description

This class parse command line arguments with the ability to override them from a PConfig file/registry.

## Constructor & Destructor Documentation

PConfigArgs::PConfigArgs | ( | const PArgList & | args | ) |

Parameters

  args | Raw argument list.

## Member Function Documentation

PString PConfigArgs::CharToString | ( | char | ch | ) | const
| protected

const PString& PConfigArgs::GetNegationPrefix | ( |  | ) | const
| inline

Get the prefix for option negation.

The default is "no-".

References negationPrefix.

virtual PINDEX PConfigArgs::GetOptionCount | ( | char | optionChar | ) | const
| virtual

Get the count of the number of times the option was specified on the command line.

Returns
  option repeat count.

Parameters

  optionChar | Character letter code for the option

Reimplemented from PArgList.

virtual PINDEX PConfigArgs::GetOptionCount | ( | const char * | optionStr | ) | const
| virtual

Get the count of option.

Parameters

  optionStr | String code for the option

Reimplemented from PArgList.

virtual PINDEX PConfigArgs::GetOptionCount | ( | const PString & | optionName | ) | const
| virtual

Get the count of option.

Parameters

  optionName | String code for the option

Reimplemented from PArgList.

virtual PString PConfigArgs::GetOptionString | ( | char | optionChar,
|  | const char * | dflt = `NULL`
| ) |  | const
| virtual

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.

Returns
  the options associated string.

Parameters

  optionChar | Character letter code for the option
  dflt | Default value of the option string

Reimplemented from PArgList.

virtual PString PConfigArgs::GetOptionString | ( | const char * | optionStr,
|  | const char * | dflt = `NULL`
| ) |  | const
| virtual

Get option string.

Parameters

  optionStr | String letter code for the option
  dflt | Default value of the option string

Reimplemented from PArgList.

virtual PString PConfigArgs::GetOptionString | ( | const PString & | optionName,
|  | const char * | dflt = `NULL`
| ) |  | const
| virtual

Get option string.

Parameters

  optionName | String code for the option
  dflt | Default value of the option string

Reimplemented from PArgList.

const PString& PConfigArgs::GetSectionName | ( |  | ) | const
| inline

Get the PConfig section name for options.

References sectionName.

void PConfigArgs::Save | ( | const PString & | optionName | ) |

Save the current options to the PConfig.

This function will check to see if the option name is present and if so, save to the PConfig all of the arguments present in the currently parsed list. Note that the optionName for saving is not saved to the PConfig itself as this would cause the data to be saved always!

Parameters

  optionName | Option name for saving.

void PConfigArgs::SetNegationPrefix | ( | const PString & | prefix | ) |
| inline

Set the prefix for option negation.

The default is "no-".

Parameters

  prefix | New prefix string

References negationPrefix.

void PConfigArgs::SetSectionName | ( | const PString & | section | ) |
| inline

Set the PConfig section name for options.

Parameters

  section | New section name

References sectionName.

## Member Data Documentation

PConfig PConfigArgs::config
| protected

PString PConfigArgs::negationPrefix
| protected

Referenced by GetNegationPrefix(), and SetNegationPrefix().

PString PConfigArgs::sectionName
| protected

Referenced by GetSectionName(), and SetSectionName().

The documentation for this class was generated from the following file:

- args.h