LeechCraft Azoth  0.6.70-14771-g9d21b0f8ad
Modular multiprotocol IM plugin for LeechCraft
iprovidecommands.h
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
9 #pragma once
10 
11 #include <variant>
12 #include <functional>
13 #include <stdexcept>
14 #include <QStringList>
15 #include <QtPlugin>
16 
17 namespace LC
18 {
19 namespace Azoth
20 {
21  class ICLEntry;
22 
24  {
26  QString Message_;
27  };
29  {
30  QString NewText_;
31  };
32  typedef std::variant<bool, StringCommandResult, TextMorphResult> CommandResult_t;
33 
34  typedef std::function<CommandResult_t (ICLEntry*, QString&)> Command_f;
35 
36  class CommandException : public std::runtime_error
37  {
38  const QString Error_;
39  const bool TryOtherCommands_;
40  public:
41  CommandException (const QString& error, bool canTryOthers = false)
42  : std::runtime_error { error.toUtf8 ().constData () }
43  , Error_ { error }
44  , TryOtherCommands_ { canTryOthers }
45  {
46  }
47 
48  const QString& GetError () const
49  {
50  return Error_;
51  }
52 
53  bool CanTryOtherCommands () const
54  {
55  return TryOtherCommands_;
56  }
57  };
58 
60  {
61  QStringList Names_;
63 
64  QString Description_;
65  QString Help_;
66 
67  StaticCommand () = default;
68  StaticCommand (const StaticCommand&) = default;
69 
70  StaticCommand (const QStringList& names, const Command_f& command)
71  : Names_ { names }
72  , Command_ { command }
73  {
74  }
75 
76  StaticCommand (const QStringList& names, const Command_f& command,
77  const QString& descr, const QString& help)
78  : Names_ { names }
79  , Command_ { command }
80  , Description_ { descr }
81  , Help_ { help }
82  {
83  }
84  };
85 
87 
89  {
90  public:
91  virtual ~IProvideCommands () {}
92 
94  };
95 }
96 }
97 
98 Q_DECLARE_INTERFACE (LC::Azoth::IProvideCommands, "org.LeechCraft.Azoth.IProvideCommands/1.0")
const QString & GetError() const
CommandException(const QString &error, bool canTryOthers=false)
Represents a single entry in contact list.
Definition: iclentry.h:121
virtual StaticCommands_t GetStaticCommands(ICLEntry *)=0
std::variant< bool, StringCommandResult, TextMorphResult > CommandResult_t
std::function< CommandResult_t(ICLEntry *, QString &)> Command_f
QList< StaticCommand > StaticCommands_t
StaticCommand(const QStringList &names, const Command_f &command)
StaticCommand(const QStringList &names, const Command_f &command, const QString &descr, const QString &help)
StaticCommand(const StaticCommand &)=default