hostport.h
1 //------------------------------------------------------------------------------
2 // hostport.h
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2017 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef id769c5e06_8b14_4e1e_b71c_3a1632b446c3
24 #define id769c5e06_8b14_4e1e_b71c_3a1632b446c3
25 
26 #include <QHostAddress>
27 
28 class HostPort
29 {
30 public:
31  QHostAddress host;
32  unsigned short port;
33 
34  HostPort()
35  {
36  this->port = 0;
37  }
38 
39  HostPort(const QHostAddress &host, unsigned short port)
40  {
41  this->host = host;
42  this->port = port;
43  }
44 
45  bool operator<(const HostPort &other) const
46  {
47  return host != other.host ? host.toString() < other.host.toString() : port < other.port;
48  }
49 
50  bool operator==(const HostPort &other) const
51  {
52  return host == other.host && port == other.port;
53  }
54 };
55 
56 uint qHash(const HostPort &hostPort);
57 
58 #endif