BPS C++ API  2.24.4
bpscmdlineparser.h
Go to the documentation of this file.
1 
4 #ifndef BPSCMDLINEPARSER_H
5 #define BPSCMDLINEPARSER_H
6 
7 #include "bpscore_global.h"
8 #include <QObject>
9 #include <QScriptable>
10 #include <QString>
11 #include <QStringList>
12 
97 class BPSCORE_EXPORT BpsCmdlineParser : public QObject, protected QScriptable
98 {
99  Q_OBJECT
101 
102 public:
103 
108  BpsCmdlineParser(QObject* aParent = nullptr);
109 
110  virtual ~BpsCmdlineParser();
111 
112 public slots:
113 
127  BpsCmdlineParser& setDescription(const QString& aDescription);
128 
135 
146 
158 
169 
181  BpsCmdlineParser& addSwitch(QChar aKey, const QString& aName, const QString& aInfo);
182 
196  BpsCmdlineParser& addHelpSwitch(QChar aKey, const QString& aName, const QString& aInfo);
197 
210  BpsCmdlineParser& addOption(QChar aKey, const QString& aName, const QString& aParam, const QString& aInfo);
211 
224  BpsCmdlineParser& addOptions(QChar aKey, const QString& aName, const QString& aParam, const QString& aInfo);
225 
233 
238  QString program() const;
239 
245  QString mandatory(const QString& aParam) const;
246 
253  QString optional(const QString& aParam) const;
254 
261 
268  bool switchState(QChar aKey, const QString& aName = QString()) const;
269 
277  QString option(QChar aKey, const QString& aName = QString()) const;
278 
286  QStringList options(QChar aKey, const QString& aName = QString()) const;
287 
325  QString help(int aWidth = 79) const;
326 
327 };
328 
329 #endif // BPSCMDLINEPARSER_H
Public include file for BPS CORE library macros.
#define BPSCORE_EXPORT
Declare class to be an import from the shared library.
Definition: bpscore_global.h:22
#define BPS_PRIVATE(Class)
Declare pointer to private object in a public class.
Definition: bpsglobals.h:102
A parser for command line arguments.
Definition: bpscmdlineparser.h:98
QString program() const
Query the invoked program after parsing the arguments.
QString mandatory(const QString &aParam) const
Query a mandatory parameter after parsing the arguments.
QString optional(const QString &aParam) const
Query an optional single parameter after parsing the arguments.
BpsCmdlineParser & parse()
Parses the command line.
BpsCmdlineParser & addOptional(const QString &aParam)
Add a single optional parameter.
BpsCmdlineParser(QObject *aParent=nullptr)
Default constructor for the BpsCmdlineParser class.
BpsCmdlineParser & addOptions(QChar aKey, const QString &aName, const QString &aParam, const QString &aInfo)
Adds a option that can occure multiple times with either a single character key and / or a key name.
BpsCmdlineParser & addHelpSwitch(QChar aKey, const QString &aName, const QString &aInfo)
Adds a help-type switch with either a single character key and / or a key name.
BpsCmdlineParser & addOptionals(const QString &aParam)
Add a multiple optional parameter.
BpsCmdlineParser & setProgram(const QString &aName)
Set the program name used by the help() funcion.
bool switchState(QChar aKey, const QString &aName=QString()) const
Query a switch after parsing the arguments.
BpsCmdlineParser & addSwitch(QChar aKey, const QString &aName, const QString &aInfo)
Adds a switch with either a single character key and / or a key name.
BpsCmdlineParser & addMandatory(const QString &aParam)
Add a mandatory parameter.
QStringList optionals() const
Query the multiple optional parameter after parsing the arguments.
QString option(QChar aKey, const QString &aName=QString()) const
Query an option value after parsing the arguments.
BpsCmdlineParser & setDescription(const QString &aDescription)
Set the description what the program is supposed to do.
QStringList options(QChar aKey, const QString &aName=QString()) const
Query options values after parsing the arguments.
QString help(int aWidth=79) const
Formats a help message for the command line parser.
BpsCmdlineParser & addOption(QChar aKey, const QString &aName, const QString &aParam, const QString &aInfo)
Adds a option with either a single character key and / or a key name.