cpp-mirai-client  v2.6.1
cpp client for mirai-api-http
XmlMessage.hpp
浏览该文件的文档.
1// Copyright (C) 2022 Numendacil and contributors
2//
3// This program is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Affero General Public License as
5// published by the Free Software Foundation, either version 3 of the
6// License, or (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU Affero General Public License for more details.
12//
13// You should have received a copy of the GNU Affero General Public License
14// along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16#ifndef MIRAI_XML_MESSAGE_HPP_
17#define MIRAI_XML_MESSAGE_HPP_
18
19
20#include <string>
21#include <utility>
22
23#include "IMessage.hpp"
24
25namespace Mirai
26{
27
28/**
29 * @brief XML消息
30 *
31 * Member Variable | Default Value
32 * --------------- | -------------
33 * `XmlMessage::content_` | `""`
34 */
35class XmlMessage final : public IMessageImpl<XmlMessage>
36{
38
39protected:
40 std::string content_;
41
43 static constexpr bool SUPPORT_SEND_ = true;
44
45 bool isValid_() const final { return !this->content_.empty(); }
46
47public:
48 XmlMessage() = default;
49 XmlMessage(std::string content) : content_(std::move(content)) {}
50
51 bool operator==(const XmlMessage& rhs) { return this->content_ == rhs.content_; }
52
53 bool operator!=(const XmlMessage& rhs) { return !(*this == rhs); }
54
55 /// 获取消息内容
56 std::string GetContent() const { return this->content_; }
57
58 /// 设置消息内容
59 XmlMessage& SetContent(std::string content)
60 {
61 this->content_ = std::move(content);
62 return *this;
63 }
64
65 struct Serializable;
66};
67
68template<> struct GetType<XmlMessage::GetType()>
69{
71};
72
73} // namespace Mirai
74
75
76#endif
CRTP helper layer
Definition: IMessage.hpp:78
XmlMessage(std::string content)
Definition: XmlMessage.hpp:49
static constexpr bool SUPPORT_SEND_
Definition: XmlMessage.hpp:43
std::string content_
Definition: XmlMessage.hpp:40
std::string GetContent() const
获取消息内容
Definition: XmlMessage.hpp:56
bool operator!=(const XmlMessage &rhs)
Definition: XmlMessage.hpp:53
static constexpr MessageTypes TYPE_
Definition: XmlMessage.hpp:42
XmlMessage & SetContent(std::string content)
设置消息内容
Definition: XmlMessage.hpp:59
bool isValid_() const final
Definition: XmlMessage.hpp:45
bool operator==(const XmlMessage &rhs)
Definition: XmlMessage.hpp:51
XmlMessage()=default
所有mirai相关的对象的命名空间
STL namespace
用于类型之间转换的辅助模板