Grantlee: templates/lib/parser.h Source File

Grantlee 5.1.0

parser.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_PARSER_H
22 #define GRANTLEE_PARSER_H
23
24 #include "filter.h"
25 #include "node.h"
26 #include "token.h"
27
28 #include <QtCore/QStringList>
29
30 namespace Grantlee
31 {
32 class TemplateImpl;
33
34 class ParserPrivate;
35
37
49 class GRANTLEE_TEMPLATES_EXPORT Parser : public QObject
50 {
51 Q_OBJECT
52 public:
58 Parser(const QList<Token> &tokenList, QObject *parent);
59
63 ~Parser() override;
64
76 NodeList parse(Node *parent, const QStringList &stopAt = QStringList());
77
82 NodeList parse(TemplateImpl *parent,
83 const QStringList &stopAt = QStringList());
84
89 NodeList parse(Node *parent, const QString &stopAt);
90
95 QSharedPointer<Filter> getFilter(const QString &name) const;
96
103 void skipPast(const QString &tag);
104
115 Token takeNextToken();
116
120 bool hasNextToken() const;
121
125 void removeNextToken();
126
127 void invalidBlockTag(const Token &token, const QString &command,
128 const QStringList &stopAt = QStringList());
129
130 #ifndef Q_QDOC
131
136 void loadLib(const QString &name);
137 #endif
138
139 protected:
144 void prependToken(const Token &token);
145
146 private:
147 Q_DECLARE_PRIVATE(Parser)
148 ParserPrivate *const d_ptr;
149 };
150 }
151
152 #endif
Grantlee::Parser
The Parser class processes a string template into a tree of nodes.
Definition: parser.h:49
Grantlee::Node
Base class for all nodes.
Definition: node.h:82
Grantlee::Token
Definition: token.h:48
Grantlee::NodeList
A list of Nodes with some convenience API for rendering them.
Definition: node.h:154
Grantlee
The Grantlee namespace holds all public Grantlee API.
Definition: Mainpage.dox:7