-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathban.h
52 lines (40 loc) · 1.34 KB
/
ban.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
/**
* COPYRIGHT 2014 (C) Jason Volk
* COPYRIGHT 2014 (C) Svetlana Tkachenko
*
* DISTRIBUTED UNDER THE GNU GENERAL PUBLIC LICENSE (GPL) (see: LICENSE)
*/
class Ban
{
Mask mask;
Mask oper;
time_t time;
public:
using Type = Mask::Type;
auto &get_mask() const { return mask; }
auto &get_oper() const { return oper; }
auto &get_time() const { return time; }
explicit operator const Mask &() const { return get_mask(); }
bool operator<(const Ban &o) const { return get_mask() < std::string(o.get_mask()); }
bool operator==(const Ban &o) const { return get_mask() == o.get_mask(); }
Ban(const Mask &mask, const Mask &oper = "", const time_t &time = 0);
friend std::ostream &operator<<(std::ostream &s, const Ban &ban);
};
inline
Ban::Ban(const Mask &mask,
const Mask &oper,
const time_t &time):
mask(mask),
oper(oper),
time(time)
{
}
inline
std::ostream &operator<<(std::ostream &s,
const Ban &ban)
{
s << std::setw(64) << std::left << ban.get_mask();
s << "by: " << std::setw(64) << std::left << ban.get_oper();
s << "(" << ban.get_time() << ")";
return s;
}