diff options
-rw-r--r-- | src/corelib/kernel/qmetaobjectbuilder.cpp | 32 | ||||
-rw-r--r-- | src/corelib/kernel/qmetaobjectbuilder_p.h | 18 |
2 files changed, 30 insertions, 20 deletions
diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp index ea8fba10d0..994549b8b2 100644 --- a/src/corelib/kernel/qmetaobjectbuilder.cpp +++ b/src/corelib/kernel/qmetaobjectbuilder.cpp @@ -1075,26 +1075,18 @@ int QMetaObjectBuilder::indexOfClassInfo(const QByteArray& name) #define ALIGN(size,type) \ (size) = ((size) + sizeof(type) - 1) & ~(sizeof(type) - 1) -class MetaStringTable -{ -public: - MetaStringTable() : m_index(0) {} - - int enter(const QByteArray &value); - - static int preferredAlignment(); - int blobSize() const; - void writeBlob(char *out); +/*! + \class QMetaStringTable + \internal + \brief The QMetaStringTable class can generate a meta-object string table at runtime. +*/ -private: - typedef QHash<QByteArray, int> Entries; // string --> index mapping - Entries m_entries; - int m_index; -}; +QMetaStringTable::QMetaStringTable() + : m_index(0) {} // Enters the given value into the string table (if it hasn't already been // entered). Returns the index of the string. -int MetaStringTable::enter(const QByteArray &value) +int QMetaStringTable::enter(const QByteArray &value) { Entries::iterator it = m_entries.find(value); if (it != m_entries.end()) @@ -1105,7 +1097,7 @@ int MetaStringTable::enter(const QByteArray &value) return pos; } -int MetaStringTable::preferredAlignment() +int QMetaStringTable::preferredAlignment() { #ifdef Q_ALIGNOF return Q_ALIGNOF(QByteArrayData); @@ -1115,7 +1107,7 @@ int MetaStringTable::preferredAlignment() } // Returns the size (in bytes) required for serializing this string table. -int MetaStringTable::blobSize() const +int QMetaStringTable::blobSize() const { int size = m_entries.size() * sizeof(QByteArrayData); Entries::const_iterator it; @@ -1128,7 +1120,7 @@ int MetaStringTable::blobSize() const // The struct consists of an array of QByteArrayData, followed by a char array // containing the actual strings. This format must match the one produced by // moc (see generator.cpp). -void MetaStringTable::writeBlob(char *out) +void QMetaStringTable::writeBlob(char *out) { Q_ASSERT(!(reinterpret_cast<quintptr>(out) & (preferredAlignment()-1))); @@ -1305,7 +1297,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, // Reset the current data position to just past the QMetaObjectPrivate. dataIndex = MetaObjectPrivateFieldCount; - MetaStringTable strings; + QMetaStringTable strings; strings.enter(d->className); // Output the class infos, diff --git a/src/corelib/kernel/qmetaobjectbuilder_p.h b/src/corelib/kernel/qmetaobjectbuilder_p.h index ef802ce82b..4d766a9197 100644 --- a/src/corelib/kernel/qmetaobjectbuilder_p.h +++ b/src/corelib/kernel/qmetaobjectbuilder_p.h @@ -56,6 +56,7 @@ #include <QtCore/qobject.h> #include <QtCore/qmetaobject.h> #include <QtCore/qdatastream.h> +#include <QtCore/qhash.h> #include <QtCore/qmap.h> @@ -319,6 +320,23 @@ private: QMetaEnumBuilderPrivate *d_func() const; }; +class Q_CORE_EXPORT QMetaStringTable +{ +public: + QMetaStringTable(); + + int enter(const QByteArray &value); + + static int preferredAlignment(); + int blobSize() const; + void writeBlob(char *out); + +private: + typedef QHash<QByteArray, int> Entries; // string --> index mapping + Entries m_entries; + int m_index; +}; + Q_DECLARE_OPERATORS_FOR_FLAGS(QMetaObjectBuilder::AddMembers) Q_DECLARE_OPERATORS_FOR_FLAGS(QMetaObjectBuilder::MetaObjectFlags) |