#include <geoipcacheitem.h>
Public Member Functions | |
GeoIpCacheItem () | |
GeoIpCacheItem (GeoIp geoip, QDateTime timestamp) | |
QHostAddress | ip () const |
GeoIp | geoip () const |
bool | isExpired () const |
bool | isEmpty () const |
QString | toString () const |
Static Public Member Functions | |
static GeoIpCacheItem | fromString (QString cacheString) |
Private Attributes | |
GeoIp | _geoip |
QDateTime | _timestamp |
Definition at line 25 of file geoipcacheitem.h.
GeoIpCacheItem::GeoIpCacheItem | ( | ) | [inline] |
GeoIpCacheItem::GeoIpCacheItem | ( | GeoIp | geoip, | |
QDateTime | timestamp | |||
) |
Constructor.
Constructor
Definition at line 23 of file geoipcacheitem.cpp.
References _geoip, and _timestamp.
QHostAddress GeoIpCacheItem::ip | ( | ) | const [inline] |
Returns the IP of this cache item.
Definition at line 34 of file geoipcacheitem.h.
References _geoip, and GeoIp::ip().
Referenced by GeoIpCache::loadFromDisk().
GeoIp GeoIpCacheItem::geoip | ( | ) | const [inline] |
Returns the cached GeoIp object.
Definition at line 36 of file geoipcacheitem.h.
References _geoip.
Referenced by fromString().
bool GeoIpCacheItem::isExpired | ( | ) | const |
Returns true if this cache item is expired.
Returns true if the cache item is too old to be considered valid. Normal cached responses are valid for one month. Cached UNKNOWN responses are considered valid for one week.
Definition at line 77 of file geoipcacheitem.cpp.
References _geoip, _timestamp, and GeoIp::isUnknown().
Referenced by GeoIpCache::contains(), GeoIpCache::loadFromDisk(), and GeoIpCache::saveToDisk().
bool GeoIpCacheItem::isEmpty | ( | ) | const |
Returns true if this cache item is empty and invalid.
Returns true if this cache item is empty and invalid. A valid cache item must have a valid GeoIp object and timestamp.
Definition at line 32 of file geoipcacheitem.cpp.
References _geoip, _timestamp, and GeoIp::isEmpty().
Referenced by GeoIpCache::loadFromDisk().
QString GeoIpCacheItem::toString | ( | ) | const |
Returns a string representing the contents of this cache item, suitable for writing to disk.
Returns a string representing the contents of this cache item, suitable for writing to disk. The format is as in the following example: <Geo ip="" data>="">:<Timestamp>
Definition at line 42 of file geoipcacheitem.cpp.
References _geoip, _timestamp, and GeoIp::toString().
Referenced by GeoIpCache::saveToDisk().
GeoIpCacheItem GeoIpCacheItem::fromString | ( | QString | cacheString | ) | [static] |
Returns a GeoIpCacheItem from a string as read from the cache that was written to disk.
Returns a GeoIpCacheItem from a string as read from the cache that was written to disk. The format is: <Geo ip="" data>="">[:<Timestamp>]
If no value for Timestamp is given, the current date and time will be used. If the string cannot be parsed for valid cached GeoIP data, then an empty GeoIpCacheItem object is returned. The calling method should call isEmpty() on the returned GeoIpCacheItem object to ensure it got a valid object.
Definition at line 57 of file geoipcacheitem.cpp.
References GeoIp::fromString(), geoip(), and GeoIpCacheItem().
Referenced by GeoIpCache::loadFromDisk().
GeoIp GeoIpCacheItem::_geoip [private] |
Cached GeoIp item.
Definition at line 50 of file geoipcacheitem.h.
Referenced by geoip(), GeoIpCacheItem(), ip(), isEmpty(), isExpired(), and toString().
QDateTime GeoIpCacheItem::_timestamp [private] |
Time this item was cached.
Definition at line 51 of file geoipcacheitem.h.
Referenced by GeoIpCacheItem(), isEmpty(), isExpired(), and toString().