irccd  3.0.3
server_util.hpp
1 /*
2  * server_util.hpp -- server utilities
3  *
4  * Copyright (c) 2013-2019 David Demelier <markand@malikania.fr>
5  *
6  * Permission to use, copy, modify, and/or distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #ifndef IRCCD_DAEMON_SERVER_UTIL_HPP
20 #define IRCCD_DAEMON_SERVER_UTIL_HPP
21 
27 #include <irccd/sysconfig.hpp>
28 
29 #include <memory>
30 #include <string_view>
31 
32 #include <boost/asio/io_service.hpp>
33 
34 #include <json.hpp>
35 
36 namespace irccd {
37 
38 namespace ini {
39 
40 class section;
41 
42 } // !ini
43 
44 class config;
45 
46 namespace daemon {
47 
48 class server;
49 
53 namespace server_util {
54 
64 struct message_type {
68  enum kind {
71  };
72 
77 
81  std::string message;
82 
94  static auto parse(std::string_view message,
95  std::string_view cchar,
96  std::string_view plugin) -> message_type;
97 };
98 
107 auto from_json(boost::asio::io_service& service,
108  const nlohmann::json& object) -> std::shared_ptr<server>;
109 
118 auto from_config(boost::asio::io_service& service,
119  const ini::section& sc) -> std::shared_ptr<server>;
120 
121 } // !server_util
122 
123 } // !daemon
124 
125 } // !irccd
126 
127 #endif // !IRCCD_DAEMON_SERVER_UTIL_HPP
irccd::daemon::server_util::message_type::kind
kind
Describe which type of message has been received.
Definition: server_util.hpp:68
irccd::daemon::server_util::message_type
Pack a message and its type.
Definition: server_util.hpp:64
irccd::daemon::server_util::message_type::is_command
@ is_command
special command
Definition: server_util.hpp:69
irccd::daemon::server_util::message_type::type
kind type
Definition: server_util.hpp:76
irccd::daemon::server_util::message_type::parse
static auto parse(std::string_view message, std::string_view cchar, std::string_view plugin) -> message_type
irccd::daemon::plugin
Abstract plugin.
Definition: plugin.hpp:61
irccd::ini::section
Section that contains one or more options.
Definition: ini.hpp:295
irccd::daemon::server_util::from_json
auto from_json(boost::asio::io_service &service, const nlohmann::json &object) -> std::shared_ptr< server >
irccd::daemon::server_util::from_config
auto from_config(boost::asio::io_service &service, const ini::section &sc) -> std::shared_ptr< server >
irccd::daemon::server_util::message_type::message
std::string message
Definition: server_util.hpp:81
irccd
Parent namespace.
Definition: acceptor.hpp:43
irccd::daemon::server_util::message_type::is_message
@ is_message
standard message
Definition: server_util.hpp:70