Grantlee 5.3.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
30namespace Grantlee
31{
32class TemplateImpl;
33
34class ParserPrivate;
35
37
48class GRANTLEE_TEMPLATES_EXPORT Parser : public QObject
49{
50 Q_OBJECT
51public:
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
108
112 bool hasNextToken() const;
113
118
119 void invalidBlockTag(const Token &token, const QString &command,
120 const QStringList &stopAt = {});
121
122#ifndef Q_QDOC
128 void loadLib(const QString &name);
129#endif
130
131protected:
136 void prependToken(const Token &token);
137
138private:
139 Q_DECLARE_PRIVATE(Parser)
140 ParserPrivate *const d_ptr;
141};
142}
143
144#endif
A list of Nodes with some convenience API for rendering them.
Definition node.h:153
Base class for all nodes.
Definition node.h:83
The Parser class processes a string template into a tree of nodes.
Definition parser.h:49
void removeNextToken()
~Parser() override
bool hasNextToken() const
void skipPast(const QString &tag)
Parser(const QList< Token > &tokenList, QObject *parent)
NodeList parse(Node *parent, const QString &stopAt)
Token takeNextToken()
QSharedPointer< Filter > getFilter(const QString &name) const
NodeList parse(Node *parent, const QStringList &stopAt={})
NodeList parse(TemplateImpl *parent, const QStringList &stopAt={})
void prependToken(const Token &token)
The Grantlee namespace holds all public Grantlee API.
Definition Mainpage.dox:8