| Version: 3.1.5

Public Member Functions | List of all members
wxCmdLineArg Class Referenceabstract

`#include </home/Hamis/wxwidgets-3.1/wxWidgets3.1-3.1.5-1.i686/src/wxWidgets-3.1.5/interface/wx/cmdline.h>`

## Detailed Description

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

Example of use:

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