Grantlee: templates/lib/template.h Source File

Grantlee 5.3.0

template.h
1/*
2 This file is part of the Grantlee template system.
3
4 Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either version
9 2.1 of the Licence, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library. If not, see <http://www.gnu.org/licenses/>.
18
19*/
20
21#ifndef GRANTLEE_TEMPLATE_H
22#define GRANTLEE_TEMPLATE_H
23
24#include "exception.h"
25#include "grantlee_templates_export.h"
26#include "node.h"
27
28#include <QtCore/QSharedPointer>
29#include <QtCore/QStringList>
30
31namespace Grantlee
32{
33class Context;
34class Engine;
35class TemplateImpl;
36class OutputStream;
37
38#ifdef Q_QDOC
39#define TemplateImpl Template
40#else
41typedef QSharedPointer<TemplateImpl> Template;
42#endif
43
44class TemplatePrivate;
45
47
95 class GRANTLEE_TEMPLATES_EXPORT TemplateImpl : public QObject
96{
97 Q_OBJECT
98public:
99 ~TemplateImpl() override;
100
104 QString render(Context *c) const;
105
109 OutputStream *render(OutputStream *stream, Context *c) const;
110
111#ifndef Q_QDOC
115 NodeList nodeList() const;
116
120 void setNodeList(const NodeList &list);
121#endif
122
126 Error error() const;
127
131 QString errorString() const;
132
136 Engine const *engine() const;
137
138#ifndef Q_QDOC
139protected:
140 TemplateImpl(Engine const *engine, QObject *parent = {});
141 TemplateImpl(Engine const *engine, bool smartTrim, QObject *parent = {});
142
143 void setContent(const QString &templateString);
144#endif
145
146private:
147 // Don't allow setting the parent on a Template, which is memory managed as
148 // a QSharedPointer.
149 using QObject::setParent;
150
151private:
152 Q_DECLARE_PRIVATE(Template)
153 TemplatePrivate *const d_ptr;
154#ifndef Q_QDOC
155 friend class Engine;
156 friend class Parser;
157#endif
158};
159}
160
161#endif
Grantlee::Context
The Context class holds the context to render a Template with.
Definition context.h:118
Grantlee::Engine
Grantlee::Engine is the main entry point for creating Grantlee Templates.
Definition engine.h:121
Grantlee::NodeList
A list of Nodes with some convenience API for rendering them.
Definition node.h:153
Grantlee::OutputStream
The OutputStream class is used to render templates to a QTextStream.
Definition outputstream.h:81
Grantlee::Template::render
QString render(Context *c) const
Grantlee::Template::engine
Engine const * engine() const
Grantlee::Template::error
Error error() const
Grantlee::Template::errorString
QString errorString() const
Grantlee::Template::render
OutputStream * render(OutputStream *stream, Context *c) const
Grantlee
The Grantlee namespace holds all public Grantlee API.
Definition Mainpage.dox:8
Grantlee::Error
Error
Definition exception.h:36