2016-08-28 15:10:43 +02:00
|
|
|
#include "commandline/Option.h"
|
|
|
|
#include "commandline/Parser.h"
|
|
|
|
|
|
|
|
using namespace commandline;
|
|
|
|
|
2017-03-04 22:17:42 +01:00
|
|
|
Option::Option(const QString &name, const QString &description, const QString &valueName, const QString &defaultValue)
|
|
|
|
: QCommandLineOption(name, description, valueName, defaultValue)
|
|
|
|
{}
|
|
|
|
|
|
|
|
Option::Option(const QStringList &names, const QString &description, const QString &valueName, const QString &defaultValue)
|
|
|
|
: QCommandLineOption(names, description, valueName, defaultValue)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
2016-08-28 15:10:43 +02:00
|
|
|
bool Option::validate(Parser & parser, QString &value)
|
|
|
|
{
|
|
|
|
/* By default everything is accepted */
|
2017-02-11 22:52:47 +01:00
|
|
|
return true;
|
2016-08-28 15:10:43 +02:00
|
|
|
}
|
|
|
|
|
2017-03-04 22:17:42 +01:00
|
|
|
Option::Option(const QCommandLineOption &other)
|
|
|
|
: QCommandLineOption(other)
|
|
|
|
{}
|
|
|
|
|
2016-08-28 15:10:43 +02:00
|
|
|
QString Option::value(Parser &parser)
|
|
|
|
{
|
2017-02-11 22:52:47 +01:00
|
|
|
return parser.value(*this);
|
2016-08-28 15:10:43 +02:00
|
|
|
}
|
|
|
|
|
2017-03-04 22:17:42 +01:00
|
|
|
QString Option::name()
|
2016-08-28 15:10:43 +02:00
|
|
|
{
|
2017-03-04 22:17:42 +01:00
|
|
|
return this->names().last();
|
2016-08-28 15:10:43 +02:00
|
|
|
}
|
|
|
|
|
2017-03-04 22:17:42 +01:00
|
|
|
QString Option::getError()
|
2016-08-28 15:10:43 +02:00
|
|
|
{
|
2017-03-04 22:17:42 +01:00
|
|
|
return this->_error;
|
2016-08-28 15:10:43 +02:00
|
|
|
}
|
|
|
|
|
2016-09-17 00:40:29 +02:00
|
|
|
const char* Option::getCString(Parser &parser)
|
|
|
|
{
|
2017-02-11 22:52:47 +01:00
|
|
|
return value(parser).toLocal8Bit().constData();
|
2016-09-17 00:40:29 +02:00
|
|
|
}
|