|
Hydra 0.20
|
#include <ArgumentParser.h>
Classes | |
| class | ErrorException |
| class | Exception |
| class | HelpException |
Public Member Functions | |
| ArgumentParser (const QStringList &args=QCoreApplication::arguments()) | |
| bool | hasNext (void) const |
| bool | hasNextParam (void) const |
| QString | next (bool *isswitch=0) |
| QString | nextParam (const QString &switchName=0) |
Parses command line arguments ("parameters") in a QDirIterator-like manner.
The first parameter is always the program name itself. You can remove it by calling next() immediatly.
Typically, you repeadedly call next() in a while(hasNext()) loop. You can also has* methods to forward-inspect the stream.
| hydra::ArgumentParser::ArgumentParser | ( | const QStringList & | args = QCoreApplication::arguments() | ) |
Initializes the parser with the given argument list. It uses the QCoreApplication arguments by default.
| bool hydra::ArgumentParser::hasNext | ( | void | ) | const |
Is there a switch or a parameter available? A switch begins with a - or --, everything else is a parameter. Note the the program name is the first parameter, always.
| bool hydra::ArgumentParser::hasNextParam | ( | void | ) | const |
Is there a parameter available?
| QString hydra::ArgumentParser::next | ( | bool * | isswitch = 0 | ) |
Returns the next switch or parameter. Examples "-s", "--switch", "blah". Switches are returned verbatem, hyphens and all.
Throws ArgsEmptyException on error. You can pre-test via hasNext
| QString hydra::ArgumentParser::nextParam | ( | const QString & | switchName = 0 | ) |
Gets the next param, throws if empty.
| switchName | is only used for exception generation purposes |