remove default parameter, because it leads only to confusion and errors

This commit is contained in:
Martin Marmsoler
2020-10-10 12:02:38 +02:00
parent 9b8c0101be
commit f18e6bd50f
9 changed files with 40 additions and 52 deletions

View File

@@ -150,13 +150,11 @@ bool PropertiesInterface::attribute(const QDomElement& e, const QString& attribu
* \return True if reading an integer was successful, else False. If the attribute was not found,
* \p entier is not valid and the return value is False
*/
PropertiesInterface::PropertyFlags PropertiesInterface::propertyInteger(const QDomElement &e, const QString& attribute_name, int* entier, bool setDefaultValue, int defaultValue) {
PropertiesInterface::PropertyFlags PropertiesInterface::propertyInteger(const QDomElement &e, const QString& attribute_name, int* entier) {
QString attr;
if (!attribute(e, attribute_name, integerS, &attr)) {
if (entier && setDefaultValue)
*entier = defaultValue;
return PropertyFlags::NotFound;
}
@@ -174,13 +172,11 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyInteger(const QD
return PropertyFlags::Success;
}
PropertiesInterface::PropertyFlags PropertiesInterface::propertyDouble(const QDomElement &e, const QString& attribute_name, double* reel, bool setDefaultValue, double defaultValue) {
PropertiesInterface::PropertyFlags PropertiesInterface::propertyDouble(const QDomElement &e, const QString& attribute_name, double* reel) {
QString attr;
if (!attribute(e, attribute_name, doubleS, &attr)) {
if (reel && setDefaultValue)
*reel = defaultValue;
return PropertyFlags::NotFound;
}
@@ -198,13 +194,11 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyDouble(const QDo
return PropertyFlags::Success;
}
PropertiesInterface::PropertyFlags PropertiesInterface::propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean, bool setDefaultValue, bool defaultValue) {
PropertiesInterface::PropertyFlags PropertiesInterface::propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean) {
QString attr;
if (!attribute(e, attribute_name, boolS, &attr)) {
if (boolean && setDefaultValue)
*boolean = defaultValue;
return PropertyFlags::NotFound;
}
@@ -228,13 +222,11 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyBool(const QDomE
return PropertyFlags::Success;
}
PropertiesInterface::PropertyFlags PropertiesInterface::propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color, bool setDefaultValue, QColor defaultValue) {
PropertiesInterface::PropertyFlags PropertiesInterface::propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color) {
QString attr;
if (!attribute(e, attribute_name, colorS, &attr)) {
if (color && setDefaultValue)
*color = defaultValue;
return PropertyFlags::NotFound;
}
@@ -251,12 +243,10 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyColor(const QDom
return PropertyFlags::Success;
}
PropertiesInterface::PropertyFlags PropertiesInterface::propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid, bool setDefaultValue, QUuid defaultValue) {
PropertiesInterface::PropertyFlags PropertiesInterface::propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid) {
QString attr;
if (!attribute(e, attribute_name, uuidS, &attr)) {
if (uuid && setDefaultValue)
*uuid = defaultValue;
return PropertyFlags::NotFound;
}
@@ -272,12 +262,10 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyUuid(const QDomE
return PropertyFlags::Success;
}
PropertiesInterface::PropertyFlags PropertiesInterface::propertyString(const QDomElement& e, const QString& attribute_name, QString* string, bool setDefaultValue, QString defaultValue) {
PropertiesInterface::PropertyFlags PropertiesInterface::propertyString(const QDomElement& e, const QString& attribute_name, QString* string) {
QString attr;
if (!attribute(e, attribute_name, stringS, &attr)) {
if (string && setDefaultValue)
*string = defaultValue;
return PropertyFlags::NotFound;
}

View File

@@ -66,12 +66,12 @@ class PropertiesInterface
/*!
* Try not using the default Value feature. It is better to initialize the class members in the class definition!
*/
static PropertyFlags propertyInteger(const QDomElement &e, const QString& attribute_name, int *entier = nullptr, bool setDefaultValue = false, int defaultValue = std::numeric_limits<int>::quiet_NaN());
static PropertyFlags propertyDouble(const QDomElement &e, const QString& attribute_name, double *reel = nullptr, bool setDefaultValue = false, double defaultValue = std::numeric_limits<double>::quiet_NaN());
static PropertyFlags propertyString(const QDomElement& e, const QString& attribute_name, QString* string = nullptr, bool setDefaultValue = false, QString defaultValue = QString());
static PropertyFlags propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean = nullptr, bool setDefaultValue = false, bool defaultValue = false);
static PropertyFlags propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid = nullptr, bool setDefaultValue = false, QUuid defaultValue = QUuid());
static PropertyFlags propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color = nullptr, bool setDefaultValue = false, QColor defaultValue = QColor());
static PropertyFlags propertyInteger(const QDomElement &e, const QString& attribute_name, int *entier = nullptr);
static PropertyFlags propertyDouble(const QDomElement &e, const QString& attribute_name, double *reel = nullptr);
static PropertyFlags propertyString(const QDomElement& e, const QString& attribute_name, QString* string = nullptr);
static PropertyFlags propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean = nullptr);
static PropertyFlags propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid = nullptr);
static PropertyFlags propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color = nullptr);
static bool validXmlProperty(const QDomElement& e);