cpp-mirai-client  v2.6.1
cpp client for mirai-api-http
MessageTypes.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_MESSAGE_TYPES_HPP_
17#define MIRAI_MESSAGE_TYPES_HPP_
18
19#include <array>
20#include <string>
21
22namespace Mirai
23{
24
25enum class MessageTypes
26{
27 APP = 0,
28 AT_ALL,
29 AT,
30 AUDIO,
31 DICE,
32 FACE,
33 FILE,
35 FORWARD,
36 IMAGE,
37 JSON,
41 PLAIN,
42 POKE,
43 QUOTE,
44 SOURCE,
45 XML,
46
47 // Used for counting
49};
50
51std::string to_string(MessageTypes type);
52
53constexpr std::array<MessageTypes, static_cast<size_t>(MessageTypes::ENUM_END)> MessageTypesList = []()
54{
55 std::array<MessageTypes, static_cast<size_t>(MessageTypes::ENUM_END)> arr{};
56 for (size_t i = 0; i < arr.size(); i++)
57 arr.at(i) = static_cast<MessageTypes>(i);
58 return arr;
59}();
60
61/**
62 * @brief 用于类型之间转换的辅助模板
63 *
64 */
65template<MessageTypes> struct GetType;
66
67template<MessageTypes type> using GetType_t = typename GetType<type>::type;
68
69} // namespace Mirai
70
71#endif
所有mirai相关的对象的命名空间
std::string to_string(EventTypes type)
typename GetType< type >::type GetType_t
constexpr std::array< MessageTypes, static_cast< size_t >(MessageTypes::ENUM_END)> MessageTypesList
用于类型之间转换的辅助模板