summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlscriptparser_p.h
blob: 8a5466f42b6cb75d682891e9618f2cd3d33f7542 (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
58
59
60
61
62
63
64
65
66
#ifndef QMLSCRIPTPARSER_P_H
#define QMLSCRIPTPARSER_P_H

#include <QtCore/QList>
#include <QtCore/QUrl>
#include <QtDeclarative/qmlerror.h>
#include "qmlparser_p.h"


QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE

QT_MODULE(Declarative)

class QByteArray;

class QmlScriptParser
{
public:
    class Import
    {
    public:
        Import() {}

        QString uri;
        QmlParser::LocationSpan location;
    };

    QmlScriptParser();
    ~QmlScriptParser();

    bool parse(const QByteArray &data, const QUrl &url = QUrl());

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

    QmlParser::Object *tree() const;
    QList<Import> imports() const;

    void clear();

    QList<QmlError> errors() const;

// ### 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:
    QList<QmlError> _errors;

    QMap<QString,QString> _nameSpacePaths;
    QmlParser::Object *root;
    QList<Import> _imports;
    QStringList _typeNames;
    QString _scriptFile;
};

QT_END_NAMESPACE
QT_END_HEADER

#endif // QMLSCRIPTPARSER_P_H