Browse Source

Remove ProtobufObject

- Make serialization of QObject independend of ProtobufObject onlu fields numbering matters
- Fix build
Alexey Edelev 6 years ago
parent
commit
53c0282505

+ 8 - 1
src/generator/protobufclassgenerator.cpp

@@ -69,7 +69,6 @@ void ProtobufClassGenerator::printCopyFunctionality()
     Outdent();
 
     mPrinter.Print(Templates::SimpleBlockEnclosureTemplate);
-
 }
 
 void ProtobufClassGenerator::printMoveSemantic()
@@ -570,6 +569,13 @@ std::set<std::string> ProtobufClassGenerator::extractModels() const
     return std::move(extractedModels);
 }
 
+void ProtobufClassGenerator::printSerializers()
+{
+    Indent();
+    mPrinter.Print({{"classname", mClassName}}, Templates::SerializersTemplate);
+    Outdent();
+}
+
 void ProtobufClassGenerator::run()
 {
     printPreamble();
@@ -580,6 +586,7 @@ void ProtobufClassGenerator::run()
     printPublic();
     printRegisterTypes();
     printFieldsOrderingDefinition();
+    printSerializers();
     printPrivate();
     printClassMembers();
     encloseClass();

+ 1 - 0
src/generator/protobufclassgenerator.h

@@ -72,6 +72,7 @@ public:
     void printMaps();
     void printMapsMetaTypesDeclaration();
     void printLocalEmumsMetaTypesDeclaration();
+    void printSerializers();
 
     std::set<std::string> extractModels() const;
 

+ 1 - 1
src/generator/protobufsourcegenerator.cpp

@@ -69,7 +69,7 @@ void ProtobufSourceGenerator::printRegisterBody()
                              Templates::MapSerializationRegisterTemplate);
         }
     }
-
+    mPrinter.Print({{"classname", mClassName}}, Templates::RegisterSerializersTemplate);
     Outdent();
     mPrinter.Print(Templates::SimpleBlockEnclosureTemplate);
     Outdent();

+ 9 - 6
src/generator/templates.cpp

@@ -29,7 +29,7 @@ using namespace qtprotobuf::generator;
 
 const char *Templates::DefaultProtobufIncludesTemplate = "#include <QMetaType>\n"
                                                          "#include <QList>\n"
-                                                         "#include <protobufobject.h>\n"
+                                                         "#include <qprotobufobject.h>\n"
                                                          "#include <unordered_map>\n\n";
 
 const char *Templates::GlobalEnumClassNameTemplate = "GlobalEnums";
@@ -51,7 +51,7 @@ const char *Templates::ComplexTypeRegistrationTemplate = "void $classname$::regi
                                                          "        qRegisterMetaType<$classname$List>(\"$classname$List\");\n"
                                                          "        qRegisterMetaType<$classname$>(\"$namespaces$::$classname$\");\n"
                                                          "        qRegisterMetaType<$classname$List>(\"$namespaces$::$classname$List\");\n"
-                                                         "        registerSerializers();\n";
+                                                         "";
 const char *Templates::ComplexListTypeUsingTemplate = "using $classname$List = QList<$classname$>;\n";
 const char *Templates::MapTypeUsingTemplate = "using $classname$ = QMap<$key$, $value$>;\n";
 
@@ -62,7 +62,7 @@ const char *Templates::UsingNamespaceTemplate = "using namespace $namespace$;\n"
 const char *Templates::NonProtoClassDefinitionTemplate = "\nclass $classname$ : public QObject\n"
                                                          "{\n"
                                                          "    Q_OBJECT\n";
-const char *Templates::ProtoClassDefinitionTemplate = "\nclass $classname$ final : public qtprotobuf::ProtobufObject<$classname$>\n"
+const char *Templates::ProtoClassDefinitionTemplate = "\nclass $classname$ final : public QObject\n"
                                                  "{\n"
                                                  "    Q_OBJECT\n";
 
@@ -74,10 +74,10 @@ const char *Templates::PublicBlockTemplate = "\npublic:\n";
 const char *Templates::PrivateBlockTemplate = "\nprivate:\n";
 const char *Templates::EnumDefinitionTemplate = "enum $enum$ {\n";
 const char *Templates::EnumFieldTemplate = "$enumvalue$ = $value$,\n";
-const char *Templates::ProtoConstructorTemplate = "$classname$($parameter_list$QObject *parent = nullptr) : ProtobufObject(parent)";
+const char *Templates::ProtoConstructorTemplate = "$classname$($parameter_list$QObject *parent = nullptr) : QObject(parent)";
 const char *Templates::ConstructorTemplate = "$classname$();\n";
-const char *Templates::CopyConstructorTemplate = "$classname$(const $classname$ &other) : ProtobufObject() {\n";
-const char *Templates::MoveConstructorTemplate = "$classname$($classname$ &&other) : ProtobufObject() {\n";
+const char *Templates::CopyConstructorTemplate = "$classname$(const $classname$ &other) : QObject() {\n";
+const char *Templates::MoveConstructorTemplate = "$classname$($classname$ &&other) : QObject() {\n";
 const char *Templates::CopyFieldTemplate = "m_$property_name$ = other.m_$property_name$;\n";
 const char *Templates::MoveComplexFieldTemplate = "m_$property_name$ = std::move(other.m_$property_name$);\n";
 const char *Templates::MoveFieldTemplate = "m_$property_name$ = std::exchange(other.m_$property_name$, 0);\n";
@@ -158,6 +158,9 @@ const char *Templates::ClientMethodDefinitionAsyncTemplate = "\nbool $classname$
                                                              "    //TODO: call transport method to serialize this method\n"
                                                              "    return false;\n"
                                                              "}\n";
+const char *Templates::SerializersTemplate = "QByteArray serialize() const { return qtprotobuf::ProtobufObjectPrivate::serialize<$classname$>(this); }\n"
+                                     "void deserialize(const QByteArray &array) { qtprotobuf::ProtobufObjectPrivate::deserialize<$classname$>(this, array); }";
+const char *Templates::RegisterSerializersTemplate = "qtprotobuf::ProtobufObjectPrivate::registerSerializers<$classname$>();";
 
 const std::unordered_map<::google::protobuf::FieldDescriptor::Type, std::string> Templates::TypeReflection = {
     {::google::protobuf::FieldDescriptor::TYPE_DOUBLE, "double"},

+ 2 - 1
src/generator/templates.h

@@ -94,7 +94,8 @@ public:
     static const char *RegisterMetaTypeTemplateNoNamespace;
     static const char *QEnumTemplate;
     static const char *MapSerializationRegisterTemplate;
-
+    static const char *SerializersTemplate;
+    static const char *RegisterSerializersTemplate;
     //Service templates
     static const char *ConstructorDefinitionSyncTemplate;
 

+ 3 - 4
src/protobuf/CMakeLists.txt

@@ -9,14 +9,13 @@ if(Qt5_POSITION_INDEPENDENT_CODE)
 endif()
 
 file(GLOB SOURCES
-    protobufobject_p.cpp
+    qprotobufobject_p.cpp
     qtprotobuf.cpp
     qtprotobuflogging.cpp)
 
 file(GLOB HEADERS
-    protobufobject_p.inc
-    protobufobject_p.h
-    protobufobject.h
+    qprotobufobject_p.h
+    qprotobufobject.h
     qtprotobuftypes.h
     qtprotobuf.h)
 

+ 0 - 123
src/protobuf/protobufobject.inc

@@ -1,123 +0,0 @@
-/*
- * 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 "protobufobject_p.h"
-
-#include <QMetaObject>
-#include <QMetaProperty>
-
-#include <qtprotobuftypes.h>
-#include <qtprotobuflogging.h>
-
-#define ASSERT_FIELD_NUMBER(X) Q_ASSERT_X(X < 128 && X > 0, T::staticMetaObject.className(), "fieldIndex is out of range")
-
-namespace qtprotobuf {
-
-template<typename T>
-QByteArray ProtobufObject<T>::serialize() const {
-    qProtoDebug() << T::staticMetaObject.className() << "serialize";
-
-    QByteArray result;
-    const QObject *instance = static_cast<const QObject *>(this);
-    for (auto field : T::propertyOrdering) {
-        int propertyIndex = field.second;
-        int fieldIndex = field.first;
-        ASSERT_FIELD_NUMBER(fieldIndex);
-        QMetaProperty metaProperty = T::staticMetaObject.property(propertyIndex);
-        const char *propertyName = metaProperty.name();
-        const QVariant &propertyValue = instance->property(propertyName);
-        result.append(ProtobufObjectPrivate::serializeValue(propertyValue, fieldIndex, metaProperty));
-    }
-
-    return result;
-}
-
-template<typename T>
-void ProtobufObject<T>::deserialize(const QByteArray &array) {
-    qProtoDebug() << T::staticMetaObject.className() << "deserialize";
-
-    for (QByteArray::const_iterator it = array.begin(); it != array.end();) {
-        //Each iteration we expect iterator is setup to beginning of next chunk
-        int fieldNumber = NotUsedFieldIndex;
-        WireTypes wireType = UnknownWireType;
-        if (!ProtobufObjectPrivate::decodeHeaderByte(*it, fieldNumber, wireType)) {
-            qProtoCritical() << "Message received doesn't contains valid header byte. "
-                           "Trying next, but seems stream is broken" << QString::number((*it), 16);
-            ++it;
-            continue;
-        }
-
-        auto propertyNumberIt = T::propertyOrdering.find(fieldNumber);
-        if (propertyNumberIt == std::end(T::propertyOrdering)) {
-            ++it;
-            qProtoCritical() << "Message received contains invalid field number. "
-                           "Trying next, but seems stream is broken";
-            continue;
-        }
-
-        int propertyIndex = propertyNumberIt->second;
-        QMetaProperty metaProperty = T::staticMetaObject.property(propertyIndex);
-
-        ++it;
-        ProtobufObjectPrivate::deserializeProperty(this, wireType, metaProperty, it);
-    }
-}
-
-template<typename T>
-void ProtobufObject<T>::registerSerializers() {
-    ProtobufObjectPrivate::wrapSerializer<T>(serializeComplexType, deserializeComplexType, LengthDelimited);
-    ProtobufObjectPrivate::serializers[qMetaTypeId<QList<T>>()] = {ProtobufObjectPrivate::Serializer(serializeComplexListType),
-            ProtobufObjectPrivate::Deserializer(deserializeComplexListType), LengthDelimited};
-}
-
-template<typename T>
-QByteArray ProtobufObject<T>::serializeComplexType(const T &value, int &/*outFieldIndex*/) {
-    return ProtobufObjectPrivate::serializeLengthDelimited(value.serialize());
-}
-
-template<typename T>
-QVariant ProtobufObject<T>::deserializeComplexType(QByteArray::const_iterator &it) {
-    T value;
-    value.deserialize(ProtobufObjectPrivate::deserializeLengthDelimited(it));
-    return QVariant::fromValue<T>(value);
-}
-
-template<typename T>
-QByteArray ProtobufObject<T>::serializeComplexListType(const QVariant &listValue, int &outFieldIndex) {
-    QList<T> list = listValue.value<QList<T>>();
-    return ProtobufObjectPrivate::serializeListType(list, outFieldIndex);
-}
-
-template<typename T>
-void ProtobufObject<T>::deserializeComplexListType(QByteArray::const_iterator &it, QVariant &previous) {
-    QList<T> previousList = previous.value<QList<T>>();
-    QVariant newMember = ProtobufObjectPrivate::deserializeList<T>(it);
-    previousList.append(newMember.value<T>());
-    previous.setValue(previousList);
-}
-
-}

+ 1 - 27
src/protobuf/protobufobject.h → src/protobuf/qprotobufobject.h

@@ -25,30 +25,4 @@
 
 #pragma once
 
-#include <QObject>
-#include <QByteArray>
-#include <QVariant>
-
-namespace qtprotobuf {
-
-template <typename T>
-class ProtobufObject : public QObject
-{
-public:
-    explicit ProtobufObject(QObject *parent = nullptr) {}
-
-    QByteArray serialize() const;
-    void deserialize(const QByteArray &array);
-
-protected:
-    static void registerSerializers();
-
-private:
-    static QByteArray serializeComplexType(const T &variantValue, int &outFieldIndex);
-    static QVariant deserializeComplexType(QByteArray::const_iterator &it);
-    static QByteArray serializeComplexListType(const QVariant &listValue, int &outFieldIndex);
-    static void deserializeComplexListType(QByteArray::const_iterator &it, QVariant &previous);
-};
-
-}
-#include "protobufobject.inc"
+#include "qprotobufobject_p.h"

+ 1 - 1
src/protobuf/protobufobject_p.cpp → src/protobuf/qprotobufobject_p.cpp

@@ -23,7 +23,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#include "protobufobject_p.h"
+#include "qprotobufobject_p.h"
 
 using namespace qtprotobuf;
 

+ 84 - 0
src/protobuf/protobufobject_p.h → src/protobuf/qprotobufobject_p.h

@@ -38,6 +38,8 @@
 #include <qtprotobuftypes.h>
 #include <qtprotobuflogging.h>
 
+#define ASSERT_FIELD_NUMBER(X) Q_ASSERT_X(X < 128 && X > 0, T::staticMetaObject.className(), "fieldIndex is out of range")
+
 namespace qtprotobuf {
 
 template<typename V>
@@ -465,6 +467,88 @@ public:
         serializer.deserializer(it, value);
         return value.value<T>();
     }
+    //-----------------------Functions to work with objects------------------------
+    template<typename T>
+    static void registerSerializers() {
+        ProtobufObjectPrivate::wrapSerializer<T>(serializeComplexType<T>, deserializeComplexType<T>, LengthDelimited);
+        ProtobufObjectPrivate::serializers[qMetaTypeId<QList<T>>()] = {ProtobufObjectPrivate::Serializer(serializeComplexListType<T>),
+                ProtobufObjectPrivate::Deserializer(deserializeComplexListType<T>), LengthDelimited};
+    }
+
+    template<typename T>
+    static QByteArray serializeComplexType(const T &value, int &/*outFieldIndex*/) {
+        return ProtobufObjectPrivate::serializeLengthDelimited(value.serialize());
+    }
+
+    template<typename T>
+    static QVariant deserializeComplexType(QByteArray::const_iterator &it) {
+        T value;
+        value.deserialize(ProtobufObjectPrivate::deserializeLengthDelimited(it));
+        return QVariant::fromValue<T>(value);
+    }
+
+    template<typename T>
+    static QByteArray serializeComplexListType(const QVariant &listValue, int &outFieldIndex) {
+        QList<T> list = listValue.value<QList<T>>();
+        return ProtobufObjectPrivate::serializeListType(list, outFieldIndex);
+    }
+
+    template<typename T>
+    static void deserializeComplexListType(QByteArray::const_iterator &it, QVariant &previous) {
+        QList<T> previousList = previous.value<QList<T>>();
+        QVariant newMember = ProtobufObjectPrivate::deserializeList<T>(it);
+        previousList.append(newMember.value<T>());
+        previous.setValue(previousList);
+    }
+
+    template<typename T>
+    static QByteArray serialize(const QObject *object) {
+        qProtoDebug() << T::staticMetaObject.className() << "serialize";
+
+        QByteArray result;
+        for (auto field : T::propertyOrdering) {
+            int propertyIndex = field.second;
+            int fieldIndex = field.first;
+            ASSERT_FIELD_NUMBER(fieldIndex);
+            QMetaProperty metaProperty = T::staticMetaObject.property(propertyIndex);
+            const char *propertyName = metaProperty.name();
+            const QVariant &propertyValue = object->property(propertyName);
+            result.append(ProtobufObjectPrivate::serializeValue(propertyValue, fieldIndex, metaProperty));
+        }
+
+        return result;
+    }
+
+    template<typename T>
+    static void deserialize(QObject* object, const QByteArray &array) {
+        qProtoDebug() << T::staticMetaObject.className() << "deserialize";
+
+        for (QByteArray::const_iterator it = array.begin(); it != array.end();) {
+            //Each iteration we expect iterator is setup to beginning of next chunk
+            int fieldNumber = NotUsedFieldIndex;
+            WireTypes wireType = UnknownWireType;
+            if (!ProtobufObjectPrivate::decodeHeaderByte(*it, fieldNumber, wireType)) {
+                qProtoCritical() << "Message received doesn't contains valid header byte. "
+                               "Trying next, but seems stream is broken" << QString::number((*it), 16);
+                ++it;
+                continue;
+            }
+
+            auto propertyNumberIt = T::propertyOrdering.find(fieldNumber);
+            if (propertyNumberIt == std::end(T::propertyOrdering)) {
+                ++it;
+                qProtoCritical() << "Message received contains invalid field number. "
+                               "Trying next, but seems stream is broken";
+                continue;
+            }
+
+            int propertyIndex = propertyNumberIt->second;
+            QMetaProperty metaProperty = T::staticMetaObject.property(propertyIndex);
+
+            ++it;
+            ProtobufObjectPrivate::deserializeProperty(object, wireType, metaProperty, it);
+        }
+    }
 };
 
 

+ 1 - 1
src/protobuf/qtprotobuf.h

@@ -26,7 +26,7 @@
 #pragma once
 
 #include <qtprotobuftypes.h>
-#include <protobufobject.h>
+#include <qprotobufobject.h>
 #include <qtprotobuflogging.h>
 #include <QDebug>
 

+ 1 - 14
tests/CMakeLists.txt

@@ -33,7 +33,7 @@ if(Qt5_POSITION_INDEPENDENT_CODE)
     set(CMAKE_POSITION_INDEPENDENT_CODE ON)
 endif()
 
-set(EXPECTED_GENERATED_HEADERS 
+set(EXPECTED_GENERATED_HEADERS
     complexmessage.h
     externalcomplexmessage.h
     globalenums.h
@@ -67,7 +67,6 @@ set(EXPECTED_GENERATED_HEADERS
     simplefixed32sint32mapmessage.h
     simplefixed32sint64mapmessage.h
     simplefixed32stringmapmessage.h
-    simplefixed32suint32mapmessage.h
     simplefixed32uint32mapmessage.h
     simplefixed32uint64mapmessage.h
     simplefixed64complexmessagemapmessage.h
@@ -76,7 +75,6 @@ set(EXPECTED_GENERATED_HEADERS
     simplefixed64sint32mapmessage.h
     simplefixed64sint64mapmessage.h
     simplefixed64stringmapmessage.h
-    simplefixed64suint32mapmessage.h
     simplefixed64uint32mapmessage.h
     simplefixed64uint64mapmessage.h
     simplefixedint32message.h
@@ -88,7 +86,6 @@ set(EXPECTED_GENERATED_HEADERS
     simpleint32sint32mapmessage.h
     simpleint32sint64mapmessage.h
     simpleint32stringmapmessage.h
-    simpleint32suint32mapmessage.h
     simpleint32uint32mapmessage.h
     simpleint32uint64mapmessage.h
     simpleint64complexmessagemapmessage.h
@@ -98,7 +95,6 @@ set(EXPECTED_GENERATED_HEADERS
     simpleint64sint32mapmessage.h
     simpleint64sint64mapmessage.h
     simpleint64stringmapmessage.h
-    simpleint64suint32mapmessage.h
     simpleint64uint32mapmessage.h
     simpleint64uint64mapmessage.h
     simpleintmessage.h
@@ -108,7 +104,6 @@ set(EXPECTED_GENERATED_HEADERS
     simplesfixed32sint32mapmessage.h
     simplesfixed32sint64mapmessage.h
     simplesfixed32stringmapmessage.h
-    simplesfixed32suint32mapmessage.h
     simplesfixed32uint32mapmessage.h
     simplesfixed32uint64mapmessage.h
     simplesfixed64complexmessagemapmessage.h
@@ -117,7 +112,6 @@ set(EXPECTED_GENERATED_HEADERS
     simplesfixed64sint32mapmessage.h
     simplesfixed64sint64mapmessage.h
     simplesfixed64stringmapmessage.h
-    simplesfixed64suint32mapmessage.h
     simplesfixed64uint32mapmessage.h
     simplesfixed64uint64mapmessage.h
     simplesfixedint32message.h
@@ -125,11 +119,9 @@ set(EXPECTED_GENERATED_HEADERS
     simplesint32complexmessagemapmessage.h
     simplesint32int32mapmessage.h
     simplesint32int64mapmessage.h
-    simplesint32mapmessage.h
     simplesint32sint32mapmessage.h
     simplesint32sint64mapmessage.h
     simplesint32stringmapmessage.h
-    simplesint32suint32mapmessage.h
     simplesint32uint32mapmessage.h
     simplesint32uint64mapmessage.h
     simplesint64complexmessagemapmessage.h
@@ -139,19 +131,16 @@ set(EXPECTED_GENERATED_HEADERS
     simplesint64sint32mapmessage.h
     simplesint64sint64mapmessage.h
     simplesint64stringmapmessage.h
-    simplesint64suint32mapmessage.h
     simplesint64uint32mapmessage.h
     simplesint64uint64mapmessage.h
     simplesintmessage.h
     simplestringcomplexmessagemapmessage.h
     simplestringint32mapmessage.h
     simplestringint64mapmessage.h
-    simplestringmapmessage.h
     simplestringmessage.h
     simplestringsint32mapmessage.h
     simplestringsint64mapmessage.h
     simplestringstringmapmessage.h
-    simplestringsuint32mapmessage.h
     simplestringuint32mapmessage.h
     simplestringuint64mapmessage.h
     simpleuint32complexmessagemapmessage.h
@@ -160,7 +149,6 @@ set(EXPECTED_GENERATED_HEADERS
     simpleuint32sint32mapmessage.h
     simpleuint32sint64mapmessage.h
     simpleuint32stringmapmessage.h
-    simpleuint32suint32mapmessage.h
     simpleuint32uint32mapmessage.h
     simpleuint32uint64mapmessage.h
     simpleuint64complexmessagemapmessage.h
@@ -170,7 +158,6 @@ set(EXPECTED_GENERATED_HEADERS
     simpleuint64sint32mapmessage.h
     simpleuint64sint64mapmessage.h
     simpleuint64stringmapmessage.h
-    simpleuint64suint32mapmessage.h
     simpleuint64uint32mapmessage.h
     simpleuint64uint64mapmessage.h
     simpleuintmessage.h

+ 28 - 28
tests/simpletest.cpp

@@ -63,8 +63,8 @@
 #include "repeatedfixedint64message.h"
 #include "repeatedsfixedint64message.h"
 #include "repeatedexternalcomplexmessage.h"
-#include "simplestringmapmessage.h"
-#include "simplesint32mapmessage.h"
+#include "simplesint32stringmapmessage.h"
+#include "simplestringstringmapmessage.h"
 
 #include "globalenums.h"
 #include "qtprotobuf.h"
@@ -632,40 +632,40 @@ TEST_F(SimpleTest, StepChildEnumListMessageTest)
 }
 
 
-TEST_F(SimpleTest, SimpleSInt32MapMessage)
+TEST_F(SimpleTest, SimpleSInt32StringMapMessageTest)
 {
     const char* propertyName = "mapField";
-    SimpleSInt32MapMessage::registerTypes();
-    SimpleSInt32MapMessage test;
-    ASSERT_TRUE(QMetaType::isRegistered(qMetaTypeId<SimpleSInt32MapMessage::MapFieldEntry>()));
-    int propertyNumber = SimpleSInt32MapMessage::propertyOrdering.at(1); //See simpletest.proto
-    ASSERT_STREQ(SimpleSInt32MapMessage::staticMetaObject.property(propertyNumber).typeName(), "SimpleSInt32MapMessage::MapFieldEntry");
-    ASSERT_EQ(SimpleSInt32MapMessage::staticMetaObject.property(propertyNumber).userType(), qMetaTypeId<SimpleSInt32MapMessage::MapFieldEntry>());
-    ASSERT_STREQ(SimpleSInt32MapMessage::staticMetaObject.property(propertyNumber).name(), propertyName);
-    SimpleSInt32MapMessage::MapFieldEntry testMap = {{10, {"Some 10"}}, {0, {"Some 0"}}, {44, {"Some 44"}}};
+    SimpleSInt32StringMapMessage::registerTypes();
+    SimpleSInt32StringMapMessage test;
+    ASSERT_TRUE(QMetaType::isRegistered(qMetaTypeId<SimpleSInt32StringMapMessage::MapFieldEntry>()));
+    int propertyNumber = SimpleSInt32StringMapMessage::propertyOrdering.at(1); //See simpletest.proto
+    ASSERT_STREQ(SimpleSInt32StringMapMessage::staticMetaObject.property(propertyNumber).typeName(), "SimpleSInt32StringMapMessage::MapFieldEntry");
+    ASSERT_EQ(SimpleSInt32StringMapMessage::staticMetaObject.property(propertyNumber).userType(), qMetaTypeId<SimpleSInt32StringMapMessage::MapFieldEntry>());
+    ASSERT_STREQ(SimpleSInt32StringMapMessage::staticMetaObject.property(propertyNumber).name(), propertyName);
+    SimpleSInt32StringMapMessage::MapFieldEntry testMap = {{10, {"Some 10"}}, {0, {"Some 0"}}, {44, {"Some 44"}}};
     test.setMapField(testMap);
-    ASSERT_TRUE(test.property(propertyName).value<SimpleSInt32MapMessage::MapFieldEntry>() == testMap);
+    ASSERT_TRUE(test.property(propertyName).value<SimpleSInt32StringMapMessage::MapFieldEntry>() == testMap);
     ASSERT_TRUE(test.mapField() == testMap);
-    ASSERT_STREQ(test.mapField()[10].testFieldString().toStdString().c_str(), "Some 10");
-    ASSERT_STREQ(test.mapField()[0].testFieldString().toStdString().c_str(), "Some 0");
-    ASSERT_STREQ(test.mapField()[44].testFieldString().toStdString().c_str(), "Some 44");
+    ASSERT_STREQ(test.mapField()[10].toStdString().c_str(), "Some 10");
+    ASSERT_STREQ(test.mapField()[0].toStdString().c_str(), "Some 0");
+    ASSERT_STREQ(test.mapField()[44].toStdString().c_str(), "Some 44");
 }
 
-TEST_F(SimpleTest, SimpleStringMapMessage)
+TEST_F(SimpleTest, SimpleStringStringMapMessage)
 {
     const char* propertyName = "mapField";
-    SimpleStringMapMessage::registerTypes();
-    SimpleStringMapMessage test;
-    ASSERT_TRUE(QMetaType::isRegistered(qMetaTypeId<SimpleStringMapMessage::MapFieldEntry>()));
-    int propertyNumber = SimpleStringMapMessage::propertyOrdering.at(1); //See simpletest.proto
-    ASSERT_STREQ(SimpleStringMapMessage::staticMetaObject.property(propertyNumber).typeName(), "SimpleStringMapMessage::MapFieldEntry");
-    ASSERT_EQ(SimpleStringMapMessage::staticMetaObject.property(propertyNumber).userType(), qMetaTypeId<SimpleStringMapMessage::MapFieldEntry>());
-    ASSERT_STREQ(SimpleStringMapMessage::staticMetaObject.property(propertyNumber).name(), propertyName);
-    SimpleStringMapMessage::MapFieldEntry testMap = {{"key 10", {"Some 10", nullptr}}, {"key 0", {"Some 0", nullptr}}, {"key 44", {"Some 44", nullptr}}};
+    SimpleStringStringMapMessage::registerTypes();
+    SimpleStringStringMapMessage test;
+    ASSERT_TRUE(QMetaType::isRegistered(qMetaTypeId<SimpleStringStringMapMessage::MapFieldEntry>()));
+    int propertyNumber = SimpleStringStringMapMessage::propertyOrdering.at(1); //See simpletest.proto
+    ASSERT_STREQ(SimpleStringStringMapMessage::staticMetaObject.property(propertyNumber).typeName(), "SimpleStringStringMapMessage::MapFieldEntry");
+    ASSERT_EQ(SimpleStringStringMapMessage::staticMetaObject.property(propertyNumber).userType(), qMetaTypeId<SimpleStringStringMapMessage::MapFieldEntry>());
+    ASSERT_STREQ(SimpleStringStringMapMessage::staticMetaObject.property(propertyNumber).name(), propertyName);
+    SimpleStringStringMapMessage::MapFieldEntry testMap = {{"key 10", "Some 10"}, {"key 0", "Some 0"}, {"key 44", "Some 44"}};
     test.setMapField(testMap);
-    ASSERT_TRUE(test.property(propertyName).value<SimpleStringMapMessage::MapFieldEntry>() == testMap);
+    ASSERT_TRUE(test.property(propertyName).value<SimpleStringStringMapMessage::MapFieldEntry>() == testMap);
     ASSERT_TRUE(test.mapField() == testMap);
-    ASSERT_STREQ(test.mapField()["key 10"].testFieldString().toStdString().c_str(), "Some 10");
-    ASSERT_STREQ(test.mapField()["key 0"].testFieldString().toStdString().c_str(), "Some 0");
-    ASSERT_STREQ(test.mapField()["key 44"].testFieldString().toStdString().c_str(), "Some 44");
+    ASSERT_STREQ(test.mapField()["key 10"].toStdString().c_str(), "Some 10");
+    ASSERT_STREQ(test.mapField()["key 0"].toStdString().c_str(), "Some 0");
+    ASSERT_STREQ(test.mapField()["key 44"].toStdString().c_str(), "Some 44");
 }