Grantlee  0.4.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_CORE_EXPORT Parser : public QObject
49 {
50  Q_OBJECT
51 public:
57  Parser( const QList<Token> &tokenList, QObject *parent );
58 
62  ~Parser();
63 
64 #ifndef Q_QDOC
65 
70  void setTokens( const QList<Token> &tokenList );
71 #endif
72 
82  NodeList parse( Node *parent, const QStringList &stopAt = QStringList() );
83 
88  NodeList parse( TemplateImpl *parent, const QStringList &stopAt = QStringList() );
89 
94  NodeList parse( Node *parent, const QString &stopAt );
95 
99  Filter::Ptr getFilter( const QString &name ) const;
100 
105  void skipPast( const QString &tag );
106 
114  Token takeNextToken();
115 
119  bool hasNextToken() const;
120 
124  void removeNextToken();
125 
126 #ifndef Q_QDOC
127 
132  void loadLib( const QString &name );
133 #endif
134 
135 protected:
139  void prependToken( const Token &token );
140 
141 private:
142  Q_DECLARE_PRIVATE( Parser )
143  ParserPrivate * const d_ptr;
144 
145 };
146 
147 }
148 
149 #endif
150 
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:142