~vcs-imports-ii/znc/master

« back to all changes in this revision

Viewing changes to Nick.cpp

  • Committer: prozacx
  • Date: 2004-08-24 00:08:51 UTC
  • Revision ID: git-v1:538d3ece4e737807e7d5a11849aab177b87c1571
Initial revision


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2 726aef4b-f618-498e-8847-2d620e286838

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "Nick.h"
 
2
 
 
3
CNick::CNick() {
 
4
        m_bIsOp = false;
 
5
        m_bIsVoice = false;
 
6
}
 
7
 
 
8
CNick::CNick(const string& sNick) {
 
9
        Parse(sNick);
 
10
        m_bIsOp = false;
 
11
        m_bIsVoice = false;
 
12
}
 
13
 
 
14
CNick::~CNick() {}
 
15
 
 
16
void CNick::Parse(const string& sNickMask) {
 
17
        if (sNickMask.empty()) {
 
18
                return;
 
19
        }
 
20
 
 
21
        unsigned int uPos = sNickMask.find('!');
 
22
 
 
23
        if (uPos == string::npos) {
 
24
                m_sNick = sNickMask.substr((sNickMask[0] == ':'));
 
25
                return;
 
26
        }
 
27
 
 
28
        m_sNick = sNickMask.substr((sNickMask[0] == ':'), uPos);
 
29
        m_sHost = sNickMask.substr(uPos +1);
 
30
 
 
31
        if ((uPos = m_sHost.find('@')) != string::npos) {
 
32
                m_sIdent = m_sHost.substr(0, uPos);
 
33
                m_sHost = m_sHost.substr(uPos +1);
 
34
        }
 
35
}
 
36
 
 
37
void CNick::SetNick(const string& s) { m_sNick = s; }
 
38
void CNick::SetIdent(const string& s) { m_sIdent = s; }
 
39
void CNick::SetHost(const string& s) { m_sHost = s; }
 
40
void CNick::SetOp(bool b) { m_bIsOp = b; }
 
41
void CNick::SetVoice(bool b) { m_bIsVoice = b; }
 
42
 
 
43
bool CNick::IsOp() const { return m_bIsOp; }
 
44
bool CNick::IsVoice() const { return m_bIsVoice; }
 
45
const string& CNick::GetNick() const { return m_sNick; }
 
46
const string& CNick::GetIdent() const { return m_sIdent; }
 
47
const string& CNick::GetHost() const { return m_sHost; }
 
48
string CNick::GetNickMask() const { return m_sNick + "!" + m_sIdent + "@" + m_sHost; }
 
49
 
 
50
string CNick::GetHostMask() const {
 
51
        string sRet = m_sNick;
 
52
 
 
53
        if (!m_sIdent.empty()) {
 
54
                sRet += "!" + m_sIdent;
 
55
        }
 
56
 
 
57
        if (!m_sHost.empty()) {
 
58
                sRet += "@" + m_sHost;
 
59
        }
 
60
 
 
61
        return (sRet);
 
62
}