Messagelib

grantleeextension.h
1 /*
2  SPDX-FileCopyrightText: 2017 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include <grantlee/node.h>
10 #include <grantlee/taglibraryinterface.h>
11 
12 #include <QObject>
13 
14 #include <functional>
15 
16 namespace MessageViewer
17 {
18 using GrantleeCallback = std::function<void(Grantlee::OutputStream *)>;
19 
20 class CallbackTag : public Grantlee::Node
21 {
22  Q_OBJECT
23 public:
24  explicit CallbackTag(const QString &name, QObject *parent = nullptr);
25  void render(Grantlee::OutputStream *stream, Grantlee::Context *context) const override;
26 
27 private:
28  const QString m_name;
29 };
30 
31 class CallbackTagFactory : public Grantlee::AbstractNodeFactory
32 {
33  Q_OBJECT
34 public:
35  Grantlee::Node *getNode(const QString &tagContent, Grantlee::Parser *parser) const override;
36 };
37 
38 class GrantleeTagLibrary : public QObject, public Grantlee::TagLibraryInterface
39 {
40  Q_OBJECT
41  Q_INTERFACES(Grantlee::TagLibraryInterface)
42  Q_PLUGIN_METADATA(IID "org.grantlee.TagLibraryInterface")
43 public:
44  explicit GrantleeTagLibrary(QObject *parent = nullptr);
45  Q_REQUIRED_RESULT QHash<QString, Grantlee::AbstractNodeFactory *> nodeFactories(const QString &name) override;
46 };
47 }
48 
49 Q_DECLARE_METATYPE(MessageViewer::GrantleeCallback)
50 
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Nov 26 2021 23:16:42 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.