2017-03-04 22:17:42 +01:00
|
|
|
#pragma once
|
2016-08-28 15:10:43 +02:00
|
|
|
|
|
|
|
#include <QCommandLineOption>
|
|
|
|
#include <QCommandLineParser>
|
|
|
|
|
|
|
|
namespace commandline
|
|
|
|
{
|
|
|
|
|
|
|
|
class Parser;
|
|
|
|
|
|
|
|
/* Note, this class and all it's derivatives store the validated results for caching. This means that unlike the
|
|
|
|
* regular QCommandLineOption it is _not_ idempotent! */
|
|
|
|
class Option: public QCommandLineOption
|
|
|
|
{
|
|
|
|
public:
|
2017-03-04 22:17:42 +01:00
|
|
|
Option(const QString &name,
|
|
|
|
const QString &description = QString(),
|
2019-07-10 10:24:40 +02:00
|
|
|
const QString &valueName = QString(),
|
2017-03-04 22:17:42 +01:00
|
|
|
const QString &defaultValue = QString()
|
|
|
|
);
|
|
|
|
|
|
|
|
Option(const QStringList &names,
|
|
|
|
const QString &description = QString(),
|
2019-07-10 10:24:40 +02:00
|
|
|
const QString &valueName = QString(),
|
2017-03-04 22:17:42 +01:00
|
|
|
const QString &defaultValue = QString()
|
|
|
|
);
|
|
|
|
|
|
|
|
Option(const QCommandLineOption &other);
|
2020-08-02 22:35:09 +02:00
|
|
|
virtual ~Option() = default;
|
2017-03-04 22:17:42 +01:00
|
|
|
|
|
|
|
virtual bool validate(Parser &parser, QString &value);
|
|
|
|
QString name();
|
2020-08-02 22:35:09 +02:00
|
|
|
QString getError();
|
|
|
|
QString value(Parser &parser);
|
2017-03-04 22:17:42 +01:00
|
|
|
const char* getCString(Parser &parser);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
QString _error;
|
2016-08-28 15:10:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|