Hydra 0.20
hydra::ArgumentParser Class Reference

#include <ArgumentParser.h>

List of all members.

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)

Detailed Description

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.

Author:
Aleksander Demko

Constructor & Destructor Documentation

hydra::ArgumentParser::ArgumentParser ( const QStringList &  args = QCoreApplication::arguments())

Initializes the parser with the given argument list. It uses the QCoreApplication arguments by default.

Author:
Aleksander Demko

Member Function Documentation

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.

Author:
Aleksander Demko
bool hydra::ArgumentParser::hasNextParam ( void  ) const

Is there a parameter available?

Author:
Aleksander Demko
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

Author:
Aleksander Demko
QString hydra::ArgumentParser::nextParam ( const QString &  switchName = 0)

Gets the next param, throws if empty.

Parameters:
switchNameis only used for exception generation purposes
Author:
Aleksander Demko

The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables