source: trunk/src/declarative/qml/qdeclarativecustomparser_p.h

Last change on this file was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 5.5 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation (qt-info@nokia.com)
6**
7** This file is part of the QtDeclarative module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at qt-info@nokia.com.
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QDECLARATIVECUSTOMPARSER_H
43#define QDECLARATIVECUSTOMPARSER_H
44
45//
46// W A R N I N G
47// -------------
48//
49// This file is not part of the Qt API. It exists purely as an
50// implementation detail. This header file may change from version to
51// version without notice, or even be removed.
52//
53// We mean it.
54//
55
56#include "private/qdeclarativemetatype_p.h"
57#include "qdeclarativeerror.h"
58#include "private/qdeclarativeparser_p.h"
59
60#include <QtCore/qbytearray.h>
61#include <QtCore/qxmlstream.h>
62
63QT_BEGIN_HEADER
64
65QT_BEGIN_NAMESPACE
66
67QT_MODULE(Declarative)
68
69class QDeclarativeCompiler;
70
71class QDeclarativeCustomParserPropertyPrivate;
72class Q_DECLARATIVE_EXPORT QDeclarativeCustomParserProperty
73{
74public:
75 QDeclarativeCustomParserProperty();
76 QDeclarativeCustomParserProperty(const QDeclarativeCustomParserProperty &);
77 QDeclarativeCustomParserProperty &operator=(const QDeclarativeCustomParserProperty &);
78 ~QDeclarativeCustomParserProperty();
79
80 QByteArray name() const;
81 QDeclarativeParser::Location location() const;
82
83 bool isList() const;
84 // Will be one of QDeclarativeParser::Variant, QDeclarativeCustomParserProperty or
85 // QDeclarativeCustomParserNode
86 QList<QVariant> assignedValues() const;
87
88private:
89 friend class QDeclarativeCustomParserNodePrivate;
90 friend class QDeclarativeCustomParserPropertyPrivate;
91 QDeclarativeCustomParserPropertyPrivate *d;
92};
93
94class QDeclarativeCustomParserNodePrivate;
95class Q_DECLARATIVE_EXPORT QDeclarativeCustomParserNode
96{
97public:
98 QDeclarativeCustomParserNode();
99 QDeclarativeCustomParserNode(const QDeclarativeCustomParserNode &);
100 QDeclarativeCustomParserNode &operator=(const QDeclarativeCustomParserNode &);
101 ~QDeclarativeCustomParserNode();
102
103 QByteArray name() const;
104 QDeclarativeParser::Location location() const;
105
106 QList<QDeclarativeCustomParserProperty> properties() const;
107
108private:
109 friend class QDeclarativeCustomParserNodePrivate;
110 QDeclarativeCustomParserNodePrivate *d;
111};
112
113class Q_DECLARATIVE_EXPORT QDeclarativeCustomParser
114{
115public:
116 enum Flag {
117 NoFlag = 0x00000000,
118 AcceptsAttachedProperties = 0x00000001
119 };
120 Q_DECLARE_FLAGS(Flags, Flag)
121
122 QDeclarativeCustomParser() : compiler(0), object(0), m_flags(NoFlag) {}
123 QDeclarativeCustomParser(Flags f) : compiler(0), object(0), m_flags(f) {}
124 virtual ~QDeclarativeCustomParser() {}
125
126 void clearErrors();
127 Flags flags() const { return m_flags; }
128
129 virtual QByteArray compile(const QList<QDeclarativeCustomParserProperty> &)=0;
130 virtual void setCustomData(QObject *, const QByteArray &)=0;
131
132 QList<QDeclarativeError> errors() const { return exceptions; }
133
134protected:
135 void error(const QString& description);
136 void error(const QDeclarativeCustomParserProperty&, const QString& description);
137 void error(const QDeclarativeCustomParserNode&, const QString& description);
138
139 int evaluateEnum(const QByteArray&) const;
140
141 const QMetaObject *resolveType(const QByteArray&) const;
142
143private:
144 QList<QDeclarativeError> exceptions;
145 QDeclarativeCompiler *compiler;
146 QDeclarativeParser::Object *object;
147 Flags m_flags;
148 friend class QDeclarativeCompiler;
149};
150Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeCustomParser::Flags);
151
152#if 0
153#define QML_REGISTER_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, CUSTOMTYPE) \
154 qmlRegisterCustomType<TYPE>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE, new CUSTOMTYPE)
155#endif
156
157QT_END_NAMESPACE
158
159Q_DECLARE_METATYPE(QDeclarativeCustomParserProperty)
160Q_DECLARE_METATYPE(QDeclarativeCustomParserNode)
161
162QT_END_HEADER
163
164#endif
Note: See TracBrowser for help on using the repository browser.