Vidalia
0.3.1
src
vidalia
network
GeoIpRecord.h
Go to the documentation of this file.
1
/*
2
** This file is part of Vidalia, and is subject to the license terms in the
3
** LICENSE file, found in the top level directory of this distribution. If you
4
** did not receive the LICENSE file with this file, you may obtain it from the
5
** Vidalia source package distributed by the Vidalia Project at
6
** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7
** including this file, may be copied, modified, propagated, or distributed
8
** except according to the terms described in the LICENSE file.
9
*/
10
11
/*
12
** \file GeoIpRecord.h
13
** \brief Associates an IP with a geographic location
14
*/
15
16
#ifndef _GEOIPRECORD_H
17
#define _GEOIPRECORD_H
18
19
#include <QHash>
20
#include <QString>
21
#include <QHostAddress>
22
23
24
class
GeoIpRecord
25
{
26
public
:
27
/** Default constructor. Creates an empty GeoIpRecord object.
28
*/
29
GeoIpRecord
();
30
31
/**
32
*/
33
GeoIpRecord
(
const
QHostAddress &
ip
,
float
latitude
,
float
longitude
,
34
const
QString &
country
,
const
QString &
countryCode
);
35
36
/**
37
*/
38
GeoIpRecord
(
const
QHostAddress &
ip
,
float
latitude
,
float
longitude
,
39
const
QString &
city
,
const
QString &
region
,
40
const
QString &
country
,
const
QString &
countryCode
);
41
42
/** Returns the IP address associated with this GeoIP object.
43
*/
44
QHostAddress
ip
()
const
{
return
_ip
; }
45
46
/** Returns the latitude portion of the geographic coordinates associated
47
* with this IP address or range of IP addresses.
48
*/
49
float
latitude
()
const
{
return
_latitude
; }
50
51
/** Returns the longitude portion of the geographic coordinates associated
52
* with this IP address or range of IP addresses.
53
*/
54
float
longitude
()
const
{
return
_longitude
; }
55
56
/** Returns the name of the city associated with this IP address, if known.
57
* Otherwise, returns an empty QString.
58
*/
59
QString
city
()
const
{
return
_city
; }
60
61
/** Returns the full region name (e.g., state) in which this IP address
62
* resides, if known. Otherwise, returns an empty QString.
63
*/
64
QString
region
()
const
{
return
_region
; }
65
66
/** Returns the full name of the country associated with this IP address
67
* or range of IP addresses, if known. Otherwise, returns an empty QString.
68
*/
69
QString
country
()
const
{
return
_country
; }
70
71
/** Returns the ISO 3166-1 alpha-2 two-letter country code of the country
72
* associated with this IP address or range of IP addresses, if known.
73
* Otherwise, returns an empty QString.
74
*/
75
QString
countryCode
()
const
{
return
_countryCode
; }
76
77
/** Returns a human-readable string of city, region(state), and country.
78
* Some fields may be absent if they are not known. If no fields are known,
79
* this will return an empty QString.
80
*/
81
QString
toString
()
const
;
82
83
/** Returns true if the GeoIpRecord object is valid. A valid GeoIpRecord object must
84
* have valid IP address, valid latitude and longitude coordinates and a
85
* two-letter country code.
86
*/
87
bool
isValid
()
const
;
88
89
private
:
90
QHostAddress
_ip
;
/**< IP address for this location. */
91
float
_latitude
;
/**< Latitudinal coordinate for this IP's location. */
92
float
_longitude
;
/**< Longitudinal coordinate for this IP's location. */
93
QString
_city
;
/**< City in which this IP lives. */
94
QString
_region
;
/**< State or district in which this IP lives. */
95
QString
_country
;
/**< Country in which this IP lives. */
96
QString
_countryCode
;
/**< ISO-3166-1 alpha-2 country code. */
97
};
98
99
#endif
100
GeoIpRecord::_latitude
float _latitude
Definition:
GeoIpRecord.h:91
GeoIpRecord
Definition:
GeoIpRecord.h:24
GeoIpRecord::latitude
float latitude() const
Definition:
GeoIpRecord.h:49
GeoIpRecord::_ip
QHostAddress _ip
Definition:
GeoIpRecord.h:90
GeoIpRecord::longitude
float longitude() const
Definition:
GeoIpRecord.h:54
GeoIpRecord::ip
QHostAddress ip() const
Definition:
GeoIpRecord.h:44
GeoIpRecord::GeoIpRecord
GeoIpRecord()
Definition:
GeoIpRecord.cpp:26
GeoIpRecord::_region
QString _region
Definition:
GeoIpRecord.h:94
GeoIpRecord::toString
QString toString() const
Definition:
GeoIpRecord.cpp:64
GeoIpRecord::countryCode
QString countryCode() const
Definition:
GeoIpRecord.h:75
GeoIpRecord::_longitude
float _longitude
Definition:
GeoIpRecord.h:92
GeoIpRecord::_countryCode
QString _countryCode
Definition:
GeoIpRecord.h:96
GeoIpRecord::country
QString country() const
Definition:
GeoIpRecord.h:69
GeoIpRecord::city
QString city() const
Definition:
GeoIpRecord.h:59
GeoIpRecord::_country
QString _country
Definition:
GeoIpRecord.h:95
GeoIpRecord::isValid
bool isValid() const
Definition:
GeoIpRecord.cpp:56
GeoIpRecord::region
QString region() const
Definition:
GeoIpRecord.h:64
GeoIpRecord::_city
QString _city
Definition:
GeoIpRecord.h:93
Generated by
1.8.17