PTLib  Version 2.10.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PCLI::Arguments Class Reference

This class is an enhancement to PArgList to add context. More...

#include <cli.h>

Inheritance diagram for PCLI::Arguments:
PArgList PObject

Public Member Functions

Construction
 Arguments (Context &context, const PString &rawLine)
 
Operations
ContextWriteUsage ()
 Write to the CLI output channel the usage for the current command. More...
 
ContextWriteError (const PString &error=PString::Empty())
 Write an error to the CLI output channel. More...
 
Member access
ContextGetContext () const
 Get the CLI context supplying the command line arguments. 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...
 
virtual PBoolean Parse (const char *theArgumentSpec, PBoolean optionsBeforeParams=true)
 Parse the arguments. More...
 
virtual PBoolean Parse (const PString &theArgumentStr, PBoolean optionsBeforeParams=true)
 Parse the arguments. More...
 
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...
 
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...
 
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...
 
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...
 
PArgListoperator<< (int sh)
 Shift the parameters by the specified amount. More...
 
PArgListoperator>> (int sh)
 Shift the parameters by the specified amount. More...
 
virtual void IllegalArgumentIndex (PINDEX idx) const
 This function is called when access to illegal parameter index is made in the GetParameter function. More...
 
virtual void UnknownOption (const PString &option) const
 This function is called when an unknown option was specified on the command line. More...
 
virtual void MissingArgument (const PString &option) const
 This function is called when an option that requires an associated string was specified on the command line but no associated string was provided. More...
 
- Public Member Functions inherited from PObject
virtual ~PObject ()
 
virtual PObjectClone () const
 Create a copy of the class on the heap. 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...
 

Protected Attributes

Contextm_context
 
PString m_command
 
PString m_usage
 
- Protected Attributes inherited from PArgList
PStringArray argumentArray
 The original program arguments. More...
 
PString optionLetters
 The specification letters for options. More...
 
PStringArray optionNames
 The specification strings for options. More...
 
PIntArray optionCount
 The count of the number of times an option appeared in the command line. More...
 
PStringArray optionString
 The array of associated strings to options. More...
 
PIntArray parameterIndex
 The index of each . More...
 
int shift
 Shift count for the parameters in the argument list. More...
 

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...
 
- Protected Member Functions inherited from PObject
 PObject ()
 Constructor for PObject, made protected so cannot ever create one on its own. More...
 

Detailed Description

This class is an enhancement to PArgList to add context.

Constructor & Destructor Documentation

PCLI::Arguments::Arguments ( Context context,
const PString rawLine 
)

Member Function Documentation

Context& PCLI::Arguments::GetContext ( ) const
inline

Get the CLI context supplying the command line arguments.

References m_context.

Context& PCLI::Arguments::WriteError ( const PString error = PString::Empty())

Write an error to the CLI output channel.

Parameters
errorError message
Context& PCLI::Arguments::WriteUsage ( )

Write to the CLI output channel the usage for the current command.

Member Data Documentation

PString PCLI::Arguments::m_command
protected
Context& PCLI::Arguments::m_context
protected

Referenced by GetContext().

PString PCLI::Arguments::m_usage
protected

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