Grantlee  5.1.0
templates/lib/parser.h
00001 /*
00002   This file is part of the Grantlee template system.
00003 
00004   Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
00005 
00006   This library is free software; you can redistribute it and/or
00007   modify it under the terms of the GNU Lesser General Public
00008   License as published by the Free Software Foundation; either version
00009   2.1 of the Licence, or (at your option) any later version.
00010 
00011   This library is distributed in the hope that it will be useful,
00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014   Lesser General Public License for more details.
00015 
00016   You should have received a copy of the GNU Lesser General Public
00017   License along with this library.  If not, see <http://www.gnu.org/licenses/>.
00018 
00019 */
00020 
00021 #ifndef GRANTLEE_PARSER_H
00022 #define GRANTLEE_PARSER_H
00023 
00024 #include "filter.h"
00025 #include "node.h"
00026 #include "token.h"
00027 
00028 #include <QtCore/QStringList>
00029 
00030 namespace Grantlee
00031 {
00032 class TemplateImpl;
00033 
00034 class ParserPrivate;
00035 
00037 
00049 class GRANTLEE_TEMPLATES_EXPORT Parser : public QObject
00050 {
00051   Q_OBJECT
00052 public:
00058   Parser(const QList<Token> &tokenList, QObject *parent);
00059 
00063   ~Parser() override;
00064 
00076   NodeList parse(Node *parent, const QStringList &stopAt = QStringList());
00077 
00082   NodeList parse(TemplateImpl *parent,
00083                  const QStringList &stopAt = QStringList());
00084 
00089   NodeList parse(Node *parent, const QString &stopAt);
00090 
00095   QSharedPointer<Filter> getFilter(const QString &name) const;
00096 
00103   void skipPast(const QString &tag);
00104 
00115   Token takeNextToken();
00116 
00120   bool hasNextToken() const;
00121 
00125   void removeNextToken();
00126 
00127   void invalidBlockTag(const Token &token, const QString &command,
00128                        const QStringList &stopAt = QStringList());
00129 
00130 #ifndef Q_QDOC
00131 
00136   void loadLib(const QString &name);
00137 #endif
00138 
00139 protected:
00144   void prependToken(const Token &token);
00145 
00146 private:
00147   Q_DECLARE_PRIVATE(Parser)
00148   ParserPrivate *const d_ptr;
00149 };
00150 }
00151 
00152 #endif