OSDN Git Service

It's 2011 now.
[qt-creator-jp/qt-creator-jp.git] / src / libs / languageutils / fakemetaobject.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef FAKEMETAOBJECT_H
35 #define FAKEMETAOBJECT_H
36
37 #include "languageutils_global.h"
38 #include "componentversion.h"
39
40 #include <QtCore/QString>
41 #include <QtCore/QStringList>
42 #include <QtCore/QList>
43 #include <QtCore/QHash>
44 #include <QtCore/QSharedPointer>
45
46 namespace LanguageUtils {
47
48 class LANGUAGEUTILS_EXPORT FakeMetaEnum {
49     QString m_name;
50     QStringList m_keys;
51     QList<int> m_values;
52
53 public:
54     FakeMetaEnum(const QString &name);
55
56     QString name() const;
57
58     void addKey(const QString &key, int value);
59     QString key(int index) const;
60     int keyCount() const;
61     QStringList keys() const;
62 };
63
64 class LANGUAGEUTILS_EXPORT FakeMetaMethod {
65 public:
66     enum {
67         Signal,
68         Slot,
69         Method
70     };
71
72     enum {
73         Private,
74         Protected,
75         Public
76     };
77
78 public:
79     FakeMetaMethod(const QString &name, const QString &returnType = QString());
80
81     QString methodName() const;
82     QStringList parameterNames() const;
83     QStringList parameterTypes() const;
84     void addParameter(const QString &name, const QString &type);
85
86     int methodType() const;
87     void setMethodType(int methodType);
88
89     int access() const;
90
91 private:
92     QString m_name;
93     QString m_returnType;
94     QStringList m_paramNames;
95     QStringList m_paramTypes;
96     int m_methodTy;
97     int m_methodAccess;
98 };
99
100 class LANGUAGEUTILS_EXPORT FakeMetaProperty {
101     QString m_propertyName;
102     QString m_type;
103     bool m_isList;
104     bool m_isWritable;
105     bool m_isPointer;
106
107 public:
108     FakeMetaProperty(const QString &name, const QString &type, bool isList, bool isWritable, bool isPointer);
109
110     QString name() const;
111     QString typeName() const;
112
113     bool isList() const;
114     bool isWritable() const;
115     bool isPointer() const;
116 };
117
118 class LANGUAGEUTILS_EXPORT FakeMetaObject {
119     Q_DISABLE_COPY(FakeMetaObject);
120
121 public:
122     typedef QSharedPointer<FakeMetaObject> Ptr;
123     typedef QSharedPointer<const FakeMetaObject> ConstPtr;
124
125     class Export {
126     public:
127         QString package;
128         QString type;
129         ComponentVersion version;
130         QString packageNameVersion;
131     };
132
133 private:
134     QList<Export> m_exports;
135     ConstPtr m_super;
136     QString m_superName;
137     QList<FakeMetaEnum> m_enums;
138     QHash<QString, int> m_enumNameToIndex;
139     QList<FakeMetaProperty> m_props;
140     QHash<QString, int> m_propNameToIdx;
141     QList<FakeMetaMethod> m_methods;
142     QString m_defaultPropertyName;
143
144 public:
145     FakeMetaObject();
146
147     void addExport(const QString &name, const QString &package, ComponentVersion version);
148     QList<Export> exports() const;
149
150     void setSuperclassName(const QString &superclass);
151     QString superclassName() const;
152     void setSuperclass(ConstPtr superClass);
153     ConstPtr superClass() const;
154
155     void addEnum(const FakeMetaEnum &fakeEnum);
156     int enumeratorCount() const;
157     int enumeratorOffset() const;
158     FakeMetaEnum enumerator(int index) const;
159     int enumeratorIndex(const QString &name) const;
160
161     void addProperty(const FakeMetaProperty &property);
162     int propertyCount() const;
163     int propertyOffset() const;
164     FakeMetaProperty property(int index) const;
165     int propertyIndex(const QString &name) const;
166
167     void addMethod(const FakeMetaMethod &method);
168     int methodCount() const;
169     int methodOffset() const;
170     FakeMetaMethod method(int index) const;
171
172     QString defaultPropertyName() const;
173     void setDefaultPropertyName(const QString defaultPropertyName);
174 };
175
176 } // namespace LanguageUtils
177
178 #endif // FAKEMETAOBJECT_H