Grantlee  5.1.0
Public Member Functions | Protected Member Functions | List of all members
Grantlee::Parser Class Reference

The Parser class processes a string template into a tree of nodes. More...

#include <grantlee/parser.h>

Inheritance diagram for Grantlee::Parser:
Inheritance graph
[legend]

Public Member Functions

 Parser (const QList< Token > &tokenList, QObject *parent)
 
 ~Parser () override
 
QSharedPointer< FiltergetFilter (const QString &name) const
 
bool hasNextToken () const
 
void invalidBlockTag (const Token &token, const QString &command, const QStringList &stopAt=QStringList())
 
NodeList parse (Node *parent, const QStringList &stopAt=QStringList())
 
NodeList parse (TemplateImpl *parent, const QStringList &stopAt=QStringList())
 
NodeList parse (Node *parent, const QString &stopAt)
 
void removeNextToken ()
 
void skipPast (const QString &tag)
 
Token takeNextToken ()
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent)
 
 QObject (QObject *parent, const char *name)
 
bool blockSignals (bool block)
 
QObjectchild (const char *objName, const char *inheritsClass, bool recursiveSearch) const
 
const QObjectList & children () const
 
const char * className () const
 
bool connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const QObject *receiver, const char *method)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method)
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QByteArraydynamicPropertyNames () const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name) const
 
QList< T > findChildren (const QRegExp &regExp) const
 
QList< T > findChildren (const QString &name) const
 
bool inherits (const char *className) const
 
void insertChild (QObject *object)
 
void installEventFilter (QObject *filterObj)
 
bool isA (const char *className) const
 
bool isWidgetType () const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
const char * name () const
 
const char * name (const char *defaultName) const
 
QString objectName () const
 
QObjectparent () const
 
QVariant property (const char *name) const
 
void removeChild (QObject *object)
 
void removeEventFilter (QObject *obj)
 
void setName (const char *name)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval)
 
QThreadthread () const
 

Protected Member Functions

void prependToken (const Token &token)
 
- Protected Member Functions inherited from QObject
bool checkConnectArgs (const char *signal, const QObject *object, const char *method)
 
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const char *signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const char *signal)
 
int receivers (const char *signal) const
 
QObjectsender () const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Static Protected Member Functions inherited from QObject
QByteArray normalizeSignalSlot (const char *signalSlot)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

For application developers, this class is internal.

For template tag authors it may be necessary to advance the parser and process contained tags if the tag works in a tag – endtag fashion.

Author
Stephen Kelly steve.nosp@m.ire@.nosp@m.gmail.nosp@m..com

Definition at line 49 of file parser.h.

Constructor & Destructor Documentation

Grantlee::Parser::Parser ( const QList< Token > &  tokenList,
QObject parent 
)

Constructor.

Initialises the Parser with the tokenList.

Grantlee::Parser::~Parser ( )
override

Destructor.

Member Function Documentation

QSharedPointer<Filter> Grantlee::Parser::getFilter ( const QString name) const

Returns the filter object called name or an invalid object if no filter with that name is loaded.

bool Grantlee::Parser::hasNextToken ( ) const

Returns whether the parser has another token to process.

NodeList Grantlee::Parser::parse ( Node parent,
const QStringList stopAt = QStringList() 
)

Advance the parser, using parent as the parent of new Nodes. The parser will stop if it encounters a tag which is contained in the list stopAt.

For example, the {% if %} tag would stopAt both {% endif %} and {% else %} tags.

See also
AbstractNodeFactory::getNode
NodeList Grantlee::Parser::parse ( TemplateImpl *  parent,
const QStringList stopAt = QStringList() 
)

This is an overloaded method.

See also
parse.
NodeList Grantlee::Parser::parse ( Node parent,
const QString stopAt 
)

This is an overloaded method.

See also
parse.
void Grantlee::Parser::prependToken ( const Token token)
protected

Puts the token token to the front of the list to be processed by the parser.

void Grantlee::Parser::removeNextToken ( )

Deletes the next token available to the parser.

void Grantlee::Parser::skipPast ( const QString tag)

Advances the parser to the tag tag. This method is similar to parse, but it does not create nodes for tags encountered.

Token Grantlee::Parser::takeNextToken ( )

Returns the next token to be processed by the parser. This can be examined in template tag implementations to determine why parsing stopped.

For example, if the {% if %} tag, parsing may stop at an {% else %} tag, in which case parsing should be restarted, or it could stop at an {% endif %} tag, in which case parsing is finished for that node.