1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #ifndef FAKEMETAOBJECT_H
34 #define FAKEMETAOBJECT_H
36 #include "languageutils_global.h"
37 #include "componentversion.h"
39 #include <QtCore/QString>
40 #include <QtCore/QStringList>
41 #include <QtCore/QList>
42 #include <QtCore/QHash>
43 #include <QtCore/QSharedPointer>
45 namespace LanguageUtils {
47 class LANGUAGEUTILS_EXPORT FakeMetaEnum {
54 explicit FakeMetaEnum(const QString &name);
57 void setName(const QString &name);
59 void addKey(const QString &key, int value);
60 QString key(int index) const;
62 QStringList keys() const;
65 class LANGUAGEUTILS_EXPORT FakeMetaMethod {
81 explicit FakeMetaMethod(const QString &name, const QString &returnType = QString());
83 QString methodName() const;
84 void setMethodName(const QString &name);
86 void setReturnType(const QString &type);
88 QStringList parameterNames() const;
89 QStringList parameterTypes() const;
90 void addParameter(const QString &name, const QString &type);
92 int methodType() const;
93 void setMethodType(int methodType);
100 QStringList m_paramNames;
101 QStringList m_paramTypes;
106 class LANGUAGEUTILS_EXPORT FakeMetaProperty {
107 QString m_propertyName;
114 FakeMetaProperty(const QString &name, const QString &type, bool isList, bool isWritable, bool isPointer);
116 QString name() const;
117 QString typeName() const;
120 bool isWritable() const;
121 bool isPointer() const;
124 class LANGUAGEUTILS_EXPORT FakeMetaObject {
125 Q_DISABLE_COPY(FakeMetaObject);
128 typedef QSharedPointer<FakeMetaObject> Ptr;
129 typedef QSharedPointer<const FakeMetaObject> ConstPtr;
131 class LANGUAGEUTILS_EXPORT Export {
135 ComponentVersion version;
136 QString packageNameVersion;
138 bool isValid() const;
143 QList<Export> m_exports;
145 QList<FakeMetaEnum> m_enums;
146 QHash<QString, int> m_enumNameToIndex;
147 QList<FakeMetaProperty> m_props;
148 QHash<QString, int> m_propNameToIdx;
149 QList<FakeMetaMethod> m_methods;
150 QString m_defaultPropertyName;
151 QString m_attachedTypeName;
156 QString className() const;
157 void setClassName(const QString &name);
159 void addExport(const QString &name, const QString &package, ComponentVersion version);
160 QList<Export> exports() const;
161 Export exportInPackage(const QString &package) const;
163 void setSuperclassName(const QString &superclass);
164 QString superclassName() const;
166 void addEnum(const FakeMetaEnum &fakeEnum);
167 int enumeratorCount() const;
168 int enumeratorOffset() const;
169 FakeMetaEnum enumerator(int index) const;
170 int enumeratorIndex(const QString &name) const;
172 void addProperty(const FakeMetaProperty &property);
173 int propertyCount() const;
174 int propertyOffset() const;
175 FakeMetaProperty property(int index) const;
176 int propertyIndex(const QString &name) const;
178 void addMethod(const FakeMetaMethod &method);
179 int methodCount() const;
180 int methodOffset() const;
181 FakeMetaMethod method(int index) const;
183 QString defaultPropertyName() const;
184 void setDefaultPropertyName(const QString &defaultPropertyName);
186 QString attachedTypeName() const;
187 void setAttachedTypeName(const QString &name);
190 } // namespace LanguageUtils
192 #endif // FAKEMETAOBJECT_H