Grantlee  5.0.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();
63 
73  NodeList parse( Node *parent, const QStringList &stopAt = QStringList() );
74 
79  NodeList parse( TemplateImpl *parent, const QStringList &stopAt = QStringList() );
80 
85  NodeList parse( Node *parent, const QString &stopAt );
86 
90  QSharedPointer<Filter> getFilter( const QString &name ) const;
91 
96  void skipPast( const QString &tag );
97 
105  Token takeNextToken();
106 
110  bool hasNextToken() const;
111 
115  void removeNextToken();
116 
117 #ifndef Q_QDOC
118 
123  void loadLib( const QString &name );
124 #endif
125 
126 protected:
130  void prependToken( const Token &token );
131 
132 private:
133  Q_DECLARE_PRIVATE( Parser )
134  ParserPrivate * const d_ptr;
135 
136 };
137 
138 }
139 
140 #endif
The Parser class processes a string template into a tree of nodes.
Definition: parser.h:48
Base class for all nodes.
Definition: node.h:76
A list of Nodes with some convenience API for rendering them.
Definition: node.h:141
The Grantlee namespace holds all public Grantlee API.
Definition: Mainpage.dox:7