2016-08-28 15:10:43 +02:00
|
|
|
#include "commandline/ValidatorOption.h"
|
|
|
|
#include "commandline/Parser.h"
|
|
|
|
|
|
|
|
using namespace commandline;
|
|
|
|
|
|
|
|
bool ValidatorOption::validate(Parser & parser, QString & value)
|
|
|
|
{
|
2017-02-11 22:52:47 +01:00
|
|
|
if (parser.isSet(*this) || !defaultValues().empty())
|
|
|
|
{
|
2016-08-28 15:10:43 +02:00
|
|
|
int pos = 0;
|
|
|
|
validator->fixup(value);
|
|
|
|
return validator->validate(value, pos) == QValidator::Acceptable;
|
|
|
|
}
|
2017-02-11 22:52:47 +01:00
|
|
|
return true;
|
2016-08-28 15:10:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const QValidator *ValidatorOption::getValidator() const
|
|
|
|
{
|
2017-02-11 22:52:47 +01:00
|
|
|
return validator;
|
2016-08-28 15:10:43 +02:00
|
|
|
}
|
2017-02-11 22:52:47 +01:00
|
|
|
|
2016-08-28 15:10:43 +02:00
|
|
|
void ValidatorOption::setValidator(const QValidator *validator)
|
|
|
|
{
|
2017-02-11 22:52:47 +01:00
|
|
|
ValidatorOption::validator = validator;
|
2016-08-28 15:10:43 +02:00
|
|
|
}
|
|
|
|
|