Browse Source

Introduce QProtobufMetaObject

- Intorduce QProtobufMetaObject as replacment for staticMetaObject
  and propertyOrdering pairs in serialization/deserialization
  interfaces
- Realign arguments position in QAbstractProtobufSerializer
  interface
- Update doxy descriptions
Alexey Edelev 5 years ago
parent
commit
eed4df1434

+ 2 - 1
src/generator/templates.cpp

@@ -150,7 +150,8 @@ const char *Templates::SetterTemplateSimpleType = "void set$property_name_cap$(c
 const char *Templates::SignalsBlockTemplate = "\nsignals:\n";
 const char *Templates::SignalTemplate = "void $property_name$Changed();\n";
 
-const char *Templates::FieldsOrderingContainerTemplate = "const QtProtobuf::QProtobufPropertyOrdering $type$::propertyOrdering = {";
+const char *Templates::FieldsOrderingContainerTemplate = "const QtProtobuf::QProtobufMetaObject $type$::protobufMetaObject = QtProtobuf::QProtobufMetaObject($type$::staticMetaObject, $type$::propertyOrdering);\n"
+                                                         "const QtProtobuf::QProtobufPropertyOrdering $type$::propertyOrdering = {";
 const char *Templates::FieldOrderTemplate = "{$field_number$, $property_number$}";
 
 const char *Templates::EnumTemplate = "$type$";

+ 7 - 3
src/protobuf/CMakeLists.txt

@@ -22,7 +22,8 @@ file(GLOB SOURCES
     qabstractprotobufserializer.cpp
     qprotobufjsonserializer.cpp
     qprotobufserializer.cpp
-    qprotobufmetaproperty.cpp)
+    qprotobufmetaproperty.cpp
+    qprotobufmetaobject.cpp)
 
 file(GLOB HEADERS
     qtprotobufglobal.h
@@ -37,7 +38,9 @@ file(GLOB HEADERS
     qprotobufserializer_p.h
     qprotobufjsonserializer.h
     qprotobufselfcheckiterator.h
-    qprotobufregistrationhelper.h)
+    qprotobufregistrationhelper.h
+    qprotobufmetaproperty.h
+    qprotobufmetaobject.h)
 
 file(GLOB PUBLIC_HEADERS
     qtprotobufglobal.h
@@ -51,7 +54,8 @@ file(GLOB PUBLIC_HEADERS
     qprotobufjsonserializer.h
     qprotobufselfcheckiterator.h
     qprotobufregistrationhelper.h
-    qprotobufmetaproperty.h)
+    qprotobufmetaproperty.h
+    qprotobufmetaobject.h)
 
 add_library(${TARGET} SHARED ${SOURCES})
 target_compile_definitions(${TARGET} PRIVATE QT_BUILD_PROTOBUF_LIB PUBLIC QTPROTOBUF_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}

+ 21 - 23
src/protobuf/qabstractprotobufserializer.h

@@ -42,6 +42,7 @@
 namespace QtProtobuf {
 
 class QProtobufMetaProperty;
+class QProtobufMetaObject;
 /*!
 *  \addtogroup QtProtobuf
 *  \{
@@ -83,7 +84,7 @@ public:
     template<typename T>
     QByteArray serialize(const QObject *object) {
         qProtoDebug() << T::staticMetaObject.className() << "serialize";
-        return serializeMessage(object, T::propertyOrdering, T::staticMetaObject);
+        return serializeMessage(object, T::protobufMetaObject);
     }
 
     /*!
@@ -98,7 +99,7 @@ public:
     template<typename T>
     void deserialize(QObject *object, const QByteArray &array) {
         qProtoDebug() << T::staticMetaObject.className() << "deserialize";
-        deserializeMessage(object, array, T::propertyOrdering, T::staticMetaObject);
+        deserializeMessage(object, T::protobufMetaObject, array);
     }
 
     virtual ~QAbstractProtobufSerializer() = default;
@@ -110,7 +111,7 @@ public:
      * \param metaObject
      * \return
      */
-    virtual QByteArray serializeMessage(const QObject *object, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject) const = 0;
+    virtual QByteArray serializeMessage(const QObject *object, const QProtobufMetaObject &metaObject) const = 0;
 
     /*!
      * \brief serializeMessage
@@ -119,55 +120,52 @@ public:
      * \param metaObject
      * \return
      */
-    virtual void deserializeMessage(QObject *object, const QByteArray &data, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject) const = 0;
+    virtual void deserializeMessage(QObject *object, const QProtobufMetaObject &metaObject, const QByteArray &data) const = 0;
 
     /*!
      * \brief serializeObject Serializes complete \a object according given \a propertyOrdering and \a metaObject
      *        information
      * \param[in] object Pointer to object to be serialized
-     * \param[in] propertyOrdering Protobuf order of QObject properties
-     * \param[in] metaObject Meta object information for given \a object
-     * \param[in] metaProperty information about property to be serialized
+     * \param[in] metaObject Protobuf meta object information for given \a object
+     * \param[in] metaProperty Information about property to be serialized
      * \return Raw serialized data represented as byte array
      */
-    virtual QByteArray serializeObject(const QObject *object, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject, const QProtobufMetaProperty &metaProperty) const = 0;
+    virtual QByteArray serializeObject(const QObject *object, const QProtobufMetaObject &metaObject, const QProtobufMetaProperty &metaProperty) const = 0;
 
     /*!
      * \brief deserializeObject Deserializes buffer to an \a object
-     * \param[out] object Pointer to allocated object
+     * \param[out] object Pointer to pre-allocated object
+     * \param[in] metaObject Protobuf meta object information for given \a object. Static meta object usualy is used to get actual
+     *        property value and write new property to \a object
      * \param[in] it Pointer to beging of buffer where object serialized data is located
      * \param[in] propertyOrdering Ordering of properties for given \a object
-     * \param[in] metaProperty information about property to be serialized
-     * \param[in] metaObject Static meta object of given \a object. Static meta object usualy is used to get actual
-     *        property value and write new property to \a object
+     * \param[in] metaProperty Information about property to be serialized
      */
-    virtual void deserializeObject(QObject *object, QProtobufSelfcheckIterator &it, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject) const = 0;
+    virtual void deserializeObject(QObject *object, const QProtobufMetaObject &metaObject, QProtobufSelfcheckIterator &it) const = 0;
 
     /*!
      * \brief serializeListObject Method called to serialize \a object as a part of list property
      * \param[in] object Pointer to object that will be serialized
-     * \param[in] propertyOrdering Ordering of properties for given \a object
-     * \param[in] metaObject Static meta object of given \a object
-     * \param[in] metaProperty information about property to be serialized
+     * \param[in] metaObject Protobuf meta object information for given \a object
+     * \param[in] metaProperty Information about property to be serialized
      * \return Raw serialized data represented as byte array
      */
-    virtual QByteArray serializeListObject(const QObject *object, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject, const QProtobufMetaProperty &metaProperty) const = 0;
+    virtual QByteArray serializeListObject(const QObject *object, const QProtobufMetaObject &metaObject, const QProtobufMetaProperty &metaProperty) const = 0;
 
     /*!
      * \brief deserializeListObject Deserializes an \a object from byte stream as part of list property
-     * \param[out] object Pointer to allocated object, that will be appended to list property
-     * \param[in] it Pointer to beging of buffer where object serialized data is located
-     * \param[in] propertyOrdering Ordering of properties for given \a object
-     * \param[in] metaObject Static meta object of given \a object. Static meta object usualy is used to get actual
+     * \param[out] object Pointer to pre-allocated object, that will be appended to list property
+     * \param[in] Protobuf meta object information for given \a object. Static meta object usualy is used to get actual
      *        property value and write new property to \a object
+     * \param[in] it Pointer to beging of buffer where object serialized data is located
      */
-    virtual void deserializeListObject(QObject *object, QProtobufSelfcheckIterator &it, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject) const = 0;
+    virtual void deserializeListObject(QObject *object, const QProtobufMetaObject &metaObject, QProtobufSelfcheckIterator &it) const = 0;
 
     /*!
      * \brief serializeMapPair Serializes QMap pair of \a key and \a value to raw data buffer
      * \param[in] key Map key
      * \param[in] value Map value for given \a key
-     * \param[in] metaProperty information about property to be serialized
+     * \param[in] metaProperty Information about property to be serialized
      * \return Raw serialized data represented as byte array
      *
      * \see https://developers.google.com/protocol-buffers/docs/proto3#maps for details

+ 4 - 4
src/protobuf/qabstractprotobufserializer_p.h

@@ -78,7 +78,7 @@ template <typename T,
           typename std::enable_if_t<std::is_base_of<QObject, T>::value, int> = 0>
 void serializeObject(const QtProtobuf::QAbstractProtobufSerializer *serializer, const QVariant &value, const QtProtobuf::QProtobufMetaProperty &metaProperty, QByteArray &buffer) {
     Q_ASSERT_X(serializer != nullptr, "QAbstractProtobufSerializer", "serializer set is not setup");
-    buffer.append(serializer->serializeObject(value.value<T *>(), T::propertyOrdering, T::staticMetaObject, metaProperty));
+    buffer.append(serializer->serializeObject(value.value<T *>(), T::protobufMetaObject, metaProperty));
 }
 
 /*!
@@ -103,7 +103,7 @@ void serializeList(const QtProtobuf::QAbstractProtobufSerializer *serializer, co
             qProtoWarning() << "Null pointer in list";
             continue;
         }
-        buffer.append(serializer->serializeListObject(value.data(), V::propertyOrdering, V::staticMetaObject, metaProperty));
+        buffer.append(serializer->serializeListObject(value.data(), V::protobufMetaObject, metaProperty));
     }
 }
 
@@ -152,7 +152,7 @@ template <typename T,
 void deserializeObject(const QtProtobuf::QAbstractProtobufSerializer *serializer, QtProtobuf::QProtobufSelfcheckIterator &it, QVariant &to) {
     Q_ASSERT_X(serializer != nullptr, "QAbstractProtobufSerializer", "serializer set is not setup");
     T *value = new T;
-    serializer->deserializeObject(value, it, T::propertyOrdering, T::staticMetaObject);
+    serializer->deserializeObject(value, T::protobufMetaObject, it);
     to = QVariant::fromValue<T *>(value);
 }
 
@@ -169,7 +169,7 @@ void deserializeList(const QtProtobuf::QAbstractProtobufSerializer *serializer,
 
     V *newValue = new V;
     QList<QSharedPointer<V>> list = previous.value<QList<QSharedPointer<V>>>();
-    serializer->deserializeListObject(newValue, it, V::propertyOrdering, V::staticMetaObject);
+    serializer->deserializeListObject(newValue, V::protobufMetaObject, it);
     list.append(QSharedPointer<V>(newValue));
     previous.setValue(list);
 }

+ 10 - 13
src/protobuf/qprotobufjsonserializer.cpp

@@ -24,6 +24,7 @@
  */
 
 #include "qprotobufjsonserializer.h"
+#include "qprotobufmetaobject.h"
 #include "qprotobufmetaproperty.h"
 #include <QMetaProperty>
 
@@ -62,15 +63,15 @@ QProtobufJsonSerializer::QProtobufJsonSerializer() : d_ptr(new QProtobufJsonSeri
 QProtobufJsonSerializer::~QProtobufJsonSerializer() = default;
 
 
-QByteArray QProtobufJsonSerializer::serializeMessage(const QObject *object, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject) const
+QByteArray QProtobufJsonSerializer::serializeMessage(const QObject *object, const QProtobufMetaObject &metaObject) const
 {
     QByteArray result = "{";
 
-    for (const auto &field : propertyOrdering) {
+    for (const auto &field : metaObject.propertyOrdering) {
         int propertyIndex = field.second;
         int fieldIndex = field.first;
         Q_ASSERT_X(fieldIndex < 536870912 && fieldIndex > 0, "", "fieldIndex is out of range");
-        QMetaProperty metaProperty = metaObject.property(propertyIndex);
+        QMetaProperty metaProperty = metaObject.staticMetaObject.property(propertyIndex);
         const char *propertyName = metaProperty.name();
         const QVariant &propertyValue = object->property(propertyName);
         result.append(d_ptr->serializeProperty(propertyValue, QProtobufMetaProperty(metaProperty, fieldIndex)));
@@ -80,44 +81,40 @@ QByteArray QProtobufJsonSerializer::serializeMessage(const QObject *object, cons
     return result;
 }
 
-void QProtobufJsonSerializer::deserializeMessage(QObject *object, const QByteArray &data, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject) const
+void QProtobufJsonSerializer::deserializeMessage(QObject *object, const QProtobufMetaObject &metaObject, const QByteArray &data) const
 {
     Q_UNUSED(object)
     Q_UNUSED(data)
-    Q_UNUSED(propertyOrdering)
     Q_UNUSED(metaObject)
 }
 
-QByteArray QProtobufJsonSerializer::serializeObject(const QObject *object, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject, const QProtobufMetaProperty &/*metaProperty*/) const
+QByteArray QProtobufJsonSerializer::serializeObject(const QObject *object, const QProtobufMetaObject &metaObject, const QProtobufMetaProperty &/*metaProperty*/) const
 {
     QByteArray result = "{";
-    result.append(serializeMessage(object, propertyOrdering, metaObject));
+    result.append(serializeMessage(object, metaObject));
     result.append("}");
     return result;
 }
 
-void QProtobufJsonSerializer::deserializeObject(QObject *object, QProtobufSelfcheckIterator &it, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject) const
+void QProtobufJsonSerializer::deserializeObject(QObject *object, const QProtobufMetaObject &metaObject, QProtobufSelfcheckIterator &it) const
 {
     Q_UNUSED(object)
     Q_UNUSED(it)
-    Q_UNUSED(propertyOrdering)
     Q_UNUSED(metaObject)
 }
 
-QByteArray QProtobufJsonSerializer::serializeListObject(const QObject *object, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject, const QProtobufMetaProperty &metaProperty) const
+QByteArray QProtobufJsonSerializer::serializeListObject(const QObject *object, const QProtobufMetaObject &metaObject, const QProtobufMetaProperty &metaProperty) const
 {
     Q_UNUSED(object)
-    Q_UNUSED(propertyOrdering)
     Q_UNUSED(metaObject)
     Q_UNUSED(metaProperty)
     return QByteArray();
 }
 
-void QProtobufJsonSerializer::deserializeListObject(QObject *object, QProtobufSelfcheckIterator &it, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject) const
+void QProtobufJsonSerializer::deserializeListObject(QObject *object, const QProtobufMetaObject &metaObject, QProtobufSelfcheckIterator &it) const
 {
     Q_UNUSED(object)
     Q_UNUSED(it)
-    Q_UNUSED(propertyOrdering)
     Q_UNUSED(metaObject)
 }
 

+ 6 - 6
src/protobuf/qprotobufjsonserializer.h

@@ -41,14 +41,14 @@ public:
     ~QProtobufJsonSerializer();
 
 protected:
-    QByteArray serializeMessage(const QObject *object, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject) const  override;
-    void deserializeMessage(QObject *object, const QByteArray &data, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject) const override;
+    QByteArray serializeMessage(const QObject *object, const QProtobufMetaObject &metaObject) const  override;
+    void deserializeMessage(QObject *object, const QProtobufMetaObject &metaObject, const QByteArray &data) const override;
 
-    QByteArray serializeObject(const QObject *object, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject, const QProtobufMetaProperty &metaProperty) const override;
-    void deserializeObject(QObject *object, QProtobufSelfcheckIterator &it, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject) const override;
+    QByteArray serializeObject(const QObject *object, const QProtobufMetaObject &metaObject, const QProtobufMetaProperty &metaProperty) const override;
+    void deserializeObject(QObject *object, const QProtobufMetaObject &metaObject, QProtobufSelfcheckIterator &it) const override;
 
-    QByteArray serializeListObject(const QObject *object, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject, const QProtobufMetaProperty &metaProperty) const override;
-    void deserializeListObject(QObject *object, QProtobufSelfcheckIterator &it, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject) const override;
+    QByteArray serializeListObject(const QObject *object, const QProtobufMetaObject &metaObject, const QProtobufMetaProperty &metaProperty) const override;
+    void deserializeListObject(QObject *object, const QProtobufMetaObject &metaObject, QProtobufSelfcheckIterator &it) const override;
 
     QByteArray serializeMapPair(const QVariant &key, const QVariant &value, const QProtobufMetaProperty &metaProperty) const override;
     void deserializeMapPair(QVariant &key, QVariant &value, QProtobufSelfcheckIterator &it) const override;

+ 32 - 0
src/protobuf/qprotobufmetaobject.cpp

@@ -0,0 +1,32 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2019 Alexey Edelev <semlanik@gmail.com>
+ *
+ * This file is part of QtProtobuf project https://git.semlanik.org/semlanik/qtprotobuf
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this
+ * software and associated documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software, and
+ * to permit persons to whom the Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies
+ * or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
+ * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "qprotobufmetaobject.h"
+using namespace QtProtobuf;
+QProtobufMetaObject::QProtobufMetaObject(const QMetaObject &_staticMetaObject, const QProtobufPropertyOrdering &_propertyOrdering)
+    : staticMetaObject(_staticMetaObject)
+    , propertyOrdering(_propertyOrdering)
+{
+}

+ 44 - 0
src/protobuf/qprotobufmetaobject.h

@@ -0,0 +1,44 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2019 Alexey Edelev <semlanik@gmail.com>
+ *
+ * This file is part of QtProtobuf project https://git.semlanik.org/semlanik/qtprotobuf
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this
+ * software and associated documentation files (the "Software"), to deal in the Software
+ * without restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software, and
+ * to permit persons to whom the Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies
+ * or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
+ * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#pragma once
+
+#include "qtprotobufglobal.h"
+#include "qtprotobuftypes.h"
+
+#include <QMetaObject>
+namespace QtProtobuf {
+
+class Q_PROTOBUF_EXPORT QProtobufMetaObject
+{
+public:
+    QProtobufMetaObject(const QMetaObject &staticMetaObject, const QProtobufPropertyOrdering &propertyOrdering);
+    const QMetaObject &staticMetaObject;
+    const QProtobufPropertyOrdering &propertyOrdering;
+private:
+    QProtobufMetaObject();
+};
+
+}

+ 1 - 0
src/protobuf/qprotobufmetaproperty.h

@@ -40,4 +40,5 @@ private:
     QProtobufMetaProperty();
     int m_fieldIndex;
 };
+
 }

+ 2 - 0
src/protobuf/qprotobufobject.h

@@ -26,6 +26,7 @@
 #pragma once
 
 #include "qabstractprotobufserializer.h"
+#include "qprotobufmetaobject.h"
 #include <unordered_map>
 
 /*!
@@ -52,6 +53,7 @@
 #define Q_PROTOBUF_OBJECT\
     public:\
         static const QtProtobuf::QProtobufPropertyOrdering propertyOrdering;\
+        static const QtProtobuf::QProtobufMetaObject protobufMetaObject;\
     private:
 
 /*! \} */

+ 18 - 17
src/protobuf/qprotobufserializer.cpp

@@ -27,6 +27,7 @@
 #include "qprotobufserializer_p.h"
 
 #include "qprotobufmetaproperty.h"
+#include "qprotobufmetaobject.h"
 
 using namespace QtProtobuf;
 
@@ -107,14 +108,14 @@ QProtobufSerializer::QProtobufSerializer() : d_ptr(new QProtobufSerializerPrivat
     QProtobufSerializerPrivate::wrapSerializer<QByteArrayList, QProtobufSerializerPrivate::serializeListType, QProtobufSerializerPrivate::deserializeList<QByteArray>, LengthDelimited>();
 }
 
-QByteArray QProtobufSerializer::serializeMessage(const QObject *object, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject) const
+QByteArray QProtobufSerializer::serializeMessage(const QObject *object, const QProtobufMetaObject &metaObject) const
 {
     QByteArray result;
-    for (const auto &field : propertyOrdering) {
+    for (const auto &field : metaObject.propertyOrdering) {
         int propertyIndex = field.second;
         int fieldIndex = field.first;
         Q_ASSERT_X(fieldIndex < 536870912 && fieldIndex > 0, "", "fieldIndex is out of range");
-        QMetaProperty metaProperty = metaObject.property(propertyIndex);
+        QMetaProperty metaProperty = metaObject.staticMetaObject.property(propertyIndex);
         const char *propertyName = metaProperty.name();
         const QVariant &propertyValue = object->property(propertyName);
         result.append(d_ptr->serializeProperty(propertyValue, QProtobufMetaProperty(metaProperty, fieldIndex)));
@@ -123,34 +124,34 @@ QByteArray QProtobufSerializer::serializeMessage(const QObject *object, const QP
     return result;
 }
 
-void QProtobufSerializer::deserializeMessage(QObject *object, const QByteArray &data, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject) const
+void QProtobufSerializer::deserializeMessage(QObject *object, const QProtobufMetaObject &metaObject, const QByteArray &data) const
 {
     for (QProtobufSelfcheckIterator it(data); it != data.end();) {
-        d_ptr->deserializeProperty(object, it, propertyOrdering, metaObject);
+        d_ptr->deserializeProperty(object, metaObject, it);
     }
 }
 
-QByteArray QProtobufSerializer::serializeObject(const QObject *object, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject, const QProtobufMetaProperty &metaProperty) const
+QByteArray QProtobufSerializer::serializeObject(const QObject *object, const QProtobufMetaObject &metaObject, const QProtobufMetaProperty &metaProperty) const
 {
     QByteArray result = QProtobufSerializerPrivate::encodeHeader(metaProperty.protoFieldIndex(), LengthDelimited);
-    result.append(QProtobufSerializerPrivate::prependLengthDelimitedSize(serializeMessage(object, propertyOrdering, metaObject)));
+    result.append(QProtobufSerializerPrivate::prependLengthDelimitedSize(serializeMessage(object, metaObject)));
     return result;
 }
 
-void QProtobufSerializer::deserializeObject(QObject *object, QProtobufSelfcheckIterator &it, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject) const
+void QProtobufSerializer::deserializeObject(QObject *object, const QProtobufMetaObject &metaObject, QProtobufSelfcheckIterator &it) const
 {
     QByteArray array = QProtobufSerializerPrivate::deserializeLengthDelimited(it);
-    deserializeMessage(object, array, propertyOrdering, metaObject);
+    deserializeMessage(object, metaObject, array);
 }
 
-QByteArray QProtobufSerializer::serializeListObject(const QObject *object, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject, const QProtobufMetaProperty &metaProperty) const
+QByteArray QProtobufSerializer::serializeListObject(const QObject *object, const QProtobufMetaObject &metaObject, const QProtobufMetaProperty &metaProperty) const
 {
-    return serializeObject(object, propertyOrdering, metaObject, metaProperty);
+    return serializeObject(object, metaObject, metaProperty);
 }
 
-void QProtobufSerializer::deserializeListObject(QObject *object, QProtobufSelfcheckIterator &it, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject) const
+void QProtobufSerializer::deserializeListObject(QObject *object, const QProtobufMetaObject &metaObject, QProtobufSelfcheckIterator &it) const
 {
-    deserializeObject(object, it, propertyOrdering, metaObject);
+    deserializeObject(object, metaObject, it);
 }
 
 QByteArray QProtobufSerializer::serializeMapPair(const QVariant &key, const QVariant &value, const QProtobufMetaProperty &metaProperty) const
@@ -264,7 +265,7 @@ QByteArray QProtobufSerializerPrivate::serializeProperty(const QVariant &propert
     return result;
 }
 
-void QProtobufSerializerPrivate::deserializeProperty(QObject *object, QProtobufSelfcheckIterator &it, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject)
+void QProtobufSerializerPrivate::deserializeProperty(QObject *object, const QProtobufMetaObject &metaObject, QProtobufSelfcheckIterator &it)
 {
     //Each iteration we expect iterator is setup to beginning of next chunk
     int fieldNumber = QtProtobufPrivate::NotUsedFieldIndex;
@@ -276,8 +277,8 @@ void QProtobufSerializerPrivate::deserializeProperty(QObject *object, QProtobufS
                               "Seems stream is broken");
     }
 
-    auto propertyNumberIt = propertyOrdering.find(fieldNumber);
-    if (propertyNumberIt == std::end(propertyOrdering)) {
+    auto propertyNumberIt = metaObject.propertyOrdering.find(fieldNumber);
+    if (propertyNumberIt == std::end(metaObject.propertyOrdering)) {
         auto bytesCount = QProtobufSerializerPrivate::skipSerializedFieldBytes(it, wireType);
         qProtoWarning() << "Message received contains unexpected/optional field. WireType:" << wireType
                         << ", field number: " << fieldNumber << "Skipped:" << (bytesCount + 1) << "bytes";
@@ -285,7 +286,7 @@ void QProtobufSerializerPrivate::deserializeProperty(QObject *object, QProtobufS
     }
 
     int propertyIndex = propertyNumberIt->second;
-    QMetaProperty metaProperty = metaObject.property(propertyIndex);
+    QMetaProperty metaProperty = metaObject.staticMetaObject.property(propertyIndex);
 
     qProtoDebug() << __func__ << " wireType: " << wireType << " metaProperty: " << metaProperty.typeName()
                   << "currentByte:" << QString::number((*it), 16);

+ 6 - 6
src/protobuf/qprotobufserializer.h

@@ -42,14 +42,14 @@ public:
     ~QProtobufSerializer();
 
 protected:
-    QByteArray serializeMessage(const QObject *object, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject) const override;
-    void deserializeMessage(QObject *object, const QByteArray &data, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject) const override;
+    QByteArray serializeMessage(const QObject *object, const QProtobufMetaObject &metaObject) const override;
+    void deserializeMessage(QObject *object, const QProtobufMetaObject &metaObject, const QByteArray &data) const override;
 
-    QByteArray serializeObject(const QObject *object, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject, const QProtobufMetaProperty &metaProperty) const override;
-    void deserializeObject(QObject *object, QProtobufSelfcheckIterator &it, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject) const override;
+    QByteArray serializeObject(const QObject *object, const QProtobufMetaObject &metaObject, const QProtobufMetaProperty &metaProperty) const override;
+    void deserializeObject(QObject *object, const QProtobufMetaObject &metaObject, QProtobufSelfcheckIterator &it) const override;
 
-    QByteArray serializeListObject(const QObject *object, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject, const QProtobufMetaProperty &metaProperty) const override;
-    void deserializeListObject(QObject *object, QProtobufSelfcheckIterator &it, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject) const override;
+    QByteArray serializeListObject(const QObject *object, const QProtobufMetaObject &metaObject, const QProtobufMetaProperty &metaProperty) const override;
+    void deserializeListObject(QObject *object, const QProtobufMetaObject &metaObject, QProtobufSelfcheckIterator &it) const override;
 
     QByteArray serializeMapPair(const QVariant &key, const QVariant &value, const QProtobufMetaProperty &metaProperty) const override;
     void deserializeMapPair(QVariant &key, QVariant &value, QProtobufSelfcheckIterator &it) const override;

+ 1 - 1
src/protobuf/qprotobufserializer_p.h

@@ -433,7 +433,7 @@ public:
     static void skipLengthDelimited(QProtobufSelfcheckIterator &it);
 
     QByteArray serializeProperty(const QVariant &propertyValue, const QProtobufMetaProperty &metaProperty);
-    void deserializeProperty(QObject *object, QProtobufSelfcheckIterator &it, const QProtobufPropertyOrdering &propertyOrdering, const QMetaObject &metaObject);
+    void deserializeProperty(QObject *object, const QProtobufMetaObject &metaObject, QProtobufSelfcheckIterator &it);
 
     static SerializerRegistry handlers;
 private:

+ 2 - 2
src/protobuf/qprotobufserializerregistry.cpp

@@ -31,7 +31,7 @@
 #include <QHash>
 
 //TODO: remove once migration to 5.14 as minimum required version is completed
-#if QT_VERSION < 0x051300
+#if QT_VERSION < 0x050D00
 namespace std {
   template<> struct hash<QString> {
     std::size_t operator()(const QString &s) const {
@@ -64,7 +64,7 @@ QProtobufSerializerRegistry::~QProtobufSerializerRegistry() = default;
 
 std::shared_ptr<QAbstractProtobufSerializer> QProtobufSerializerRegistry::getSerializer(const QString &id)
 {
-       return d->serializers.at(id); //throws
+    return d->serializers.at(id); //throws
 }
 
 std::unique_ptr<QAbstractProtobufSerializer> QProtobufSerializerRegistry::acquireSerializer(const QString &/*id*/)