From fa5d40006cc22b51dd231052367684eb107e3915 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 16 Apr 2018 05:27:01 -0400 Subject: [PATCH] [locale] Fix interpretation of configured selector - In GeoIP handler constructors that take a string (to configure the selector to use), interpret the empty string (which generally isn't a meaningful selector) as meaning "use the default". - Drop the no-argument constructors in favor of a default-argument which is empty. --- src/modules/locale/GeoIPJSON.cpp | 8 +------- src/modules/locale/GeoIPJSON.h | 8 ++++++-- src/modules/locale/GeoIPXML.cpp | 8 +------- src/modules/locale/GeoIPXML.h | 10 ++++++---- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/modules/locale/GeoIPJSON.cpp b/src/modules/locale/GeoIPJSON.cpp index aa5a2b411..b5cf40214 100644 --- a/src/modules/locale/GeoIPJSON.cpp +++ b/src/modules/locale/GeoIPJSON.cpp @@ -27,16 +27,10 @@ #include GeoIPJSON::GeoIPJSON(const QString& attribute) - : GeoIP( attribute ) + : GeoIP( attribute.isEmpty() ? QLatin1String( "time_zone" ) : attribute ) { } -GeoIPJSON::GeoIPJSON() - : GeoIPJSON( QLatin1Literal( "time_zone" ) ) -{ -} - - GeoIP::RegionZonePair GeoIPJSON::processReply( const QByteArray& data ) { diff --git a/src/modules/locale/GeoIPJSON.h b/src/modules/locale/GeoIPJSON.h index dbe1eeffa..3c08f577b 100644 --- a/src/modules/locale/GeoIPJSON.h +++ b/src/modules/locale/GeoIPJSON.h @@ -31,8 +31,12 @@ class GeoIPJSON : public GeoIP { public: - explicit GeoIPJSON( const QString& attribute ); - explicit GeoIPJSON(); + /** @brief Configure the attribute name which is selected. + * + * If an empty string is passed in (not a valid attribute name), + * then "time_zone" is used. + */ + explicit GeoIPJSON( const QString& attribute = QString() ); virtual RegionZonePair processReply( const QByteArray& ); } ; diff --git a/src/modules/locale/GeoIPXML.cpp b/src/modules/locale/GeoIPXML.cpp index a2117b2f2..a9aa43f76 100644 --- a/src/modules/locale/GeoIPXML.cpp +++ b/src/modules/locale/GeoIPXML.cpp @@ -24,16 +24,10 @@ #include GeoIPXML::GeoIPXML( const QString& element ) - : GeoIP( element ) + : GeoIP( element.isEmpty() ? QLatin1String( "TimeZone" ) : element ) { } -GeoIPXML::GeoIPXML() - : GeoIPXML( QLatin1Literal( "TimeZone" ) ) -{ -} - - GeoIP::RegionZonePair GeoIPXML::processReply( const QByteArray& data ) { diff --git a/src/modules/locale/GeoIPXML.h b/src/modules/locale/GeoIPXML.h index bda359485..bc3f23bec 100644 --- a/src/modules/locale/GeoIPXML.h +++ b/src/modules/locale/GeoIPXML.h @@ -31,10 +31,12 @@ class GeoIPXML : public GeoIP { public: - /** @brief Configure the element name which is selected. */ - explicit GeoIPXML( const QString& element ); - /** @brief Use default TimeZone element. */ - explicit GeoIPXML(); + /** @brief Configure the element tag which is selected. + * + * If an empty string is passed in (not a valid element tag), + * then "TimeZone" is used. + */ + explicit GeoIPXML( const QString& element = QString() ); virtual RegionZonePair processReply( const QByteArray& ); } ;