Changeset View
Changeset View
Standalone View
Standalone View
templates/scriptabletags/scriptableparser.h
Show All 18 Lines | |||||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #ifndef SCRIPTABLE_PARSER_H | 21 | #ifndef SCRIPTABLE_PARSER_H | ||
22 | #define SCRIPTABLE_PARSER_H | 22 | #define SCRIPTABLE_PARSER_H | ||
23 | 23 | | |||
24 | #include <QtCore/QObject> | 24 | #include <QtCore/QObject> | ||
25 | #include <QtCore/QStringList> | 25 | #include <QtCore/QStringList> | ||
26 | #include <QtCore/QVariant> | 26 | #include <QtCore/QVariant> | ||
27 | #include <QtScript/QScriptValue> | 27 | #include <QtQml/QJSValue> | ||
28 | 28 | | |||
29 | #include "token.h" | 29 | #include "token.h" | ||
30 | 30 | | |||
31 | namespace Grantlee | 31 | namespace Grantlee | ||
32 | { | 32 | { | ||
33 | class Parser; | 33 | class Parser; | ||
34 | } | 34 | } | ||
35 | 35 | | |||
36 | using namespace Grantlee; | 36 | using namespace Grantlee; | ||
37 | 37 | | |||
38 | class ScriptableParser : public QObject | 38 | class ScriptableParser : public QObject | ||
39 | { | 39 | { | ||
40 | Q_OBJECT | 40 | Q_OBJECT | ||
41 | public: | 41 | public: | ||
42 | explicit ScriptableParser(Parser *p, QObject *parent = 0); | 42 | explicit ScriptableParser(Parser *p, QJSEngine *engine); | ||
43 | 43 | | |||
44 | Parser *parser() { return m_p; } | 44 | Parser *parser() { return m_p; } | ||
45 | 45 | | |||
46 | public Q_SLOTS: | 46 | public Q_SLOTS: | ||
47 | QObjectList parse(QObject *parent, const QString &stopAt); | 47 | QList<QObject *> parse(QObject *parent, const QString &stopAt); | ||
48 | QObjectList parse(QObject *parent, const QStringList &stopAt = QStringList()); | 48 | QList<QObject *> parse(QObject *parent, const QStringList &stopAt = QStringList()); | ||
49 | 49 | | |||
50 | void skipPast(const QString &tag); | 50 | void skipPast(const QString &tag); | ||
51 | 51 | | |||
52 | Token takeNextToken(); | 52 | QJSValue takeNextToken(); | ||
53 | bool hasNextToken() const; | 53 | bool hasNextToken() const; | ||
54 | void removeNextToken(); | 54 | void removeNextToken(); | ||
55 | 55 | | |||
56 | void loadLib(const QString &name); | 56 | void loadLib(const QString &name); | ||
57 | 57 | | |||
58 | private: | 58 | private: | ||
59 | Parser *m_p; | 59 | Parser *m_p; | ||
60 | QJSEngine *m_engine; | ||||
60 | }; | 61 | }; | ||
61 | 62 | | |||
62 | #endif | 63 | #endif |