Fix standalone grabbers (#1384)

* Fix too much copy/paste
* Fix typo
* Commandlineoptions: Additional error details for Int and Double ranges
* Standalone grabbers: Show fps range on error, fix default host address
This commit is contained in:
LordGrey
2021-11-29 17:51:03 +00:00
committed by GitHub
parent 926a58de9c
commit e3b494428a
16 changed files with 84 additions and 36 deletions

View File

@@ -26,20 +26,28 @@ public:
double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000)
: ValidatorOption(names, description, valueName, defaultValue)
{
setValidator(new QDoubleValidator(minimum, maximum, decimals));
_minimum = minimum;
_maximum = maximum;
setValidator(new QDoubleValidator(_minimum, _maximum, decimals));
}
DoubleOption(const QCommandLineOption &other, double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000)
: ValidatorOption(other)
{
setValidator(new QDoubleValidator(minimum, maximum, decimals));
_minimum = minimum;
_maximum = maximum;
setValidator(new QDoubleValidator(_minimum, _maximum, decimals));
}
double getDouble(Parser &parser, bool *ok = 0);
double *getDoublePtr(Parser &parser, bool *ok = 0);
bool validate(Parser & parser, QString & value) override;
protected:
double _double;
int _minimum;
int _maximum;
};
}

View File

@@ -12,6 +12,8 @@ class IntOption: public ValidatorOption
{
protected:
int _int;
int _minimum;
int _maximum;
public:
IntOption(const QString &name,
@@ -31,18 +33,24 @@ public:
int minimum = std::numeric_limits<int>::min(), int maximum = std::numeric_limits<int>::max())
: ValidatorOption(names, description, valueName, defaultValue)
{
setValidator(new QIntValidator(minimum, maximum));
_minimum = minimum;
_maximum = 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));
_minimum = minimum;
_maximum = 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);
bool validate(Parser & parser, QString & value) override;
};
}

View File

@@ -61,6 +61,11 @@ namespace NetUtils {
///
inline bool resolveHostPort(const QString& address, QString& host, quint16& port)
{
if (address.isEmpty())
{
return false;
}
QString testUrl;
if (address.at(0) != '[' && address.count(':') > 1)
{
@@ -87,10 +92,10 @@ namespace NetUtils {
///
/// @brief Check if the port is in the valid range
/// @param log The logger of the caller to print
/// @param[in] address The port to be tested
/// @param log The logger of the caller to print
/// @param[in] address The port to be tested
/// @param[out] hostAddress A hostname to make reference to during logging
/// @return True on success else false
/// @return True on success else false
///
inline bool resolveHostAddress(Logger* log, const QString& address, QHostAddress& hostAddress)