-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddress.h
54 lines (45 loc) · 1 KB
/
address.h
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
#ifndef ADDRESS_H
#define ADDRESS_H
class Address {
public:
Address()
{
address = 0;
port = 0;
}
Address( unsigned int address, unsigned short port )
{
this->address = address;
this->port = port;
}
unsigned int GetAddress() const
{
return address;
}
unsigned short GetPort() const
{
return port;
}
bool operator == ( const Address & other ) const
{
return address == other.address && port == other.port;
}
bool operator != ( const Address & other ) const
{
return ! ( *this == other );
}
bool operator < ( const Address & other ) const
{
// note: this is so we can use address as a key in std::map
if ( address < other.address )
return true;
if ( address > other.address )
return false;
else
return port < other.port;
}
private:
unsigned int address;
unsigned short port;
};
#endif // ADDRESS_H