[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.
This commit is contained in:
Adriaan de Groot 2018-04-16 05:27:01 -04:00
parent 352b385b12
commit fa5d40006c
4 changed files with 14 additions and 20 deletions

View File

@ -27,16 +27,10 @@
#include <yaml-cpp/yaml.h> #include <yaml-cpp/yaml.h>
GeoIPJSON::GeoIPJSON(const QString& attribute) GeoIPJSON::GeoIPJSON(const QString& attribute)
: GeoIP( attribute ) : GeoIP( attribute.isEmpty() ? QLatin1String( "time_zone" ) : attribute )
{ {
} }
GeoIPJSON::GeoIPJSON()
: GeoIPJSON( QLatin1Literal( "time_zone" ) )
{
}
GeoIP::RegionZonePair GeoIP::RegionZonePair
GeoIPJSON::processReply( const QByteArray& data ) GeoIPJSON::processReply( const QByteArray& data )
{ {

View File

@ -31,8 +31,12 @@
class GeoIPJSON : public GeoIP class GeoIPJSON : public GeoIP
{ {
public: public:
explicit GeoIPJSON( const QString& attribute ); /** @brief Configure the attribute name which is selected.
explicit GeoIPJSON(); *
* 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& ); virtual RegionZonePair processReply( const QByteArray& );
} ; } ;

View File

@ -24,16 +24,10 @@
#include <QtXml/QDomDocument> #include <QtXml/QDomDocument>
GeoIPXML::GeoIPXML( const QString& element ) GeoIPXML::GeoIPXML( const QString& element )
: GeoIP( element ) : GeoIP( element.isEmpty() ? QLatin1String( "TimeZone" ) : element )
{ {
} }
GeoIPXML::GeoIPXML()
: GeoIPXML( QLatin1Literal( "TimeZone" ) )
{
}
GeoIP::RegionZonePair GeoIP::RegionZonePair
GeoIPXML::processReply( const QByteArray& data ) GeoIPXML::processReply( const QByteArray& data )
{ {

View File

@ -31,10 +31,12 @@
class GeoIPXML : public GeoIP class GeoIPXML : public GeoIP
{ {
public: public:
/** @brief Configure the element name which is selected. */ /** @brief Configure the element tag which is selected.
explicit GeoIPXML( const QString& element ); *
/** @brief Use default TimeZone element. */ * If an empty string is passed in (not a valid element tag),
explicit GeoIPXML(); * then "TimeZone" is used.
*/
explicit GeoIPXML( const QString& element = QString() );
virtual RegionZonePair processReply( const QByteArray& ); virtual RegionZonePair processReply( const QByteArray& );
} ; } ;