mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Const correctness, override keyword, a bunch of stuff..
This commit is contained in:
@@ -12,6 +12,7 @@ class ColorOption: public Option
|
||||
{
|
||||
protected:
|
||||
QColor _color;
|
||||
|
||||
public:
|
||||
ColorOption(const QString &name,
|
||||
const QString &description = QString(),
|
||||
@@ -31,9 +32,8 @@ public:
|
||||
: Option(other)
|
||||
{}
|
||||
|
||||
virtual bool validate(Parser & parser, QString & value) override;
|
||||
QColor getColor(Parser &parser)
|
||||
{ return _color; }
|
||||
bool validate(Parser & parser, QString & value) override;
|
||||
QColor getColor(Parser &parser) const { return _color; }
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ class ColorsOption: public Option
|
||||
{
|
||||
protected:
|
||||
QList<QColor> _colors;
|
||||
|
||||
public:
|
||||
ColorsOption(const QString &name,
|
||||
const QString &description = QString(),
|
||||
@@ -20,6 +21,7 @@ public:
|
||||
)
|
||||
: Option(name, description, valueName, defaultValue)
|
||||
{}
|
||||
|
||||
ColorsOption(const QStringList &names,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
@@ -27,13 +29,13 @@ public:
|
||||
)
|
||||
: Option(names, description, valueName, defaultValue)
|
||||
{}
|
||||
|
||||
ColorsOption(const QCommandLineOption &other)
|
||||
: Option(other)
|
||||
{}
|
||||
|
||||
virtual bool validate(Parser & parser, QString & value) override;
|
||||
QList<QColor> &getColors(Parser &parser)
|
||||
{ return _colors; }
|
||||
QList<QColor> getColors(Parser &parser) const { return _colors; }
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ class ImageOption: public Option
|
||||
{
|
||||
protected:
|
||||
QImage _image;
|
||||
|
||||
public:
|
||||
ImageOption(const QString &name,
|
||||
const QString &description = QString(),
|
||||
@@ -20,6 +21,7 @@ public:
|
||||
)
|
||||
: Option(name, description, valueName, defaultValue)
|
||||
{}
|
||||
|
||||
ImageOption(const QStringList &names,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
@@ -27,13 +29,13 @@ public:
|
||||
)
|
||||
: Option(names, description, valueName, defaultValue)
|
||||
{}
|
||||
|
||||
ImageOption(const QCommandLineOption &other)
|
||||
: Option(other)
|
||||
{}
|
||||
|
||||
virtual bool validate(Parser & parser, QString & value) override;
|
||||
QImage &getImage(Parser &parser)
|
||||
{ return _image; }
|
||||
bool validate(Parser & parser, QString & value) override;
|
||||
QImage& getImage(Parser &parser) { return _image; }
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ class IntOption: public ValidatorOption
|
||||
{
|
||||
protected:
|
||||
int _int;
|
||||
|
||||
public:
|
||||
IntOption(const QString &name,
|
||||
const QString &description = QString(),
|
||||
@@ -19,18 +20,26 @@ public:
|
||||
const QString &defaultValue = QString(),
|
||||
int minimum = std::numeric_limits<int>::min(), int maximum = std::numeric_limits<int>::max())
|
||||
: ValidatorOption(name, description, valueName, defaultValue)
|
||||
{ setValidator(new QIntValidator(minimum, maximum)); }
|
||||
{
|
||||
setValidator(new QIntValidator(minimum, maximum));
|
||||
}
|
||||
|
||||
IntOption(const QStringList &names,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString(),
|
||||
int minimum = std::numeric_limits<int>::min(), int maximum = std::numeric_limits<int>::max())
|
||||
: ValidatorOption(names, description, valueName, defaultValue)
|
||||
{ setValidator(new QIntValidator(minimum, maximum)); }
|
||||
{
|
||||
setValidator(new QIntValidator(minimum, maximum));
|
||||
}
|
||||
|
||||
IntOption(const QCommandLineOption &other,
|
||||
int minimum = std::numeric_limits<int>::min(), int maximum = std::numeric_limits<int>::max())
|
||||
: ValidatorOption(other)
|
||||
{ setValidator(new QIntValidator(minimum, maximum)); }
|
||||
{
|
||||
setValidator(new QIntValidator(minimum, maximum));
|
||||
}
|
||||
|
||||
int getInt(Parser &parser, bool *ok = 0, int base = 10);
|
||||
int *getIntPtr(Parser &parser, bool *ok = 0, int base = 10);
|
||||
|
@@ -26,13 +26,12 @@ public:
|
||||
);
|
||||
|
||||
Option(const QCommandLineOption &other);
|
||||
virtual ~Option() = default;
|
||||
|
||||
virtual bool validate(Parser &parser, QString &value);
|
||||
QString name();
|
||||
QString getError();
|
||||
QString value(Parser &parser);
|
||||
const char* getCString(Parser &parser);
|
||||
QString name() const;
|
||||
QString getError() const;
|
||||
QString value(Parser &parser) const;
|
||||
const char* getCString(Parser &parser) const;
|
||||
|
||||
protected:
|
||||
QString _error;
|
||||
|
@@ -93,76 +93,108 @@ public:
|
||||
return *option;
|
||||
}
|
||||
|
||||
Parser(QString description=QString())
|
||||
Parser(const QString& description = QString())
|
||||
{
|
||||
if(description.size())setApplicationDescription(description);
|
||||
if(description.size())
|
||||
setApplicationDescription(description);
|
||||
};
|
||||
|
||||
|
||||
QCommandLineOption addHelpOption()
|
||||
{
|
||||
return _parser.addHelpOption();
|
||||
};
|
||||
|
||||
|
||||
bool addOption(Option &option);
|
||||
bool addOption(Option *option);
|
||||
void addPositionalArgument(const QString &name, const QString &description, const QString &syntax = QString())
|
||||
{
|
||||
_parser.addPositionalArgument(name, description, syntax);
|
||||
};
|
||||
|
||||
|
||||
QCommandLineOption addVersionOption()
|
||||
{
|
||||
{
|
||||
return _parser.addVersionOption();
|
||||
};
|
||||
|
||||
QString applicationDescription() const
|
||||
{ return _parser.applicationDescription(); }
|
||||
|
||||
void clearPositionalArguments()
|
||||
{ _parser.clearPositionalArguments(); }
|
||||
|
||||
QString helpText() const
|
||||
{ return _parser.helpText(); }
|
||||
|
||||
bool isSet(const QString &name) const
|
||||
{ return _parser.isSet(name); }
|
||||
|
||||
bool isSet(const Option &option) const
|
||||
{ return _parser.isSet(option); }
|
||||
|
||||
bool isSet(const Option *option) const
|
||||
{ return _parser.isSet(*option); }
|
||||
|
||||
QStringList optionNames() const
|
||||
{ return _parser.optionNames(); }
|
||||
|
||||
QStringList positionalArguments() const
|
||||
{ return _parser.positionalArguments(); }
|
||||
|
||||
void setApplicationDescription(const QString &description)
|
||||
{ _parser.setApplicationDescription(description); }
|
||||
|
||||
void setSingleDashWordOptionMode(QCommandLineParser::SingleDashWordOptionMode singleDashWordOptionMode)
|
||||
{ _parser.setSingleDashWordOptionMode(singleDashWordOptionMode); }
|
||||
|
||||
void showHelp(int exitCode = 0)
|
||||
{ _parser.showHelp(exitCode); }
|
||||
|
||||
QStringList unknownOptionNames() const
|
||||
{ return _parser.unknownOptionNames(); }
|
||||
|
||||
QString value(const QString &optionName) const
|
||||
{ return _parser.value(optionName); }
|
||||
|
||||
QString value(const Option &option) const
|
||||
{ return _parser.value(option); }
|
||||
|
||||
QStringList values(const QString &optionName) const
|
||||
{ return _parser.values(optionName); }
|
||||
|
||||
QStringList values(const Option &option) const
|
||||
{ return _parser.values(option); }
|
||||
|
||||
QString applicationDescription() const
|
||||
{
|
||||
return _parser.applicationDescription();
|
||||
}
|
||||
|
||||
void clearPositionalArguments()
|
||||
{
|
||||
_parser.clearPositionalArguments();
|
||||
}
|
||||
|
||||
QString helpText() const
|
||||
{
|
||||
return _parser.helpText();
|
||||
}
|
||||
|
||||
bool isSet(const QString &name) const
|
||||
{
|
||||
return _parser.isSet(name);
|
||||
}
|
||||
|
||||
bool isSet(const Option &option) const
|
||||
{
|
||||
return _parser.isSet(option);
|
||||
}
|
||||
|
||||
bool isSet(const Option *option) const
|
||||
{
|
||||
return _parser.isSet(*option);
|
||||
}
|
||||
|
||||
QStringList optionNames() const
|
||||
{
|
||||
return _parser.optionNames();
|
||||
}
|
||||
|
||||
QStringList positionalArguments() const
|
||||
{
|
||||
return _parser.positionalArguments();
|
||||
}
|
||||
|
||||
void setApplicationDescription(const QString &description)
|
||||
{
|
||||
_parser.setApplicationDescription(description);
|
||||
}
|
||||
|
||||
void setSingleDashWordOptionMode(QCommandLineParser::SingleDashWordOptionMode singleDashWordOptionMode)
|
||||
{
|
||||
_parser.setSingleDashWordOptionMode(singleDashWordOptionMode);
|
||||
}
|
||||
|
||||
void showHelp(int exitCode = 0)
|
||||
{
|
||||
_parser.showHelp(exitCode);
|
||||
}
|
||||
|
||||
QStringList unknownOptionNames() const
|
||||
{
|
||||
return _parser.unknownOptionNames();
|
||||
}
|
||||
|
||||
QString value(const QString &optionName) const
|
||||
{
|
||||
return _parser.value(optionName);
|
||||
}
|
||||
|
||||
QString value(const Option &option) const
|
||||
{
|
||||
return _parser.value(option);
|
||||
}
|
||||
|
||||
QStringList values(const QString &optionName) const
|
||||
{
|
||||
return _parser.values(optionName);
|
||||
}
|
||||
|
||||
QStringList values(const Option &option) const
|
||||
{
|
||||
return _parser.values(option);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -17,12 +17,14 @@ public:
|
||||
const QString &defaultValue = QString())
|
||||
: ValidatorOption(name, description, valueName, defaultValue)
|
||||
{}
|
||||
|
||||
RegularExpressionOption(const QStringList &names,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString())
|
||||
: ValidatorOption(names, description, valueName, defaultValue)
|
||||
{}
|
||||
|
||||
RegularExpressionOption(const QCommandLineOption &other)
|
||||
: ValidatorOption(other)
|
||||
{}
|
||||
@@ -33,18 +35,26 @@ public:
|
||||
const QString &defaultValue = QString(),
|
||||
const QRegularExpression &expression = QRegularExpression())
|
||||
: ValidatorOption(name, description, valueName, defaultValue)
|
||||
{ setValidator(new QRegularExpressionValidator(expression)); }
|
||||
{
|
||||
setValidator(new QRegularExpressionValidator(expression));
|
||||
}
|
||||
|
||||
RegularExpressionOption(const QStringList &names,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString(),
|
||||
const QRegularExpression &expression = QRegularExpression())
|
||||
: ValidatorOption(names, description, valueName, defaultValue)
|
||||
{ setValidator(new QRegularExpressionValidator(expression)); }
|
||||
{
|
||||
setValidator(new QRegularExpressionValidator(expression));
|
||||
}
|
||||
|
||||
RegularExpressionOption(const QCommandLineOption &other,
|
||||
const QRegularExpression &expression = QRegularExpression())
|
||||
: ValidatorOption(other)
|
||||
{ setValidator(new QRegularExpressionValidator(expression)); }
|
||||
{
|
||||
setValidator(new QRegularExpressionValidator(expression));
|
||||
}
|
||||
|
||||
RegularExpressionOption(const QString &name,
|
||||
const QString &description = QString(),
|
||||
@@ -52,18 +62,26 @@ public:
|
||||
const QString &defaultValue = QString(),
|
||||
const QString &expression = QString())
|
||||
: ValidatorOption(name, description, valueName, defaultValue)
|
||||
{ setValidator(new QRegularExpressionValidator(QRegularExpression(expression))); }
|
||||
{
|
||||
setValidator(new QRegularExpressionValidator(QRegularExpression(expression)));
|
||||
}
|
||||
|
||||
RegularExpressionOption(const QStringList &names,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString(),
|
||||
const QString &expression = QString())
|
||||
: ValidatorOption(names, description, valueName, defaultValue)
|
||||
{ setValidator(new QRegularExpressionValidator(QRegularExpression(expression))); }
|
||||
{
|
||||
setValidator(new QRegularExpressionValidator(QRegularExpression(expression)));
|
||||
}
|
||||
|
||||
RegularExpressionOption(const QCommandLineOption &other,
|
||||
const QString &expression = QString())
|
||||
: ValidatorOption(other)
|
||||
{ setValidator(new QRegularExpressionValidator(QRegularExpression(expression))); }
|
||||
{
|
||||
setValidator(new QRegularExpressionValidator(QRegularExpression(expression)));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -30,8 +30,6 @@ public:
|
||||
: Option(other), _switches(switches)
|
||||
{}
|
||||
|
||||
virtual ~SwitchOption() {}
|
||||
|
||||
const QMap<QString, T> &getSwitches() const { return _switches; }
|
||||
virtual bool validate(Parser &parser, QString &switch_) override { return hasSwitch(switch_); }
|
||||
bool hasSwitch(const QString &switch_) { return _switches.contains(switch_.toLower()); }
|
||||
|
@@ -13,6 +13,7 @@ class ValidatorOption: public Option
|
||||
protected:
|
||||
const QValidator *validator;
|
||||
virtual void setValidator(const QValidator *validator);
|
||||
|
||||
public:
|
||||
ValidatorOption(const QString &name,
|
||||
const QString &description = QString(),
|
||||
@@ -21,6 +22,7 @@ public:
|
||||
const QValidator *validator = nullptr)
|
||||
: Option(name, description, valueName, defaultValue), validator(validator)
|
||||
{}
|
||||
|
||||
ValidatorOption(const QStringList &names,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
@@ -28,6 +30,7 @@ public:
|
||||
const QValidator *validator = nullptr)
|
||||
: Option(names, description, valueName, defaultValue), validator(validator)
|
||||
{}
|
||||
|
||||
ValidatorOption(const QCommandLineOption &other,
|
||||
const QValidator *validator = nullptr)
|
||||
: Option(other), validator(validator)
|
||||
|
Reference in New Issue
Block a user