-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverinfo.cc
More file actions
89 lines (62 loc) · 1.76 KB
/
serverinfo.cc
File metadata and controls
89 lines (62 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/// \file
/// \brief Implementation of ServerInfo utility class
///
/// \author png!das-system
#include "ServerInfo"
using namespace QIRC;
/// \brief Construct new ServerInfo
ServerInfo::ServerInfo(QString host, quint16 port) :
m_host(host), m_port(port) {}
/// \brief Copy Constructor
ServerInfo::ServerInfo(const ServerInfo& o) :
m_host(o.m_host), m_port(o.m_port) {}
/// \brief Access host part
QString ServerInfo::host() const {
return m_host;
}
/// \brief Set host part to new value
void ServerInfo::setHost(QString h) {
if (m_host != h)
m_host = h;
}
/// \brief Access port number
quint16 ServerInfo::port() const {
return m_port;
}
/// \brief Set port number to new value
void ServerInfo::setPort(quint16 p) {
if (m_port != p)
m_port = p;
}
/// \brief String representation for logging/debugging
QString ServerInfo::toString() const {
QString r = "ServerInfo:{host=" + m_host + "; " +
"port=" + QString::number(m_port) + "}";
return r;
}
/// \brief Equality operator
bool ServerInfo::operator ==(const ServerInfo& o) const {
return ((m_host == o.m_host) && (m_port == o.m_port));
}
/// \brief Inequality operator
bool ServerInfo::operator !=(const ServerInfo& o) const {
return !((*this) == o);
}
/// \brief Assignment operator
///
/// Copies the host/port info from another ServerInfo instance.
ServerInfo& ServerInfo::operator =(const ServerInfo& o) {
if (this != &o) {
m_host = o.m_host;
m_port = o.m_port;
}
return (*this);
}
/// \brief Output a ServerInfo to a QDebug stream
///
/// Creates a string in the form of 'host:port' and sends it to
/// the given debug stream.
QDebug& operator <<(QDebug& dbg, const ServerInfo& si) {
QString tmp = si.host() + ":" + QString::number(si.port());
return (dbg << tmp);
}