Qt 4.8
qmetaobjectbuilder_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
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, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QMETAOBJECTBUILDER_H
43 #define QMETAOBJECTBUILDER_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 for the convenience
50 // of moc. This header file may change from version to version without notice,
51 // or even be removed.
52 //
53 // We mean it.
54 //
55 
56 #include <QtCore/qobject.h>
57 #include <QtCore/qmetaobject.h>
58 #include <QtCore/qdatastream.h>
59 #include <QtCore/qmap.h>
60 
61 #include <private/qdeclarativeglobal_p.h>
62 
64 
66 class QMetaMethodBuilder;
70 class QMetaEnumBuilder;
72 
74 {
75 public:
76  enum AddMember
77  {
78  ClassName = 0x00000001,
79  SuperClass = 0x00000002,
80  Methods = 0x00000004,
81  Signals = 0x00000008,
82  Slots = 0x00000010,
83  Constructors = 0x00000020,
84  Properties = 0x00000040,
85  Enumerators = 0x00000080,
86  ClassInfos = 0x00000100,
87  RelatedMetaObjects = 0x00000200,
88  StaticMetacall = 0x00000400,
89  PublicMethods = 0x00000800,
90  ProtectedMethods = 0x00001000,
91  PrivateMethods = 0x00002000,
92  AllMembers = 0x7FFFFFFF,
93  AllPrimaryMembers = 0x7FFFFBFC
94  };
95  Q_DECLARE_FLAGS(AddMembers, AddMember)
96 
99  };
101 
103  explicit QMetaObjectBuilder(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members = AllMembers);
104  virtual ~QMetaObjectBuilder();
105 
106  QByteArray className() const;
107  void setClassName(const QByteArray& name);
108 
109  const QMetaObject *superClass() const;
110  void setSuperClass(const QMetaObject *meta);
111 
112  MetaObjectFlags flags() const;
113  void setFlags(MetaObjectFlags);
114 
115  int methodCount() const;
116  int constructorCount() const;
117  int propertyCount() const;
118  int enumeratorCount() const;
119  int classInfoCount() const;
120  int relatedMetaObjectCount() const;
121 
122  QMetaMethodBuilder addMethod(const QByteArray& signature);
123  QMetaMethodBuilder addMethod(const QByteArray& signature, const QByteArray& returnType);
124  QMetaMethodBuilder addMethod(const QMetaMethod& prototype);
125 
126  QMetaMethodBuilder addSlot(const QByteArray& signature);
127  QMetaMethodBuilder addSignal(const QByteArray& signature);
128 
129  QMetaMethodBuilder addConstructor(const QByteArray& signature);
130  QMetaMethodBuilder addConstructor(const QMetaMethod& prototype);
131 
132  QMetaPropertyBuilder addProperty(const QByteArray& name, const QByteArray& type, int notifierId=-1);
133  QMetaPropertyBuilder addProperty(const QMetaProperty& prototype);
134 
135  QMetaEnumBuilder addEnumerator(const QByteArray& name);
136  QMetaEnumBuilder addEnumerator(const QMetaEnum& prototype);
137 
138  int addClassInfo(const QByteArray& name, const QByteArray& value);
139 
140 #ifdef Q_NO_DATA_RELOCATION
141  int addRelatedMetaObject(const QMetaObjectAccessor &meta);
142 #else
143  int addRelatedMetaObject(const QMetaObject *meta);
144 #endif
145 
146  void addMetaObject(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members = AllMembers);
147 
148  QMetaMethodBuilder method(int index) const;
149  QMetaMethodBuilder constructor(int index) const;
151  QMetaEnumBuilder enumerator(int index) const;
152  const QMetaObject *relatedMetaObject(int index) const;
153 
154  QByteArray classInfoName(int index) const;
155  QByteArray classInfoValue(int index) const;
156 
157  void removeMethod(int index);
158  void removeConstructor(int index);
159  void removeProperty(int index);
160  void removeEnumerator(int index);
161  void removeClassInfo(int index);
162  void removeRelatedMetaObject(int index);
163 
164  int indexOfMethod(const QByteArray& signature);
165  int indexOfSignal(const QByteArray& signature);
166  int indexOfSlot(const QByteArray& signature);
167  int indexOfConstructor(const QByteArray& signature);
168  int indexOfProperty(const QByteArray& name);
169  int indexOfEnumerator(const QByteArray& name);
170  int indexOfClassInfo(const QByteArray& name);
171 
173 
174  QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction() const;
175  void setStaticMetacallFunction(QMetaObjectBuilder::StaticMetacallFunction value);
176 
177  QMetaObject *toMetaObject() const;
178  QByteArray toRelocatableData(bool * = 0) const;
179  static void fromRelocatableData(QMetaObject *, const QMetaObject *, const QByteArray &);
180 
181 #ifndef QT_NO_DATASTREAM
182  void serialize(QDataStream& stream) const;
183  void deserialize
185  const QMap<QByteArray, const QMetaObject *>& references);
186 #endif
187 
188 private:
190 
192 
196 };
197 
199 {
200 public:
201  QMetaMethodBuilder() : _mobj(0), _index(0) {}
202 
203  int index() const;
204 
205  QMetaMethod::MethodType methodType() const;
206  QByteArray signature() const;
207 
208  QByteArray returnType() const;
209  void setReturnType(const QByteArray& value);
210 
211  QList<QByteArray> parameterNames() const;
212  void setParameterNames(const QList<QByteArray>& value);
213 
214  QByteArray tag() const;
215  void setTag(const QByteArray& value);
216 
217  QMetaMethod::Access access() const;
218  void setAccess(QMetaMethod::Access value);
219 
220  int attributes() const;
221  void setAttributes(int value);
222 
223 private:
225  int _index;
226 
227  friend class QMetaObjectBuilder;
228  friend class QMetaPropertyBuilder;
229 
230  QMetaMethodBuilder(const QMetaObjectBuilder *mobj, int index)
231  : _mobj(mobj), _index(index) {}
232 
234 };
235 
237 {
238 public:
239  QMetaPropertyBuilder() : _mobj(0), _index(0) {}
240 
241  int index() const { return _index; }
242 
243  QByteArray name() const;
244  QByteArray type() const;
245 
246  bool hasNotifySignal() const;
247  QMetaMethodBuilder notifySignal() const;
248  void setNotifySignal(const QMetaMethodBuilder& value);
249  void removeNotifySignal();
250 
251  bool isReadable() const;
252  bool isWritable() const;
253  bool isResettable() const;
254  bool isDesignable() const;
255  bool isScriptable() const;
256  bool isStored() const;
257  bool isEditable() const;
258  bool isUser() const;
259  bool hasStdCppSet() const;
260  bool isEnumOrFlag() const;
261  bool isConstant() const;
262  bool isFinal() const;
263 
264  void setReadable(bool value);
265  void setWritable(bool value);
266  void setResettable(bool value);
267  void setDesignable(bool value);
268  void setScriptable(bool value);
269  void setStored(bool value);
270  void setEditable(bool value);
271  void setUser(bool value);
272  void setStdCppSet(bool value);
273  void setEnumOrFlag(bool value);
274  void setConstant(bool value);
275  void setFinal(bool value);
276 
277 private:
279  int _index;
280 
281  friend class QMetaObjectBuilder;
282 
284  : _mobj(mobj), _index(index) {}
285 
286  QMetaPropertyBuilderPrivate *d_func() const;
287 };
288 
290 {
291 public:
292  QMetaEnumBuilder() : _mobj(0), _index(0) {}
293 
294  int index() const { return _index; }
295 
296  QByteArray name() const;
297 
298  bool isFlag() const;
299  void setIsFlag(bool value);
300 
301  int keyCount() const;
302  QByteArray key(int index) const;
303  int value(int index) const;
304 
305  int addKey(const QByteArray& name, int value);
306  void removeKey(int index);
307 
308 private:
310  int _index;
311 
312  friend class QMetaObjectBuilder;
313 
314  QMetaEnumBuilder(const QMetaObjectBuilder *mobj, int index)
315  : _mobj(mobj), _index(index) {}
316 
317  QMetaEnumBuilderPrivate *d_func() const;
318 };
319 
320 Q_DECLARE_OPERATORS_FOR_FLAGS(QMetaObjectBuilder::AddMembers)
322 
324 
325 #endif
double d
Definition: qnumeric_p.h:62
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
int type
Definition: qmetatype.cpp:239
The QMetaEnum class provides meta-data about an enumerator.
Definition: qmetaobject.h:147
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
Definition: qglobal.h:2348
The QMetaPropertyBuilder class enables modifications to a property definition on a meta object builde...
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
Access
This enum describes the access level of a method, following the conventions used in C++...
Definition: qmetaobject.h:66
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
QMetaObjectExtraData::StaticMetacallFunction StaticMetacallFunction
Typedef for static metacall functions.
The QMetaMethodBuilder class enables modifications to a method definition on a meta object builder...
QMetaPropertyBuilder(const QMetaObjectBuilder *mobj, int index)
const QMetaObject &(* QMetaObjectAccessor)()
Definition: qobjectdefs.h:476
const char * className
Definition: qwizard.cpp:137
AddMember
This enum defines which members of QMetaObject should be copied by QMetaObjectBuilder::addMetaObject(...
int index() const
Returns the index of this property within its QMetaObjectBuilder.
static void addKey(QString &str, const QString &theKey, QKeySequence::SequenceFormat format)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static FILE * stream
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
Definition: qglobal.h:2355
int access(const char *, int)
const char * name
const QMetaObjectBuilder * _mobj
const QMetaObjectBuilder * _mobj
QMetaEnumBuilder(const QMetaObjectBuilder *mobj, int index)
#define Q_DECLARATIVE_PRIVATE_EXPORT
MetaObjectFlags
static QByteArray prototype(const QList< QByteArray > &parameterTypes, const QList< QByteArray > &parameterNames, bool *ok)
Definition: qaxserver.cpp:685
const QMetaObjectBuilder * _mobj
QMetaMethodBuilder(const QMetaObjectBuilder *mobj, int index)
int key
const char * property
Definition: qwizard.cpp:138
quint16 index
int index() const
Returns the index of this enumerator within its QMetaObjectBuilder.
The QMetaProperty class provides meta-data about a property.
Definition: qmetaobject.h:176
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
void(* StaticMetacallFunction)(QObject *, QMetaObject::Call, int, void **)
Definition: qobjectdefs.h:486
QMetaPropertyBuilderPrivate * d_func() const
#define class
The QMetaEnumBuilder class enables modifications to an enumerator definition on a meta object builder...
The QMetaMethod class provides meta-data about a member function.
Definition: qmetaobject.h:56
The QMap class is a template class that provides a skip-list-based dictionary.
Definition: qdatastream.h:67