-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathircmessage.h
More file actions
73 lines (59 loc) · 2.1 KB
/
ircmessage.h
File metadata and controls
73 lines (59 loc) · 2.1 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
/*
Copyright Notice:
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
//#include <string>
//#include <iostream>
//#include <windows.h>
using std::string;
#undef GetMessage
namespace IrcMessage
{
enum MSG_TYPE { MSG_SERVER,
MSG_PRIVMSG ,
MSG_QUERY ,
MSG_NOTICE,
MSG_PING };
const string WHITESPACE = " \t\n\r\f\v";
typedef struct _IrcMsgStruct
{
string sender;
string hostmask;
MSG_TYPE typeMsg;
string target;
string message;
unsigned short srvrTypeMsg;
} IrcMsgs;
string TrimWhitespace(string& in);
string ParseWord(const string& str, int slot);
string ToUpper(string& str);
class IrcMsg
{
//the purpose of this class is to parse a string recieved from IRC
//usage: IrcMsg(raw irc msg)
//then you can get common info about that line
//user name, @server, typeMsg, target, :msg
public:
IrcMsg(const string& in):m_rawMsg(in){ memset(&m_Msg, 0, sizeof(IrcMsgs)); if (m_rawMsg != "") IrcMsg::Parse(m_rawMsg); }
IrcMsg(){}
~IrcMsg();
void Parse(string& msg);
//accessors
void SetRawMsg(const string& msg) { m_rawMsg = msg; IrcMsg::Parse(m_rawMsg); }
string GetRawMsg() const { return m_rawMsg; }
IrcMsgs GetMsg() { return m_Msg; }
string GetSender() const { return m_Msg.sender; }
string GetHostmask() const { return m_Msg.hostmask; }
MSG_TYPE GetTypeMsg() const { return m_Msg.typeMsg; }
string GetTarget() const { return m_Msg.target; }
string GetMessage() const { return m_Msg.message; }
short GetSrvrTypeMsg() const { return m_Msg.srvrTypeMsg; }
protected:
string m_rawMsg;
IrcMsgs m_Msg;
};
}