KVIrc 5.2.6
Developer APIs
KviIrcMask.h
Go to the documentation of this file.
1#ifndef _KVI_IRCMASK_H_
2#define _KVI_IRCMASK_H_
3//=============================================================================
4//
5// File : KviIrcMask.h
6// Creation date : Fri Jan 8 1999 19:50:35 by Szymon Stefanek
7//
8// This file is part of the KVIrc IRC client distribution
9// Copyright (C) 1999-2010 Szymon Stefanek (pragma at kvirc dot net)
10//
11// This program is FREE software. You can redistribute it and/or
12// modify it under the terms of the GNU General Public License
13// as published by the Free Software Foundation; either version 2
14// of the License, or (at your option) any later version.
15//
16// This program is distributed in the HOPE that it will be USEFUL,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19// See the GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program. If not, write to the Free Software Foundation,
23// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24//
25//=============================================================================
26
27//
28// originally this file was named kvi_ircuser.h and the class was KviIrcUser
29// ported to UNICODE on 2004.10.28 1:50 am
30//
31
38#include "kvi_settings.h"
39#include "KviHeapObject.h"
40
41#include <QString>
42
48{
49 friend class KviIrcUserList;
50 friend class KviIrcUserChanList;
51
52private:
53 QString m_szNick;
54 QString m_szUser;
55 QString m_szHost;
56 static QString m_szWild;
57
58public:
63 KviIrcMask();
64
70 KviIrcMask(const QString & szMask);
71
77 KviIrcMask(const KviIrcMask & ircUser)
78 : m_szNick(ircUser.m_szNick), m_szUser(ircUser.m_szUser), m_szHost(ircUser.m_szHost){};
79
87 KviIrcMask(const QString & nick, const QString & user, const QString & host)
88 : m_szNick(nick), m_szUser(user), m_szHost(host){};
89
95 {
96 NickUserHost = 0,
97 NickUserNet = 1,
98 NickUser = 2,
99 NickHost = 3,
100 NickNet = 4,
101 Nick = 5,
102 UserHost = 6,
103 UserNet = 7,
104 User = 8,
105 Host = 9,
106 Net = 10,
107 NickCleanUserHost = 11,
108 NickCleanUserNet = 12,
109 NickCleanUser = 13,
110 CleanUserHost = 14,
111 CleanUserNet = 15,
112 CleanUser = 16,
113 NickUserLargeNet = 17,
114 NickLargeNet = 18,
115 UserLargeNet = 19,
116 NickCleanUserLargeNet = 20,
117 CleanUserLargeNet = 21,
118 NickUserSmartNet = 22,
119 NickSmartNet = 23,
120 UserSmartNet = 24,
121 NickCleanUserSmartNet = 25,
122 CleanUserSmartNet = 26
123 };
124
125public:
133 void setNick(const QString & szNick) { m_szNick = szNick.isEmpty() ? m_szWild : szNick; };
134
142 void setUsername(const QString & szUser) { m_szUser = szUser.isEmpty() ? m_szWild : szUser; };
143
152 void setUser(const QString & szUser) { m_szUser = szUser.isEmpty() ? m_szWild : szUser; };
153
161 void setHost(const QString & szHost) { m_szHost = szHost.isEmpty() ? m_szWild : szHost; };
162
169 const QString & nick() const { return m_szNick; };
170
177 const QString & user() const { return m_szUser; };
178
185 const QString & host() const { return m_szHost; };
186
191 bool hasUser() const { return !(m_szUser.isEmpty() || (m_szUser == m_szWild)); };
192
197 bool hasHost() const { return !(m_szHost.isEmpty() || (m_szHost == m_szWild)); };
198
203 bool hasNumericHost() const;
204
258 void mask(QString & szMask, MaskType eMaskType = NickCleanUserHost) const;
259
264 bool hasWildNick();
265
271 bool matches(const KviIrcMask & mask) const;
272
280 bool matchesFixed(const QString & szNick, const QString & szUser, const QString & szHost) const;
281
287 bool matchesFixed(const KviIrcMask & mask) const;
288
294 bool matchedBy(const KviIrcMask & mask) const { return mask.matchesFixed(*this); };
295
302 bool matchWildString(const QString & szExp, const QString & szStr) const;
303
308 int nonWildChars();
309
315 bool operator==(const KviIrcMask & user);
316
317private:
324 int getIpDomainMaskLen() const;
325
332 int getLargeIpDomainMaskLen() const;
333
338 QString getHostDomainMask() const;
339
344 QString getLargeHostDomainMask() const;
345
351 bool hasMaskedIp() const;
352};
353
354#endif //_KVI_IRCMASK_H_
__KVI_EXTERN bool operator==(const KviCString &left, const KviCString &right)
Definition KviCString.h:516
Heap Object.
Definition KviHeapObject.h:119
Irc user mask handling.
Definition KviIrcMask.h:48
KviIrcMask(const KviIrcMask &ircUser)
Carbon copy.
Definition KviIrcMask.h:77
QString m_szNick
Definition KviIrcMask.h:53
static QString m_szWild
Definition KviIrcMask.h:56
KviIrcMask(const QString &nick, const QString &user, const QString &host)
Carbon copy.
Definition KviIrcMask.h:87
MaskType
Defines the type of the masks.
Definition KviIrcMask.h:95
void setNick(const QString &szNick)
Sets the nick for this user.
Definition KviIrcMask.h:133
QString m_szHost
Definition KviIrcMask.h:55
void setHost(const QString &szHost)
Sets the host for this user.
Definition KviIrcMask.h:161
const QString & host() const
Returns the hostname of this user.
Definition KviIrcMask.h:185
bool matchesFixed(const QString &szNick, const QString &szUser, const QString &szHost) const
Fixed external matches (this is wild, external is fixed)
Definition KviIrcMask.cpp:356
const QString & nick() const
Returns the nickname of this user.
Definition KviIrcMask.h:169
void setUsername(const QString &szUser)
Sets the username for this user.
Definition KviIrcMask.h:142
const QString & user() const
Returns the username of this user.
Definition KviIrcMask.h:177
bool matchedBy(const KviIrcMask &mask) const
Fixed internal matches (this is fixed, external is wild)
Definition KviIrcMask.h:294
void setUser(const QString &szUser)
Sets the username for this user.
Definition KviIrcMask.h:152
bool hasHost() const
Returns true if the hostname is set in the mask.
Definition KviIrcMask.h:197
QString m_szUser
Definition KviIrcMask.h:54
bool hasUser() const
Returns true if the username is set in the mask.
Definition KviIrcMask.h:191
This file contains compile time settings.
#define KVILIB_API
Definition kvi_settings.h:124
QString szHost
Definition libkvisetup.cpp:48