1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QFASTMETABUILDER_P_H
43 #define QFASTMETABUILDER_P_H
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.
56 #include <QtCore/qglobal.h>
57 #include <QtCore/qmetatype.h>
59 #include <private/qhashedstring_p.h>
64 class QFastMetaBuilder
73 inline StringRef(const StringRef &);
74 inline StringRef &operator=(const StringRef &);
76 inline void load(const QHashedStringRef &);
77 inline void load(const QByteArray &);
78 inline void load(const char *);
80 inline bool isEmpty() const;
81 inline QFastMetaBuilder *builder() const;
82 inline int offset() const;
84 inline int length() const;
86 friend class QFastMetaBuilder;
92 StringRef newString(int length);
95 StringRef init(int classNameLength,
96 int propertyCount, int methodCount,
97 int signalCount, int classInfoCount);
99 void setClassInfo(int index, const StringRef &key, const StringRef &value);
103 Writable = 0x00000002,
104 Resettable = 0x00000004,
105 Constant = 0x00000400,
108 // void setProperty(int index, const StringRef &name, QMetaType::Type type, int notifySignal = -1);
109 void setProperty(int index, const StringRef &name, const StringRef &type,
110 QMetaType::Type mtype, PropertyFlag flags, int notifySignal = -1);
111 void setProperty(int index, const StringRef &name, const StringRef &type,
112 PropertyFlag flags, int notifySignal = -1);
113 void setMethod(int index, const StringRef &signature,
114 const StringRef ¶meterNames = StringRef(),
115 const StringRef &type = StringRef());
116 void setSignal(int index, const StringRef &signature,
117 const StringRef ¶meterNames = StringRef(),
118 const StringRef &type = StringRef());
120 int metaObjectIndexForSignal(int) const;
121 int metaObjectIndexForMethod(int) const;
123 QByteArray toData() const { return m_data; }
124 static void fromData(QMetaObject *, const QMetaObject *parent, const QByteArray &);
126 friend struct StringRef;
131 void allocateStringData();
133 int m_stringDataLength;
134 int m_stringDataAllocated;
137 QFastMetaBuilder::StringRef::StringRef()
138 : _b(0), _o(0), _l(0)
142 QFastMetaBuilder::StringRef::StringRef(const StringRef &o)
143 : _b(o._b), _o(o._o), _l(o._l)
147 QFastMetaBuilder::StringRef &QFastMetaBuilder::StringRef::operator=(const StringRef &o)
155 bool QFastMetaBuilder::StringRef::isEmpty() const
160 QFastMetaBuilder *QFastMetaBuilder::StringRef::builder() const
165 int QFastMetaBuilder::StringRef::offset() const
170 char *QFastMetaBuilder::StringRef::data()
173 if (_b->m_stringDataLength != _b->m_stringDataAllocated)
174 _b->allocateStringData();
175 return _b->m_stringData + _o;
178 int QFastMetaBuilder::StringRef::length() const
183 void QFastMetaBuilder::StringRef::load(const QHashedStringRef &str)
185 Q_ASSERT(str.utf8length() == _l);
186 str.writeUtf8(data());
190 void QFastMetaBuilder::StringRef::load(const QByteArray &str)
192 Q_ASSERT(str.length() == _l);
193 strcpy(data(), str.constData());
196 void QFastMetaBuilder::StringRef::load(const char *str)
198 Q_ASSERT(strlen(str) == (uint)_l);
204 #endif // QFASTMETABUILDER_P_H