summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlscriptparser_p.h
blob: 0d89268047dde8fa8c8337e7081ae26dbbc0ba30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef QMLSCRIPTPARSER_P_H
#define QMLSCRIPTPARSER_P_H

#include <QtCore/QList>
#include <QtCore/QUrl>
#include <qml.h>

QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE

QT_MODULE(Declarative)

namespace QmlParser {
    class Object;
}

class QByteArray;

class QmlScriptParser
{
public:
    QmlScriptParser();
    ~QmlScriptParser();

    bool parse(const QByteArray &data, const QUrl &url = QUrl());
    QString errorDescription() const;
    int errorLine() const;

    QMap<QString,QString> nameSpacePaths() const;
    QStringList types() const;

    QmlParser::Object *tree() const;

    void clear();

// ### private:
    int findOrCreateTypeId(const QString &name);
    void setTree(QmlParser::Object *tree);

    void setScriptFile(const QString &filename) {_scriptFile = filename; }
    QString scriptFile() const { return _scriptFile; }

    void addNamespacePath(const QString &path);

private:
    QMap<QString,QString> _nameSpacePaths;
    QmlParser::Object *root;
    QStringList _typeNames;
    QString _error;
    int _errorLine;
    QString _scriptFile;
};

QT_END_NAMESPACE
QT_END_HEADER

#endif // QMLSCRIPTPARSER_P_H