Workspace 6.21.5
Public Member Functions | Protected Member Functions | List of all members
WorkspaceArgumentsParser Class Reference

Helper class for dealing with command line arguments supplied to a workspace application. More...

#include <Workspace/Application/workspaceargumentsparser.h>

Inheritance diagram for WorkspaceArgumentsParser:
[legend]

Public Member Functions

 WorkspaceArgumentsParser (const QStringList &expectedArguments=QStringList(), const QString &usageHeader=QString())
 
- Public Member Functions inherited from ArgumentsParser
 ArgumentsParser (ArgumentsParser &&args)
 
 ArgumentsParser (const ArgumentsParser &args)
 
 ArgumentsParser (const QStringList &expectedArguments=QStringList(), const QString &usageHeader="")
 
virtual ~ArgumentsParser ()
 
QString argument (int index) const
 
bool flagExists (const QString &name) const
 
int flagOccurrence (const QString &name) const
 
QString flagParameter (const QString &name, int paramIndex, int occurrence=0) const
 
QStringList flagParameters (const QString &name, int occurrence=0) const
 
const QStringListgetArguments () const
 
int numArguments () const
 
ArgumentsParseroperator= (ArgumentsParser args)
 
bool parse (const QStringList &arguments, int &exitCode)
 
virtual QString usage () const
 

Protected Member Functions

bool validate (int &exitCode) override
 
- Protected Member Functions inherited from ArgumentsParser
void addSupportedFlag (const QString &name, const QString &description, int numParameters=0, const QStringList &paramNames=QStringList(), bool developOnly=false)
 
void logError (const QString &msg)
 
void purgeArgument (int index)
 
void purgeFlag (const QString &name, int occurrence=0)
 
virtual bool validate (int &exitCode)
 

Additional Inherited Members

- Static Public Member Functions inherited from ArgumentsParser
static bool parseBoolean (const QString &s)
 
static bool validBoolean (const QString &s)
 

Detailed Description

Workspace applications may use this class as is, or they may subclass it further to add their own flags to the standard set of options. Subclass impmlementors should note that validate() returns an exit code of 1 if it encounters any problems in the arguments (in which case it also returns false to indicate failure).

Constructor & Destructor Documentation

◆ WorkspaceArgumentsParser()

WorkspaceArgumentsParser ( const QStringList expectedArguments = QStringList(),
const QString &  usageHeader = QString() 
)

Member Function Documentation

◆ validate()

bool validate ( int &  exitCode)
overrideprotectedvirtual
Parameters
exitCodeUpon returning, this will be set to 1 if any errors are encountered, in which case validate() will also return false.

Reimplemented from ArgumentsParser.