Cutelee 6.1.0
parser.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_PARSER_H
22#define CUTELEE_PARSER_H
23
24#include "filter.h"
25#include "node.h"
26#include "token.h"
27
28#include <QtCore/QStringList>
29
30namespace Cutelee
31{
32class TemplateImpl;
33
34class ParserPrivate;
35
37
48class CUTELEE_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 std::shared_ptr<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
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:148
Base class for all nodes.
Definition node.h:78
The Parser class processes a string template into a tree of nodes.
Definition parser.h:49
NodeList parse(TemplateImpl *parent, const QStringList &stopAt={})
The Cutelee namespace holds all public Cutelee API.
Definition Mainpage.dox:8