Class to handle command line arguments and options.
More...
#include <ecmdlineargs.h>
Class to handle command line arguments and options.
The class allows easy handling of command line arguments and options. To add a provided option or argument, use add(const QByteArray&, const QByteArray&, const QString&, const QByteArray&) or add(ECmdLineOption*). To get information about the added options, call init() first. Afterwards you can use isSet() to determine, if an option is set or getOption() to get back the result of the option.
- Note
- The options -v –version and -h –help are added and handled automatically.
args.
add(
"[user] <argument>",
"u",
"The user");
args.
add(
"+file",
"",
"A path to a file");
- See also
- ECmdLineOption
ECmdLineArgs::ECmdLineArgs |
( |
EPart * |
part = NULL | ) |
|
ECmdLineArgs::~ECmdLineArgs |
( |
| ) |
|
|
virtual |
void ECmdLineArgs::add |
( |
const QByteArray & |
name, |
|
|
const QByteArray & |
alias = QByteArray() , |
|
|
const QString & |
description = QString() , |
|
|
const QByteArray & |
defaultValue = QByteArray() |
|
) |
| |
void ECmdLineArgs::addToKCmdLineOptions |
( |
KCmdLineOptions * |
option | ) |
const |
Adds all options to the given KCmdLineOptions option
.
If KDE is not enabled, this function does nothing.
ECmdLineOption * ECmdLineArgs::findOption |
( |
const QByteArray & |
option | ) |
const |
|
private |
QString ECmdLineArgs::getOption |
( |
const QByteArray & |
option | ) |
const |
Returns the value of option
.
It uses isSet() to set the value of option
. option
is the name of the option without any special characters like [], + or so (e.g. For "+[optionname] option
should be optionname).
bool ECmdLineArgs::init |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Instantiate the given options.
- Returns
- true if everything can be proceeded and false, if the application should exit. E.g. this can be the case, if the option -v or -h is chosen.
bool ECmdLineArgs::isSet |
( |
const QByteArray & |
option | ) |
const |
Checks wether the option
is set.
If option
is set, it also set's the value of the option
to the first value of the occurence. option
is the name of the option without any special characters like [], + or so (e.g. For "+[optionname] option
should be optionname).
- Todo:
- improve handling of optional arguments and not optional arguments
void ECmdLineArgs::showHelp |
( |
| ) |
const |
|
protectedvirtual |
Shows the help.
If you use ECmdLineArgs within your own application (not EPart based) you should subclass it and reimplement this function along with showVersion().
void ECmdLineArgs::showVersion |
( |
| ) |
const |
|
protectedvirtual |
Shows version information of Qt, KDE, LibEngsas and the EPart.
If you use ECmdLineArgs within your own application (not EPart based) you should subclass it and reimplement this function along with showHelp().
- Todo:
- show LibEngsas version number
char** ECmdLineArgs::argv |
|
private |
QPointer<EPart> ECmdLineArgs::part |
|
private |
The documentation for this class was generated from the following files: