Version: 3.2.2
wxCmdLineArg Class Referenceabstract

#include <wx/cmdline.h>

Detailed Description

The interface wxCmdLineArg provides information for an instance of argument passed on command line.

Example of use:

for (wxCmdLineArgs::const_iterator itarg=parser.GetArguments().begin();
itarg!=parser.GetArguments().end();
++itarg)
{
wxString optionName;
switch (itarg->GetKind())
{
if (itarg->IsNegated()) {
}
else {
}
break;
// assuming that all the options have a short name
optionName = itarg->GetShortName();
switch (itarg->GetType()) {
// do something with itarg->GetLongVal();
break;
// do something with itarg->GetDoubleVal();
break;
// do something with itarg->GetDateVal();
break;
// do something with itarg->GetStrVal();
break;
}
break;
// do something with itarg->GetStrVal();
break;
}
}
const_iterator end() const
const_iterator begin() const
wxCmdLineParser is a class for parsing the command line.
Definition: cmdline.h:444
wxCmdLineArgs GetArguments() const
Returns the collection of arguments.
String class for passing textual data to or receiving it from wxWidgets.
Definition: string.h:315
@ wxCMD_LINE_VAL_DOUBLE
Definition: cmdline.h:59
@ wxCMD_LINE_VAL_STRING
Definition: cmdline.h:56
@ wxCMD_LINE_VAL_DATE
Definition: cmdline.h:58
@ wxCMD_LINE_VAL_NUMBER
Definition: cmdline.h:57
@ wxCMD_LINE_SWITCH
A boolean argument of the program; e.g. -v to enable verbose mode.
Definition: cmdline.h:69
@ wxCMD_LINE_OPTION
An argument with an associated value; e.g.
Definition: cmdline.h:73
@ wxCMD_LINE_PARAM
A parameter: a required program argument.
Definition: cmdline.h:76

With C++11, the for loop could be written:

for (const auto &arg : parser.GetArguments()) {
// working on arg as with *itarg above
}
Since
3.1.0

Public Member Functions

virtual ~wxCmdLineArg ()
 
virtual const wxDateTimeGetDateVal () const =0
 Returns the command line argument value as a wxDateTime. More...
 
virtual double GetDoubleVal () const =0
 Returns the command line argument value as a double. More...
 
virtual wxCmdLineEntryType GetKind () const =0
 Returns the command line argument entry kind. More...
 
virtual long GetLongVal () const =0
 Returns the command line argument value as a long. More...
 
virtual wxString GetLongName () const =0
 Returns the command line argument long name if any. More...
 
virtual wxString GetShortName () const =0
 Returns the command line argument short name if any. More...
 
virtual const wxStringGetStrVal () const =0
 Returns the command line argument value as a string. More...
 
virtual wxCmdLineParamType GetType () const =0
 Returns the command line argument parameter type. More...
 
virtual bool IsNegated () const =0
 Returns true if the switch was negated. More...
 

Constructor & Destructor Documentation

◆ ~wxCmdLineArg()

virtual wxCmdLineArg::~wxCmdLineArg ( )
virtual

Member Function Documentation

◆ GetDateVal()

virtual const wxDateTime & wxCmdLineArg::GetDateVal ( ) const
pure virtual

Returns the command line argument value as a wxDateTime.

Note
This call works only for wxCMD_LINE_VAL_DATE options

◆ GetDoubleVal()

virtual double wxCmdLineArg::GetDoubleVal ( ) const
pure virtual

Returns the command line argument value as a double.

Note
This call works only for wxCMD_LINE_VAL_DOUBLE options

◆ GetKind()

virtual wxCmdLineEntryType wxCmdLineArg::GetKind ( ) const
pure virtual

Returns the command line argument entry kind.

Note
Parameters can only be retrieved as strings, with GetStrVal()
See also
wxCmdLineEntryType, GetType()

◆ GetLongName()

virtual wxString wxCmdLineArg::GetLongName ( ) const
pure virtual

Returns the command line argument long name if any.

Note
This call makes sense only for options and switches

◆ GetLongVal()

virtual long wxCmdLineArg::GetLongVal ( ) const
pure virtual

Returns the command line argument value as a long.

Note
This call works only for wxCMD_LINE_VAL_NUMBER options

◆ GetShortName()

virtual wxString wxCmdLineArg::GetShortName ( ) const
pure virtual

Returns the command line argument short name if any.

Note
This call makes sense only for options and switches

◆ GetStrVal()

virtual const wxString & wxCmdLineArg::GetStrVal ( ) const
pure virtual

Returns the command line argument value as a string.

Note
This call works only for wxCMD_LINE_VAL_STRING options and parameters

◆ GetType()

virtual wxCmdLineParamType wxCmdLineArg::GetType ( ) const
pure virtual

Returns the command line argument parameter type.

Note
This call makes sense only for options (i.e. GetKind() == wxCMD_LINE_OPTION).
See also
wxCmdLineParamType, GetKind()

◆ IsNegated()

virtual bool wxCmdLineArg::IsNegated ( ) const
pure virtual

Returns true if the switch was negated.

Note
This call works only for switches.