Mercurial > irccd
view lib/irccd/irccdctl.h @ 81:969f30acfb0e
Misc: new header guards, #438
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 31 Mar 2016 12:39:08 +0200 |
parents | f8160d515a76 |
children | 39fe49d294c8 |
line wrap: on
line source
/* * irccdctl.h -- main irccdctl class * * Copyright (c) 2013-2016 David Demelier <markand@malikania.fr> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef IRCCD_IRCCDCTL_H #define IRCCD_IRCCDCTL_H #include <cassert> #include <map> #include <memory> #include <string> #include "alias.h" #include "application.h" #include "connection.h" #include "options.h" namespace irccd { class Command; namespace ini { class Section; } // !ini class Irccdctl : public Application { private: /* Irccd's information */ unsigned short m_major{0}; unsigned short m_minor{0}; unsigned short m_patch{0}; /* Irccd's compilation option */ bool m_javascript{true}; bool m_ssl{true}; std::unique_ptr<Connection> m_connection; std::unordered_map<std::string, Alias> m_aliases; void usage() const; void readConnectIp(const ini::Section &sc); void readConnectUnix(const ini::Section &sc); void readConnect(const ini::Section &sc); void readGeneral(const ini::Section &sc); void readAliases(const ini::Section &sc); void read(const std::string &path, const parser::Result &options); void parseConnectIp(const parser::Result &options, bool ipv6); void parseConnectUnix(const parser::Result &options); void parseConnect(const parser::Result &options); parser::Result parse(int &argc, char **&argv) const; void connect(); public: /** * Execute the given command and wait for its result. * * @param cmd the command * @param args the arguments */ void exec(const RemoteCommand &cmd, std::vector<std::string> args); /** * Execute the given alias. * * @param alias the alias * @param args the arguments */ void exec(const Alias &alias, std::vector<std::string> args); /** * Resolve the command line arguments. * * @param args the main arguments */ void exec(std::vector<std::string> args); /** * Get the connection. * * @return the connection */ inline Connection &connection() noexcept { return *m_connection; } void run(int argc, char **argv); }; } // !irccd #endif // !IRCCD_IRCCDCTL_H