make wxCmdLineParser:Usage() const
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52505 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -150,7 +150,7 @@ public:
|
|||||||
void EnableLongOptions(bool enable = true);
|
void EnableLongOptions(bool enable = true);
|
||||||
void DisableLongOptions() { EnableLongOptions(false); }
|
void DisableLongOptions() { EnableLongOptions(false); }
|
||||||
|
|
||||||
bool AreLongOptionsEnabled();
|
bool AreLongOptionsEnabled() const;
|
||||||
|
|
||||||
// extra text may be shown by Usage() method if set by this function
|
// extra text may be shown by Usage() method if set by this function
|
||||||
void SetLogo(const wxString& logo);
|
void SetLogo(const wxString& logo);
|
||||||
@@ -189,7 +189,7 @@ public:
|
|||||||
int Parse(bool showUsage = true);
|
int Parse(bool showUsage = true);
|
||||||
|
|
||||||
// give the usage message describing all program options
|
// give the usage message describing all program options
|
||||||
void Usage();
|
void Usage() const;
|
||||||
|
|
||||||
// get the command line arguments
|
// get the command line arguments
|
||||||
// ------------------------------
|
// ------------------------------
|
||||||
@@ -225,7 +225,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// get usage string
|
// get usage string
|
||||||
wxString GetUsageString();
|
wxString GetUsageString() const;
|
||||||
|
|
||||||
// common part of all ctors
|
// common part of all ctors
|
||||||
void Init();
|
void Init();
|
||||||
|
@@ -14,43 +14,32 @@
|
|||||||
|
|
||||||
It has the following features:
|
It has the following features:
|
||||||
|
|
||||||
distinguishes options, switches and parameters; allows option grouping
|
- distinguishes options, switches and parameters
|
||||||
allows both short and long options
|
- allows option grouping
|
||||||
automatically generates the usage message from the command line description
|
- allows both short and long options
|
||||||
does type checks on the options values (number, date, ...).
|
- automatically generates the usage message from the command line description
|
||||||
|
- checks types of the options values (number, date, ...).
|
||||||
|
|
||||||
To use it you should follow these steps:
|
To use it you should follow these steps:
|
||||||
|
|
||||||
@ref wxCmdLineParser::construction construct an object of this class
|
-# @ref wxCmdLineParser::construction construct an object of this class
|
||||||
giving it the command line to parse and optionally its description or use
|
giving it the command line to parse and optionally its description or use
|
||||||
@c AddXXX() functions later
|
@c AddXXX() functions later
|
||||||
call @c Parse()
|
-# call @c Parse()
|
||||||
use @c Found() to retrieve the results
|
-# use @c Found() to retrieve the results
|
||||||
|
|
||||||
In the documentation below the following terminology is used:
|
In the documentation below the following terminology is used:
|
||||||
|
|
||||||
|
- @e switch
|
||||||
|
|
||||||
switch
|
|
||||||
|
|
||||||
|
|
||||||
This is a boolean option which can be given or not, but
|
This is a boolean option which can be given or not, but
|
||||||
which doesn't have any value. We use the word switch to distinguish such boolean
|
which doesn't have any value. We use the word switch to distinguish such boolean
|
||||||
options from more generic options like those described below. For example,
|
options from more generic options like those described below. For example,
|
||||||
@c -v might be a switch meaning "enable verbose mode".
|
@c -v might be a switch meaning "enable verbose mode".
|
||||||
|
- @e option
|
||||||
|
|
||||||
option
|
|
||||||
|
|
||||||
|
|
||||||
Option for us here is something which comes with a value 0
|
Option for us here is something which comes with a value 0
|
||||||
unlike a switch. For example, @c -o:filename might be an option which allows
|
unlike a switch. For example, @c -o:filename might be an option which allows
|
||||||
to specify the name of the output file.
|
to specify the name of the output file.
|
||||||
|
- @e parameter
|
||||||
|
|
||||||
parameter
|
|
||||||
|
|
||||||
|
|
||||||
This is a required program argument.
|
This is a required program argument.
|
||||||
|
|
||||||
|
|
||||||
@@ -118,7 +107,7 @@ public:
|
|||||||
|
|
||||||
@see EnableLongOptions()
|
@see EnableLongOptions()
|
||||||
*/
|
*/
|
||||||
bool AreLongOptionsEnabled();
|
bool AreLongOptionsEnabled() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Before Parse() can be called, the command line
|
Before Parse() can be called, the command line
|
||||||
@@ -286,6 +275,6 @@ public:
|
|||||||
|
|
||||||
@see SetLogo()
|
@see SetLogo()
|
||||||
*/
|
*/
|
||||||
void Usage();
|
void Usage() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -348,7 +348,7 @@ void wxCmdLineParser::EnableLongOptions(bool enable)
|
|||||||
m_data->m_enableLongOptions = enable;
|
m_data->m_enableLongOptions = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxCmdLineParser::AreLongOptionsEnabled()
|
bool wxCmdLineParser::AreLongOptionsEnabled() const
|
||||||
{
|
{
|
||||||
return m_data->m_enableLongOptions;
|
return m_data->m_enableLongOptions;
|
||||||
}
|
}
|
||||||
@@ -945,7 +945,7 @@ int wxCmdLineParser::Parse(bool showUsage)
|
|||||||
// give the usage message
|
// give the usage message
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxCmdLineParser::Usage()
|
void wxCmdLineParser::Usage() const
|
||||||
{
|
{
|
||||||
wxMessageOutput* msgOut = wxMessageOutput::Get();
|
wxMessageOutput* msgOut = wxMessageOutput::Get();
|
||||||
if ( msgOut )
|
if ( msgOut )
|
||||||
@@ -958,7 +958,7 @@ void wxCmdLineParser::Usage()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxCmdLineParser::GetUsageString()
|
wxString wxCmdLineParser::GetUsageString() const
|
||||||
{
|
{
|
||||||
wxString appname;
|
wxString appname;
|
||||||
if ( m_data->m_arguments.empty() )
|
if ( m_data->m_arguments.empty() )
|
||||||
|
Reference in New Issue
Block a user