OSDN Git Service

Update license.
[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 (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
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.
18 **
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.
22 **
23 ** Other Usage
24 **
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.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef FAKEMETAOBJECT_H
34 #define FAKEMETAOBJECT_H
35
36 #include "languageutils_global.h"
37 #include "componentversion.h"
38
39 #include <QtCore/QString>
40 #include <QtCore/QStringList>
41 #include <QtCore/QList>
42 #include <QtCore/QHash>
43 #include <QtCore/QSharedPointer>
44
45 namespace LanguageUtils {
46
47 class LANGUAGEUTILS_EXPORT FakeMetaEnum {
48     QString m_name;
49     QStringList m_keys;
50     QList<int> m_values;
51
52 public:
53     FakeMetaEnum();
54     explicit FakeMetaEnum(const QString &name);
55
56     QString name() const;
57     void setName(const QString &name);
58
59     void addKey(const QString &key, int value);
60     QString key(int index) const;
61     int keyCount() const;
62     QStringList keys() const;
63 };
64
65 class LANGUAGEUTILS_EXPORT FakeMetaMethod {
66 public:
67     enum {
68         Signal,
69         Slot,
70         Method
71     };
72
73     enum {
74         Private,
75         Protected,
76         Public
77     };
78
79 public:
80     FakeMetaMethod();
81     explicit FakeMetaMethod(const QString &name, const QString &returnType = QString());
82
83     QString methodName() const;
84     void setMethodName(const QString &name);
85
86     void setReturnType(const QString &type);
87
88     QStringList parameterNames() const;
89     QStringList parameterTypes() const;
90     void addParameter(const QString &name, const QString &type);
91
92     int methodType() const;
93     void setMethodType(int methodType);
94
95     int access() const;
96
97 private:
98     QString m_name;
99     QString m_returnType;
100     QStringList m_paramNames;
101     QStringList m_paramTypes;
102     int m_methodTy;
103     int m_methodAccess;
104 };
105
106 class LANGUAGEUTILS_EXPORT FakeMetaProperty {
107     QString m_propertyName;
108     QString m_type;
109     bool m_isList;
110     bool m_isWritable;
111     bool m_isPointer;
112
113 public:
114     FakeMetaProperty(const QString &name, const QString &type, bool isList, bool isWritable, bool isPointer);
115
116     QString name() const;
117     QString typeName() const;
118
119     bool isList() const;
120     bool isWritable() const;
121     bool isPointer() const;
122 };
123
124 class LANGUAGEUTILS_EXPORT FakeMetaObject {
125     Q_DISABLE_COPY(FakeMetaObject);
126
127 public:
128     typedef QSharedPointer<FakeMetaObject> Ptr;
129     typedef QSharedPointer<const FakeMetaObject> ConstPtr;
130
131     class LANGUAGEUTILS_EXPORT Export {
132     public:
133         QString package;
134         QString type;
135         ComponentVersion version;
136         QString packageNameVersion;
137
138         bool isValid() const;
139     };
140
141 private:
142     QString m_className;
143     QList<Export> m_exports;
144     QString m_superName;
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;
152
153 public:
154     FakeMetaObject();
155
156     QString className() const;
157     void setClassName(const QString &name);
158
159     void addExport(const QString &name, const QString &package, ComponentVersion version);
160     QList<Export> exports() const;
161     Export exportInPackage(const QString &package) const;
162
163     void setSuperclassName(const QString &superclass);
164     QString superclassName() const;
165
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;
171
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;
177
178     void addMethod(const FakeMetaMethod &method);
179     int methodCount() const;
180     int methodOffset() const;
181     FakeMetaMethod method(int index) const;
182
183     QString defaultPropertyName() const;
184     void setDefaultPropertyName(const QString &defaultPropertyName);
185
186     QString attachedTypeName() const;
187     void setAttachedTypeName(const QString &name);
188 };
189
190 } // namespace LanguageUtils
191
192 #endif // FAKEMETAOBJECT_H