Represents one command line argument or option.
More...
#include <ecmdlineoption.h>
Public Member Functions |
| ECmdLineOption (const QByteArray &name, const QByteArray &alias=QByteArray(), const QString &description=QString(), const QByteArray &defaultValue=QByteArray()) |
void | setName (const QByteArray &name) |
| Sets the name of the option.
|
QByteArray | name () const |
bool | requiresArgument () const |
| Returns true, if the option requires an argument.
|
bool | isArgument () const |
| Returns true, if the option is an argument.
|
bool | isOptional () const |
| Returns true, if the option or argument is optional.
|
void | setAlias (const QByteArray &alias) |
| The alias of this option.
|
QByteArray | alias () const |
void | setDescription (const QString &description=QString()) |
| The description of this option, which is used at the help.
|
QString | description () const |
void | setDefaultValue (const QByteArray &defaultValue=QByteArray()) |
| The default vaule, if no value is given.
|
QByteArray | defaultValue () const |
void | setIsSet (bool status=true) |
bool | isSet () const |
| Is true, if the option is set at the command line.
|
void | setValue (const QByteArray &value) |
QByteArray | value () const |
| Returns the value, which is specified via the command line.
|
QString | usage () const |
| The part at the usage line in help.
|
QString | helpLine () const |
| The help line for this option in help.
|
void | addToKCmdLineOptions (KCmdLineOptions *option) const |
| Adds this option to the given KCmdLineOptions option .
|
Detailed Description
Represents one command line argument or option.
It is used by ECmdLineArgs to handle available options and parse the given arguments.
- Todo:
- add convenience functions for the use of QStrings instead of QByteArrays
Constructor & Destructor Documentation
ECmdLineOption::ECmdLineOption |
( |
const QByteArray & |
name, |
|
|
const QByteArray & |
alias = QByteArray() , |
|
|
const QString & |
description = QString() , |
|
|
const QByteArray & |
defaultValue = QByteArray() |
|
) |
| |
To find out more about the parameters and espacially about name
, to add optional options and or arguments, look at setName().
- Parameters
-
Member Function Documentation
void ECmdLineOption::addToKCmdLineOptions |
( |
KCmdLineOptions * |
option | ) |
const |
Adds this option to the given KCmdLineOptions option
.
If KDE is not enabled, this function does nothing.
QByteArray ECmdLineOption::alias |
( |
| ) |
const |
QByteArray ECmdLineOption::defaultValue |
( |
| ) |
const |
QString ECmdLineOption::description |
( |
| ) |
const |
QString ECmdLineOption::helpLine |
( |
| ) |
const |
The help line for this option in help.
bool ECmdLineOption::isArgument |
( |
| ) |
const |
Returns true, if the option is an argument.
This is the case, if the name is something like
bool ECmdLineOption::isOptional |
( |
| ) |
const |
Returns true, if the option or argument is optional.
This is the case, if the option name contains [ and ].
bool ECmdLineOption::isSet |
( |
| ) |
const |
Is true, if the option is set at the command line.
QByteArray ECmdLineOption::name |
( |
| ) |
const |
bool ECmdLineOption::requiresArgument |
( |
| ) |
const |
Returns true, if the option requires an argument.
This is the case, if the option name is something like
void ECmdLineOption::setAlias |
( |
const QByteArray & |
alias | ) |
|
The alias of this option.
E.g. set it to "u" if the option is "user" and should be accessible through "-u".
void ECmdLineOption::setDefaultValue |
( |
const QByteArray & |
defaultValue = QByteArray() | ) |
|
The default vaule, if no value is given.
The default default value is an empty QByteArray().
void ECmdLineOption::setDescription |
( |
const QString & |
description = QString() | ) |
|
The description of this option, which is used at the help.
void ECmdLineOption::setIsSet |
( |
bool |
status = true | ) |
|
void ECmdLineOption::setName |
( |
const QByteArray & |
name | ) |
|
Sets the name of the option.
It also analyze the name as following:
- name <argument> - The option with name "name" requires an argument
- +name - The option is an required argument
- [name] - The option is optional (combineable with the ones before)
void ECmdLineOption::setValue |
( |
const QByteArray & |
value | ) |
|
QString ECmdLineOption::usage |
( |
| ) |
const |
The part at the usage line in help.
QByteArray ECmdLineOption::value |
( |
| ) |
const |
Returns the value, which is specified via the command line.
Or it returns an the defaultValue() if no value is given.
Member Data Documentation
QByteArray ECmdLineOption::myAlias |
|
private |
QByteArray ECmdLineOption::myDefaultValue |
|
private |
QString ECmdLineOption::myDescription |
|
private |
bool ECmdLineOption::myIsArgument |
|
private |
bool ECmdLineOption::myIsOptional |
|
private |
bool ECmdLineOption::myIsSet |
|
private |
QByteArray ECmdLineOption::myName |
|
private |
bool ECmdLineOption::myRequiresArgument |
|
private |
QByteArray ECmdLineOption::myValue |
|
private |
The documentation for this class was generated from the following files: