KTextTemplate

taglibraryinterface.h
1/*
2 This file is part of the KTextTemplate library
3
4 SPDX-FileCopyrightText: 2009, 2010 Stephen Kelly <steveire@gmail.com>
5
6 SPDX-License-Identifier: LGPL-2.1-or-later
7
8*/
9
10#ifndef TAGLIBRARYINTERFACE_H
11#define TAGLIBRARYINTERFACE_H
12
13#include "outputstream.h"
14
15#include <QHash>
16#include <QtPlugin>
17
18namespace KTextTemplate
19{
20class AbstractNodeFactory;
21class Filter;
22
23/// @headerfile taglibraryinterface.h <KTextTemplate/TagLibraryInterface>
24
25/**
26 @brief The **%TagLibraryInterface** returns available tags and filters from
27 libraries.
28
29 This interface must be implemented in tag and filter libraries.
30
31 The implementation will usually be very simple.
32
33 @code
34 class MyTagLibrary : public QObject, public TagLibraryInterface
35 {
36 Q_OBJECT
37 Q_INTERFACES( KTextTemplate::TagLibraryInterface )
38 public:
39 MyTagLibrary( QObject *parent = {} )
40 : QObject( parent ) {
41 }
42
43 QHash<QString, AbstractNodeFactory*>
44 nodeFactories(const QString &name = {}) {
45 Q_UNUSED( name );
46 QHash<QString, AbstractNodeFactory*> nodeFactories;
47 nodeFactories.insert( "mytag1", new MyTag1() );
48 nodeFactories.insert( "mytag2", new MyTag2() );
49 return nodeFactories;
50 }
51
52 QHash<QString, Filter*> filters( const QString &name = {} ) {
53 Q_UNUSED( name );
54
55 QHash<QString, Filter*> filters;
56
57 filters.insert( "myfilter1", new MyFilter1() );
58 filters.insert( "myfilter2", new MyFilter2() );
59
60 return filters;
61 }
62 };
63 @endcode
64
65 @author Stephen Kelly <steveire@gmail.com>
66*/
68{
69public:
70 virtual ~TagLibraryInterface()
71 {
72 }
73
74 /**
75 Returns the AbstractNodeFactory implementations available in this library.
76 */
78 {
79 Q_UNUSED(name);
81 return h;
82 };
83
84 /**
85 Returns the Filter implementations available in this library.
86 */
87 virtual QHash<QString, Filter *> filters(const QString &name = {})
88 {
89 Q_UNUSED(name);
90 static const QHash<QString, Filter *> h;
91 return h;
92 };
93};
94}
95
96Q_DECLARE_INTERFACE(KTextTemplate::TagLibraryInterface, "org.kde.KTextTemplate.TagLibraryInterface/1.0")
97
98#endif
The TagLibraryInterface returns available tags and filters from libraries.
virtual QHash< QString, AbstractNodeFactory * > nodeFactories(const QString &name={})
Returns the AbstractNodeFactory implementations available in this library.
virtual QHash< QString, Filter * > filters(const QString &name={})
Returns the Filter implementations available in this library.
The KTextTemplate namespace holds all public KTextTemplate API.
Definition Mainpage.dox:8
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Apr 27 2024 22:14:09 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.