libcolutius
Message.h
浏览该文件的文档.
1
11#pragma once
12#include <QDebug>
13#include <QObject>
14#include <QRegularExpression>
15#include <QTime>
16#include <QtGui/QValidator>
21class Message : public QObject
22{
23 Q_OBJECT
24 public:
28 enum Type
29 {
40 };
44 enum Who
45 {
50 };
51 explicit Message(QObject *parent = nullptr);
52 ~Message() override;
53 Type msgType();
54 Message *msgType(Type type);
55 QString typeStr();
56 Message *typeStr(QString type);
57 QString server();
58 Message *server(QString server);
59 Who from();
61 QString fromName();
62 Message *fromName(QString fromName);
63 Who to();
64 Message *to(Who to);
65 QString toName();
66 Message *toName(QString toName);
67 QString rawMsg();
68 Message *rawMsg(QString rawMsg);
69 QString mainMsg();
70 Message *mainMsg(QString mainMsg);
71 QString myNick();
72 Message *myNick(QString myNick);
73 int time();
74 Message *parse(); //解析消息原始数据
75
76 private:
77 void parseType(QString msg);
78 void parseFrom(QString msg);
79 void parseTo(QString msg);
80 void parseSpecial(QString msg);
81
82 /*Type*/
83 QString _typeStr; //消息类型字符串
84 Type _msgType; //消息类型
85 /*Who*/
86 QString _server; //消息所在服务器
87 Who _from; //消息从哪来
88 QString _fromName;
89 Who _to; //消息到哪去
90 QString _toName;
91 /*Main*/
92 QString _rawMsg; //原始数据
93 QString _mainMsg; //消息主体信息
94 /*Additional*/
95 int _time; //消息发送时间 时间戳形式
96 QString _myNick; //我的昵称
97};
IRC消息类 将原始数据传入其中,由该类对接收到的消息进行解析、分类、格式化
Definition: Message.h:22
QString rawMsg()
Definition: Message.cpp:92
Type
消息类型
Definition: Message.h:29
@ Common
常规消息
Definition: Message.h:39
@ Quit
退出频道消息
Definition: Message.h:35
@ Join
加入信息
Definition: Message.h:34
@ None
未知消息
Definition: Message.h:30
@ Num
数字类信息,相当于状态码
Definition: Message.h:38
@ Ping
服务器定期Ping消息
Definition: Message.h:31
@ Notice
注意信息
Definition: Message.h:33
@ Nick
昵称相关信息
Definition: Message.h:36
@ Kick
踢人信息
Definition: Message.h:37
@ Error
报错信息
Definition: Message.h:32
QString myNick()
Definition: Message.cpp:110
Who to()
Definition: Message.cpp:74
Who from()
Definition: Message.cpp:56
QString server()
Definition: Message.cpp:47
QString toName()
Definition: Message.cpp:83
Type msgType()
Definition: Message.cpp:29
Who
消息发送者
Definition: Message.h:45
@ Me
用户自己发送的消息
Definition: Message.h:49
@ Channel
频道消息
Definition: Message.h:47
@ User
其他用户发送的消息
Definition: Message.h:48
@ Server
服务器发送的消息
Definition: Message.h:46
Message * parse()
Definition: Message.cpp:123
QString mainMsg()
Definition: Message.cpp:101
QString fromName()
Definition: Message.cpp:65
Message(QObject *parent=nullptr)
有参构造函数
Definition: Message.cpp:21
int time()
Definition: Message.cpp:119
QString typeStr()
Definition: Message.cpp:38
~Message() override
默认析构函数