Cutelee
6.1.0
templates
lib
node.h
1
/*
2
This file is part of the Cutelee 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 CUTELEE_NODE_H
22
#define CUTELEE_NODE_H
23
24
// krazy:excludeall=dpointer
25
26
#include "context.h"
27
#include "filterexpression.h"
28
#include "cutelee_templates_export.h"
29
#include "outputstream.h"
30
#include "safestring.h"
31
32
#include <QtCore/QStringList>
33
34
namespace
Cutelee
35
{
36
37
class
Engine;
38
class
NodeList;
39
class
TemplateImpl;
40
41
class
NodePrivate;
42
44
77
class
CUTELEE_TEMPLATES_EXPORT
Node
:
public
QObject
78
{
79
Q_OBJECT
80
public
:
86
explicit
Node
(QObject *parent = {});
87
91
~Node
()
override
;
92
98
virtual
void
render
(
OutputStream
*stream,
Context
*c)
const
= 0;
99
100
#ifndef Q_QDOC
104
virtual
bool
mustBeFirst()
105
{
// krazy:exclude:inline
106
return
false
;
107
}
108
#endif
109
110
protected
:
117
void
streamValueInContext(
OutputStream
*stream,
const
QVariant
&input,
118
Cutelee::Context
*c)
const
;
119
123
TemplateImpl *containerTemplate()
const
;
124
125
private
:
126
Q_DECLARE_PRIVATE(
Node
)
127
NodePrivate
*
const
d_ptr;
128
};
129
131
147
class
CUTELEE_TEMPLATES_EXPORT
NodeList
:
public
QList<Cutelee::Node *>
148
{
149
public
:
153
NodeList
();
154
158
NodeList
(
const
NodeList
&list);
159
160
NodeList
&operator=(
const
NodeList
&list);
161
165
/* implicit */
NodeList
(
const
QList<Cutelee::Node *> &list);
166
170
~NodeList
();
171
175
void
append(
Cutelee::Node
*node);
176
180
void
append(
const
QList<Cutelee::Node *> &nodeList);
181
185
bool
containsNonText()
const
;
186
190
template
<
typename
T> QList<T>
findChildren
()
191
{
192
QList<T> children;
193
QList<Cutelee::Node *>::const_iterator it;
194
const
QList<Cutelee::Node *>::const_iterator first = constBegin();
195
const
QList<Cutelee::Node *>::const_iterator last = constEnd();
196
for
(it = first; it != last; ++it) {
197
T
object
= qobject_cast<T>(*it);
198
if
(
object
) {
199
children << object;
200
}
201
children << (*it)->findChildren<T>();
202
}
203
return
children;
204
}
205
209
void
render(
OutputStream
*stream,
Context
*c)
const
;
210
211
private
:
212
bool
m_containsNonText;
213
};
214
215
class
AbstractNodeFactoryPrivate;
216
218
299
class
CUTELEE_TEMPLATES_EXPORT
AbstractNodeFactory
:
public
QObject
300
{
301
Q_OBJECT
302
public
:
308
explicit
AbstractNodeFactory
(QObject *parent = {});
309
313
~AbstractNodeFactory
()
override
;
314
329
virtual
Node
*
getNode
(
const
QString
&tagContent,
Parser
*p)
const
= 0;
330
331
#ifndef Q_QDOC
338
virtual
void
setEngine(
Engine
*) {}
339
#endif
340
341
protected
:
357
Q_INVOKABLE QStringList smartSplit(
const
QString
&str)
const
;
358
359
protected
:
366
QList<FilterExpression> getFilterExpressionList(
const
QStringList &list,
367
Parser
*p)
const
;
368
369
private
:
370
Q_DECLARE_PRIVATE(
AbstractNodeFactory
)
371
AbstractNodeFactoryPrivate
*
const
d_ptr;
372
};
373
}
374
375
#endif
Cutelee::AbstractNodeFactoryPrivate
Definition
node.cpp:43
Cutelee::AbstractNodeFactory
Base class for all NodeFactories.
Definition
node.h:300
Cutelee::AbstractNodeFactory::getNode
virtual Node * getNode(const QString &tagContent, Parser *p) const =0
Cutelee::Context
The Context class holds the context to render a Template with.
Definition
context.h:119
Cutelee::Engine
Cutelee::Engine is the main entry point for creating Cutelee Templates.
Definition
engine.h:121
Cutelee::NodeList
A list of Nodes with some convenience API for rendering them.
Definition
node.h:148
Cutelee::NodeList::findChildren
QList< T > findChildren()
Definition
node.h:190
Cutelee::NodePrivate
Definition
node.cpp:36
Cutelee::Node
Base class for all nodes.
Definition
node.h:78
Cutelee::Node::render
virtual void render(OutputStream *stream, Context *c) const =0
Cutelee::OutputStream
The OutputStream class is used to render templates to a QTextStream.
Definition
outputstream.h:81
Cutelee::Parser
The Parser class processes a string template into a tree of nodes.
Definition
parser.h:49
QString
Definition
operatorcasttests.cpp:24
QVariant
Definition
operatorcasttests.cpp:31
Cutelee
The Cutelee namespace holds all public Cutelee API.
Definition
Mainpage.dox:8
Generated by
1.9.8