Grantlee: templates/lib/parser.h Source File

Grantlee 5.2.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
48 class GRANTLEE_TEMPLATES_EXPORT Parser : public QObject
49 {
50 Q_OBJECT
51 public:
57 Parser(const QList<Token> &tokenList, QObject *parent);
58
62 ~Parser() override;
63
73 NodeList parse(Node *parent, const QStringList &stopAt = {});
74
79 NodeList parse(TemplateImpl *parent, const QStringList &stopAt = {});
80
85 NodeList parse(Node *parent, const QString &stopAt);
86
91 QSharedPointer<Filter> getFilter(const QString &name) const;
92
97 void skipPast(const QString &tag);
98
107 Token takeNextToken();
108
112 bool hasNextToken() const;
113
117 void removeNextToken();
118
119 void invalidBlockTag(const Token &token, const QString &command,
120 const QStringList &stopAt = {});
121
122 #ifndef Q_QDOC
123
128 void loadLib(const QString &name);
129 #endif
130
131 protected:
136 void prependToken(const Token &token);
137
138 private:
139 Q_DECLARE_PRIVATE(Parser)
140 ParserPrivate *const d_ptr;
141 };
142 }
143
144 #endif
Grantlee::Parser
The Parser class processes a string template into a tree of nodes.
Definition: parser.h:48
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:152
Grantlee
The Grantlee namespace holds all public Grantlee API.
Definition: Mainpage.dox:7