Move all registration functionality to a separate unit

Move functionality related to the registration of the protobuf messages
to a separate header/source files.

Task-number: QTBUG-120931
Change-Id: I6076b41139d43982148e46f5f315808509c4db65
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
This commit is contained in:
Alexey Edelev 2024-01-20 12:44:39 +01:00
parent ad3960ae39
commit b9519412ae
68 changed files with 568 additions and 524 deletions

View File

@ -6,6 +6,8 @@
#include <QGrpcHttp2Channel>
#include <qprotobufregistration.h>
#include <QDebug>
#include <QFile>
#include <QCryptographicHash>

View File

@ -13,6 +13,7 @@ qt_internal_add_module(Protobuf
qprotobufserializer.cpp qprotobufserializer.h qprotobufserializer_p.h
qprotobufjsonserializer.cpp qprotobufjsonserializer.h
qtprotobuflogging.cpp qtprotobuflogging_p.h
qprotobufregistration.cpp qprotobufregistration.h
qtprotobuftypes.cpp qtprotobuftypes.h
qprotobufoneof.cpp qprotobufoneof.h
GENERATE_CPP_EXPORTS

View File

@ -3,8 +3,6 @@
#include "qprotobufbaseserializer.h"
#include <QtProtobuf/qprotobufmessage.h>
QT_BEGIN_NAMESPACE
/*!
@ -155,31 +153,4 @@ QT_BEGIN_NAMESPACE
\sa QProtobufBaseSerializer::serializeEnumList()
*/
/*!
\relates QProtobufBaseSerializer
\fn template<typename T> inline void qRegisterProtobufType()
Registers a Protobuf type \e T.
This function is normally called by generated code.
*/
/*!
\relates QProtobufBaseSerializer
\fn template<typename K, typename V> inline void qRegisterProtobufMapType();
Registers a Protobuf map type \c K and \c V.
\c V must be a QProtobufMessage.
This function is normally called by generated code.
*/
/*!
\relates QProtobufBaseSerializer
\fn template<typename T> inline void qRegisterProtobufEnumType();
Registers serializers for enumeration type \c T in QtProtobuf global
serializers registry.
This function is normally called by generated code.
*/
QT_END_NAMESPACE

View File

@ -6,11 +6,8 @@
#include <QtProtobuf/qabstractprotobufserializer.h>
#include <QtCore/QHash>
#include <QtCore/QList>
#include <QtCore/QMetaEnum>
#include <QtCore/QMetaObject>
#include <QtCore/QPair>
#include <QtCore/QVariant>
QT_BEGIN_NAMESPACE
@ -51,273 +48,5 @@ public:
const QMetaEnum &metaEnum) const = 0;
};
namespace QtProtobufPrivate {
using Serializer = void (*)(const QProtobufBaseSerializer *, const QVariant &,
const QProtobufPropertyOrderingInfo &);
using Deserializer = void (*)(const QProtobufBaseSerializer *, QVariant &);
/*!
\private
\brief SerializationHandlers contains set of objects that required for class
serialization/deserialization
*/
struct SerializationHandler
{
Serializer serializer = nullptr; /*!< serializer assigned to class */
Deserializer deserializer = nullptr; /*!< deserializer assigned to class */
};
extern Q_PROTOBUF_EXPORT SerializationHandler findHandler(QMetaType type);
extern Q_PROTOBUF_EXPORT void registerHandler(QMetaType type, const SerializationHandler &handlers);
/*!
\private
\brief default serializer template for type T that inherits from QProtobufMessage
*/
template <typename T,
typename std::enable_if_t<std::is_base_of<QProtobufMessage, T>::value, int> = 0>
void serializeObject(const QProtobufBaseSerializer *serializer, const QVariant &value,
const QProtobufPropertyOrderingInfo &fieldInfo)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufBaseSerializer", "Serializer is null");
serializer->serializeObject(value.value<T *>(), T::staticPropertyOrdering, fieldInfo);
}
/*!
\private
\brief default serializer template for list of type T objects that inherits from QProtobufMessage
*/
template <typename V,
typename std::enable_if_t<std::is_base_of<QProtobufMessage, V>::value, int> = 0>
void serializeList(const QProtobufBaseSerializer *serializer, const QVariant &listValue,
const QProtobufPropertyOrderingInfo &fieldInfo)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufSerializer", "Serializer is null");
for (const auto &value : listValue.value<QList<V>>()) {
serializer->serializeListObject(&value, V::staticPropertyOrdering, fieldInfo);
}
}
/*!
\private
\brief default serializer template for map of key K, value V
*/
template <typename K, typename V,
typename std::enable_if_t<!std::is_base_of<QProtobufMessage, V>::value, int> = 0>
void serializeMap(const QProtobufBaseSerializer *serializer, const QVariant &value,
const QProtobufPropertyOrderingInfo &fieldInfo)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufSerializer", "Serializer is null");
for (const auto &[k, v] : value.value<QHash<K, V>>().asKeyValueRange()) {
serializer->serializeMapPair(QVariant::fromValue<K>(k), QVariant::fromValue<V>(v),
fieldInfo);
}
}
/*!
\private
\brief default serializer template for map of type key K, value V. Specialization for V that
inherits from QProtobufMessage
*/
template <typename K, typename V,
typename std::enable_if_t<std::is_base_of<QProtobufMessage, V>::value, int> = 0>
void serializeMap(const QProtobufBaseSerializer *serializer, const QVariant &value,
const QProtobufPropertyOrderingInfo &fieldInfo)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufSerializer", "Serializer is null");
for (const auto &[k, v] : value.value<QHash<K, V>>().asKeyValueRange()) {
serializer->serializeMapPair(QVariant::fromValue<K>(k), QVariant::fromValue<V *>(&v),
fieldInfo);
}
}
/*!
\private
\brief default serializer template for enum types
*/
template <typename T, typename std::enable_if_t<std::is_enum<T>::value, int> = 0>
void serializeEnum(const QProtobufBaseSerializer *serializer, const QVariant &value,
const QProtobufPropertyOrderingInfo &fieldInfo)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufBaseSerializer", "Serializer is null");
static const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
serializer->serializeEnum(QtProtobuf::int64(value.value<T>()), metaEnum,
fieldInfo);
}
/*!
\private
\brief default serializer template for enum list types
*/
template <typename T, typename std::enable_if_t<std::is_enum<T>::value, int> = 0>
void serializeEnumList(const QProtobufBaseSerializer *serializer, const QVariant &value,
const QProtobufPropertyOrderingInfo &fieldInfo)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufBaseSerializer", "Serializer is null");
static const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
QList<QtProtobuf::int64> intList;
for (auto enumValue : value.value<QList<T>>()) {
intList.append(QtProtobuf::int64(enumValue));
}
serializer->serializeEnumList(intList, metaEnum, fieldInfo);
}
/*!
\private
\brief default deserializer template for type T that inherits from QProtobufMessage
*/
template <typename T,
typename std::enable_if_t<std::is_base_of<QProtobufMessage, T>::value, int> = 0>
void deserializeObject(const QProtobufBaseSerializer *serializer, QVariant &to)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufBaseSerializer", "Serializer is null");
Q_ASSERT_X(to.isNull() || to.metaType() == QMetaType::fromType<T *>(),
"QProtobufBaseSerializer",
"Property should be either uninitialized or contain a valid pointer");
T *value = to.value<T *>();
if (value == nullptr) {
value = new T;
to = QVariant::fromValue<T *>(value);
}
serializer->deserializeObject(value, T::staticPropertyOrdering);
}
/*!
\private
\brief default deserializer template for list of type T objects that inherits from QProtobufMessage
*/
template <typename V,
typename std::enable_if_t<std::is_base_of<QProtobufMessage, V>::value, int> = 0>
void deserializeList(const QProtobufBaseSerializer *serializer, QVariant &previous)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufBaseSerializer", "Serializer is null");
V newValue;
serializer->deserializeListObject(&newValue, V::staticPropertyOrdering);
QList<V> list = previous.value<QList<V>>();
list.append(newValue);
previous.setValue(list);
}
/*!
\private
*
\brief default deserializer template for map of key K, value V
*/
template <typename K, typename V,
typename std::enable_if_t<!std::is_base_of<QProtobufMessage, V>::value, int> = 0>
void deserializeMap(const QProtobufBaseSerializer *serializer, QVariant &previous)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufBaseSerializer", "Serializer is null");
QHash<K, V> out = previous.value<QHash<K, V>>();
QVariant key = QVariant::fromValue<K>(K());
QVariant value = QVariant::fromValue<V>(V());
if (serializer->deserializeMapPair(key, value)) {
out[key.value<K>()] = value.value<V>();
previous = QVariant::fromValue<QHash<K, V>>(out);
}
}
/*!
\private
*
\brief default deserializer template for map of type key K, value V. Specialization for V
that inherits from QProtobufMessage
*/
template <typename K, typename V,
typename std::enable_if_t<std::is_base_of<QProtobufMessage, V>::value, int> = 0>
void deserializeMap(const QProtobufBaseSerializer *serializer, QVariant &previous)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufBaseSerializer", "Serializer is null");
auto out = previous.value<QHash<K, V>>();
QVariant key = QVariant::fromValue<K>(K());
QVariant value = QVariant::fromValue<V *>(nullptr);
bool ok = serializer->deserializeMapPair(key, value);
V *valuePtr = value.value<V *>();
if (ok) {
out[key.value<K>()] = valuePtr ? *valuePtr : V();
previous = QVariant::fromValue<QHash<K, V>>(out);
}
delete valuePtr;
}
/*!
\private
*
\brief default deserializer template for enum type T
*/
template <typename T, typename std::enable_if_t<std::is_enum<T>::value, int> = 0>
void deserializeEnum(const QProtobufBaseSerializer *serializer, QVariant &to)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufBaseSerializer", "Serializer is null");
static const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
QtProtobuf::int64 intValue;
if (serializer->deserializeEnum(intValue, metaEnum))
to = QVariant::fromValue<T>(static_cast<T>(intValue._t));
}
/*!
\private
*
\brief default deserializer template for enumList type T
*/
template <typename T, typename std::enable_if_t<std::is_enum<T>::value, int> = 0>
void deserializeEnumList(const QProtobufBaseSerializer *serializer, QVariant &previous)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufBaseSerializer", "Serializer is null");
static const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
QList<QtProtobuf::int64> intList;
if (!serializer->deserializeEnumList(intList, metaEnum))
return;
QList<T> enumList = previous.value<QList<T>>();
for (auto intValue : intList)
enumList.append(static_cast<T>(intValue._t));
previous = QVariant::fromValue<QList<T>>(enumList);
}
} // namespace QtProtobufPrivate
template<typename T>
inline void qRegisterProtobufType()
{
T::registerTypes();
QtProtobufPrivate::registerOrdering(QMetaType::fromType<T>(), T::staticPropertyOrdering);
QtProtobufPrivate::registerHandler(
QMetaType::fromType<T *>(),
{ QtProtobufPrivate::serializeObject<T>, QtProtobufPrivate::deserializeObject<T> });
QtProtobufPrivate::registerHandler(
QMetaType::fromType<QList<T>>(),
{ QtProtobufPrivate::serializeList<T>, QtProtobufPrivate::deserializeList<T> });
}
template<typename K, typename V>
inline void qRegisterProtobufMapType()
{
QtProtobufPrivate::registerHandler(
QMetaType::fromType<QHash<K, V>>(),
{ QtProtobufPrivate::serializeMap<K, V>, QtProtobufPrivate::deserializeMap<K, V> });
}
#ifdef Q_QDOC
template<typename T>
inline void qRegisterProtobufEnumType();
#else // !Q_QDOC
template<typename T, typename std::enable_if_t<std::is_enum<T>::value, int> = 0>
inline void qRegisterProtobufEnumType()
{
QtProtobufPrivate::registerHandler(
QMetaType::fromType<T>(),
{ QtProtobufPrivate::serializeEnum<T>, QtProtobufPrivate::deserializeEnum<T> });
QtProtobufPrivate::registerHandler(
QMetaType::fromType<QList<T>>(),
{ QtProtobufPrivate::serializeEnumList<T>, QtProtobufPrivate::deserializeEnumList<T> });
}
#endif // Q_QDOC
QT_END_NAMESPACE
#endif // QPROTOBUFSBASEERIALIZER_H

View File

@ -3,6 +3,7 @@
#include "qprotobufjsonserializer.h"
#include "qprotobufserializer_p.h"
#include "qprotobufregistration.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QJsonArray>

View File

@ -4,8 +4,9 @@
#include "qprotobufmessage.h"
#include "qprotobufmessage_p.h"
#include "qabstractprotobufserializer.h"
#include "qprotobufregistration.h"
#include "qtprotobuftypes.h"
#include <QtProtobuf/qtprotobuftypes.h>
#include <QtCore/qassert.h>
#include <QtCore/qmetaobject.h>

View File

@ -0,0 +1,193 @@
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qprotobufregistration.h"
#include "qtprotobuftypes.h"
#include <QtCore/qmutex.h>
#include <QtCore/qmetatype.h>
#include <QtCore/qreadwritelock.h>
#include <mutex>
QT_BEGIN_NAMESPACE
/*!
\relates QtProtobuf
\fn template<typename T> inline void qRegisterProtobufType()
Registers a Protobuf type \e T.
This function is normally called by generated code.
*/
/*!
\relates QtProtobuf
\fn template<typename K, typename V> inline void qRegisterProtobufMapType();
Registers a Protobuf map type \c K and \c V.
\c V must be a QProtobufMessage.
This function is normally called by generated code.
*/
/*!
\relates QtProtobuf
\fn template<typename T> inline void qRegisterProtobufEnumType();
Registers serializers for enumeration type \c T in QtProtobuf global
serializers registry.
This function is normally called by generated code.
*/
namespace {
std::vector<QtProtobuf::RegisterFunction> &registerFunctions()
{
// no need for implicit sharing etc, so stick with std::vector
static std::vector<QtProtobuf::RegisterFunction> registrationList;
return registrationList;
}
template<typename T>
void registerBasicConverters()
{
QMetaType::registerConverter<int32_t, T>(T::fromType);
QMetaType::registerConverter<T, int32_t>(T::toType);
QMetaType::registerConverter<int64_t, T>(T::fromType);
QMetaType::registerConverter<T, int64_t>(T::toType);
QMetaType::registerConverter<uint32_t, T>(T::fromType);
QMetaType::registerConverter<T, uint32_t>(T::toType);
QMetaType::registerConverter<uint64_t, T>(T::fromType);
QMetaType::registerConverter<T, uint64_t>(T::toType);
if constexpr (!std::is_same_v<long long, int64_t>) {
QMetaType::registerConverter<long long, T>(T::fromType);
QMetaType::registerConverter<T, long long>(T::toType);
QMetaType::registerConverter<unsigned long long, T>(T::fromType);
QMetaType::registerConverter<T, unsigned long long>(T::toType);
}
QMetaType::registerConverter<double, T>(T::fromType);
QMetaType::registerConverter<T, double>(T::toType);
QMetaType::registerConverter<T, QString>(T::toString);
}
static void qRegisterBaseTypes()
{
[[maybe_unused]] // definitely unused
static bool registered = [] {
qRegisterMetaType<QtProtobuf::int32>();
qRegisterMetaType<QtProtobuf::int64>();
qRegisterMetaType<QtProtobuf::uint32>();
qRegisterMetaType<QtProtobuf::uint64>();
qRegisterMetaType<QtProtobuf::sint32>();
qRegisterMetaType<QtProtobuf::sint64>();
qRegisterMetaType<QtProtobuf::fixed32>();
qRegisterMetaType<QtProtobuf::fixed64>();
qRegisterMetaType<QtProtobuf::sfixed32>();
qRegisterMetaType<QtProtobuf::sfixed64>();
qRegisterMetaType<QtProtobuf::boolean>();
qRegisterMetaType<QtProtobuf::int32List>();
qRegisterMetaType<QtProtobuf::int64List>();
qRegisterMetaType<QtProtobuf::uint32List>();
qRegisterMetaType<QtProtobuf::uint64List>();
qRegisterMetaType<QtProtobuf::sint32List>();
qRegisterMetaType<QtProtobuf::sint64List>();
qRegisterMetaType<QtProtobuf::fixed32List>();
qRegisterMetaType<QtProtobuf::fixed64List>();
qRegisterMetaType<QtProtobuf::sfixed32List>();
qRegisterMetaType<QtProtobuf::sfixed64List>();
qRegisterMetaType<QtProtobuf::doubleList>();
qRegisterMetaType<QtProtobuf::floatList>();
qRegisterMetaType<QtProtobuf::boolList>();
registerBasicConverters<QtProtobuf::int32>();
registerBasicConverters<QtProtobuf::int64>();
registerBasicConverters<QtProtobuf::sfixed32>();
registerBasicConverters<QtProtobuf::sfixed64>();
registerBasicConverters<QtProtobuf::fixed32>();
registerBasicConverters<QtProtobuf::fixed64>();
return true;
}();
}
/*
\internal
\brief The HandlersRegistry is a container to store mapping between metatype
identifier and serialization handlers.
*/
struct HandlersRegistry
{
void registerHandler(QMetaType type, const QtProtobufPrivate::SerializationHandler &handlers)
{
QWriteLocker locker(&m_lock);
m_registry[type] = handlers;
}
QtProtobufPrivate::SerializationHandler findHandler(QMetaType type)
{
QtProtobufPrivate::SerializationHandler handler;
QReadLocker locker(&m_lock);
auto it = m_registry.constFind(type);
if (it != m_registry.constEnd())
handler = it.value();
return handler;
}
private:
QReadWriteLock m_lock;
QHash<QMetaType, QtProtobufPrivate::SerializationHandler> m_registry;
};
Q_GLOBAL_STATIC(HandlersRegistry, handlersRegistry)
Q_CONSTINIT QBasicMutex registerMutex;
}
void QtProtobufPrivate::registerHandler(QMetaType type,
const QtProtobufPrivate::SerializationHandler &handlers)
{
handlersRegistry->registerHandler(type, handlers);
}
QtProtobufPrivate::SerializationHandler QtProtobufPrivate::findHandler(QMetaType type)
{
if (!handlersRegistry.exists())
return {};
return handlersRegistry->findHandler(type);
}
namespace QtProtobuf {
ProtoTypeRegistrar::ProtoTypeRegistrar(QtProtobuf::RegisterFunction initializer)
{
std::scoped_lock lock(registerMutex);
registerFunctions().push_back(initializer);
}
}
/*!
\relates QtProtobuf
Calling this function registers all, currently known, protobuf types with
the serializer registry.
\note You should not have to call this function manually, as it is called
automatically upon attempting serialization or deserialization of a protobuf
message.
*/
void qRegisterProtobufTypes()
{
qRegisterBaseTypes();
std::vector<QtProtobuf::RegisterFunction> registrationList;
// Move the list to a local variable, emptying the global one.
{
std::scoped_lock lock(registerMutex);
registrationList.swap(registerFunctions());
}
for (QtProtobuf::RegisterFunction registerFunc : registrationList)
registerFunc();
}
QT_END_NAMESPACE

View File

@ -0,0 +1,306 @@
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPROTOBUFREGISTRATION_H
#define QPROTOBUFREGISTRATION_H
#if 0
# pragma qt_sync_skip_header_check
# pragma qt_sync_stop_processing
#endif
#include <QtCore/qmetatype.h>
#include <QtCore/qmetaobject.h>
#include <QtCore/qhash.h>
#include <QtProtobuf/qtprotobufglobal.h>
#include <QtProtobuf/qtprotobuftypes.h>
#include <QtProtobuf/qprotobufbaseserializer.h>
#include <QtProtobuf/qprotobufmessage.h>
QT_BEGIN_NAMESPACE
namespace QtProtobuf {
using RegisterFunction = void (*)();
// This struct is used for type registrations in generated code
struct ProtoTypeRegistrar
{
Q_PROTOBUF_EXPORT explicit ProtoTypeRegistrar(QtProtobuf::RegisterFunction initializer);
};
}
namespace QtProtobufPrivate {
extern Q_PROTOBUF_EXPORT void registerOrdering(QMetaType type, QProtobufPropertyOrdering ordering);
using Serializer = void (*)(const QProtobufBaseSerializer *, const QVariant &,
const QProtobufPropertyOrderingInfo &);
using Deserializer = void (*)(const QProtobufBaseSerializer *, QVariant &);
/*!
\private
\brief SerializationHandlers contains set of objects that required for class
serialization/deserialization
*/
struct SerializationHandler
{
Serializer serializer = nullptr; /*!< serializer assigned to class */
Deserializer deserializer = nullptr; /*!< deserializer assigned to class */
};
extern Q_PROTOBUF_EXPORT SerializationHandler findHandler(QMetaType type);
extern Q_PROTOBUF_EXPORT void registerHandler(QMetaType type, const SerializationHandler &handlers);
/*!
\private
\brief default serializer template for type T that inherits from QProtobufMessage
*/
template <typename T,
typename std::enable_if_t<std::is_base_of<QProtobufMessage, T>::value, int> = 0>
void serializeObject(const QProtobufBaseSerializer *serializer, const QVariant &value,
const QProtobufPropertyOrderingInfo &fieldInfo)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufBaseSerializer", "Serializer is null");
serializer->serializeObject(value.value<T *>(), T::staticPropertyOrdering, fieldInfo);
}
/*!
\private
\brief default serializer template for list of type T objects that inherits from QProtobufMessage
*/
template <typename V,
typename std::enable_if_t<std::is_base_of<QProtobufMessage, V>::value, int> = 0>
void serializeList(const QProtobufBaseSerializer *serializer, const QVariant &listValue,
const QProtobufPropertyOrderingInfo &fieldInfo)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufSerializer", "Serializer is null");
for (const auto &value : listValue.value<QList<V>>()) {
serializer->serializeListObject(&value, V::staticPropertyOrdering, fieldInfo);
}
}
/*!
\private
\brief default serializer template for map of key K, value V
*/
template <typename K, typename V,
typename std::enable_if_t<!std::is_base_of<QProtobufMessage, V>::value, int> = 0>
void serializeMap(const QProtobufBaseSerializer *serializer, const QVariant &value,
const QProtobufPropertyOrderingInfo &fieldInfo)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufSerializer", "Serializer is null");
for (const auto &[k, v] : value.value<QHash<K, V>>().asKeyValueRange()) {
serializer->serializeMapPair(QVariant::fromValue<K>(k), QVariant::fromValue<V>(v),
fieldInfo);
}
}
/*!
\private
\brief default serializer template for map of type key K, value V. Specialization for V that
inherits from QProtobufMessage
*/
template <typename K, typename V,
typename std::enable_if_t<std::is_base_of<QProtobufMessage, V>::value, int> = 0>
void serializeMap(const QProtobufBaseSerializer *serializer, const QVariant &value,
const QProtobufPropertyOrderingInfo &fieldInfo)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufSerializer", "Serializer is null");
for (const auto &[k, v] : value.value<QHash<K, V>>().asKeyValueRange()) {
serializer->serializeMapPair(QVariant::fromValue<K>(k), QVariant::fromValue<V *>(&v),
fieldInfo);
}
}
/*!
\private
\brief default serializer template for enum types
*/
template <typename T, typename std::enable_if_t<std::is_enum<T>::value, int> = 0>
void serializeEnum(const QProtobufBaseSerializer *serializer, const QVariant &value,
const QProtobufPropertyOrderingInfo &fieldInfo)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufBaseSerializer", "Serializer is null");
static const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
serializer->serializeEnum(QtProtobuf::int64(value.value<T>()), metaEnum,
fieldInfo);
}
/*!
\private
\brief default serializer template for enum list types
*/
template <typename T, typename std::enable_if_t<std::is_enum<T>::value, int> = 0>
void serializeEnumList(const QProtobufBaseSerializer *serializer, const QVariant &value,
const QProtobufPropertyOrderingInfo &fieldInfo)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufBaseSerializer", "Serializer is null");
static const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
QList<QtProtobuf::int64> intList;
for (auto enumValue : value.value<QList<T>>()) {
intList.append(QtProtobuf::int64(enumValue));
}
serializer->serializeEnumList(intList, metaEnum, fieldInfo);
}
/*!
\private
\brief default deserializer template for type T that inherits from QProtobufMessage
*/
template <typename T,
typename std::enable_if_t<std::is_base_of<QProtobufMessage, T>::value, int> = 0>
void deserializeObject(const QProtobufBaseSerializer *serializer, QVariant &to)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufBaseSerializer", "Serializer is null");
Q_ASSERT_X(to.isNull() || to.metaType() == QMetaType::fromType<T *>(),
"QProtobufBaseSerializer",
"Property should be either uninitialized or contain a valid pointer");
T *value = to.value<T *>();
if (value == nullptr) {
value = new T;
to = QVariant::fromValue<T *>(value);
}
serializer->deserializeObject(value, T::staticPropertyOrdering);
}
/*!
\private
\brief default deserializer template for list of type T objects that inherits from QProtobufMessage
*/
template <typename V,
typename std::enable_if_t<std::is_base_of<QProtobufMessage, V>::value, int> = 0>
void deserializeList(const QProtobufBaseSerializer *serializer, QVariant &previous)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufBaseSerializer", "Serializer is null");
V newValue;
serializer->deserializeListObject(&newValue, V::staticPropertyOrdering);
QList<V> list = previous.value<QList<V>>();
list.append(newValue);
previous.setValue(list);
}
/*!
\private
*
\brief default deserializer template for map of key K, value V
*/
template <typename K, typename V,
typename std::enable_if_t<!std::is_base_of<QProtobufMessage, V>::value, int> = 0>
void deserializeMap(const QProtobufBaseSerializer *serializer, QVariant &previous)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufBaseSerializer", "Serializer is null");
QHash<K, V> out = previous.value<QHash<K, V>>();
QVariant key = QVariant::fromValue<K>(K());
QVariant value = QVariant::fromValue<V>(V());
if (serializer->deserializeMapPair(key, value)) {
out[key.value<K>()] = value.value<V>();
previous = QVariant::fromValue<QHash<K, V>>(out);
}
}
/*!
\private
*
\brief default deserializer template for map of type key K, value V. Specialization for V
that inherits from QProtobufMessage
*/
template <typename K, typename V,
typename std::enable_if_t<std::is_base_of<QProtobufMessage, V>::value, int> = 0>
void deserializeMap(const QProtobufBaseSerializer *serializer, QVariant &previous)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufBaseSerializer", "Serializer is null");
auto out = previous.value<QHash<K, V>>();
QVariant key = QVariant::fromValue<K>(K());
QVariant value = QVariant::fromValue<V *>(nullptr);
bool ok = serializer->deserializeMapPair(key, value);
V *valuePtr = value.value<V *>();
if (ok) {
out[key.value<K>()] = valuePtr ? *valuePtr : V();
previous = QVariant::fromValue<QHash<K, V>>(out);
}
delete valuePtr;
}
/*!
\private
*
\brief default deserializer template for enum type T
*/
template <typename T, typename std::enable_if_t<std::is_enum<T>::value, int> = 0>
void deserializeEnum(const QProtobufBaseSerializer *serializer, QVariant &to)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufBaseSerializer", "Serializer is null");
static const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
QtProtobuf::int64 intValue;
if (serializer->deserializeEnum(intValue, metaEnum))
to = QVariant::fromValue<T>(static_cast<T>(intValue._t));
}
/*!
\private
*
\brief default deserializer template for enumList type T
*/
template <typename T, typename std::enable_if_t<std::is_enum<T>::value, int> = 0>
void deserializeEnumList(const QProtobufBaseSerializer *serializer, QVariant &previous)
{
Q_ASSERT_X(serializer != nullptr, "QProtobufBaseSerializer", "Serializer is null");
static const QMetaEnum metaEnum = QMetaEnum::fromType<T>();
QList<QtProtobuf::int64> intList;
if (!serializer->deserializeEnumList(intList, metaEnum))
return;
QList<T> enumList = previous.value<QList<T>>();
for (auto intValue : intList)
enumList.append(static_cast<T>(intValue._t));
previous = QVariant::fromValue<QList<T>>(enumList);
}
} // namespace QtProtobufPrivate
Q_PROTOBUF_EXPORT void qRegisterProtobufTypes();
template<typename T>
inline void qRegisterProtobufType()
{
T::registerTypes();
QtProtobufPrivate::registerOrdering(QMetaType::fromType<T>(), T::staticPropertyOrdering);
QtProtobufPrivate::registerHandler(
QMetaType::fromType<T *>(),
{ QtProtobufPrivate::serializeObject<T>, QtProtobufPrivate::deserializeObject<T> });
QtProtobufPrivate::registerHandler(
QMetaType::fromType<QList<T>>(),
{ QtProtobufPrivate::serializeList<T>, QtProtobufPrivate::deserializeList<T> });
}
template<typename K, typename V>
inline void qRegisterProtobufMapType()
{
QtProtobufPrivate::registerHandler(
QMetaType::fromType<QHash<K, V>>(),
{ QtProtobufPrivate::serializeMap<K, V>, QtProtobufPrivate::deserializeMap<K, V> });
}
#ifdef Q_QDOC
template<typename T>
inline void qRegisterProtobufEnumType();
#else // !Q_QDOC
template<typename T, typename std::enable_if_t<std::is_enum<T>::value, int> = 0>
inline void qRegisterProtobufEnumType()
{
QtProtobufPrivate::registerHandler(
QMetaType::fromType<T>(),
{ QtProtobufPrivate::serializeEnum<T>, QtProtobufPrivate::deserializeEnum<T> });
QtProtobufPrivate::registerHandler(
QMetaType::fromType<QList<T>>(),
{ QtProtobufPrivate::serializeEnumList<T>, QtProtobufPrivate::deserializeEnumList<T> });
}
#endif // Q_QDOC
QT_END_NAMESPACE
#endif // QPROTOBUFREGISTRATION_H

View File

@ -4,7 +4,7 @@
#include "qprotobufserializer.h"
#include "qprotobufserializer_p.h"
#include "qprotobufregistration.h"
#include "qtprotobuftypes.h"
#include <QtCore/qmetatype.h>
@ -22,57 +22,15 @@ QT_BEGIN_NAMESPACE
namespace {
/*
\internal
\brief The HandlersRegistry is a container to store mapping between metatype
identifier and serialization handlers.
*/
struct HandlersRegistry
{
void registerHandler(QMetaType type, const QtProtobufPrivate::SerializationHandler &handlers)
{
QWriteLocker locker(&m_lock);
m_registry[type] = handlers;
}
QtProtobufPrivate::SerializationHandler findHandler(QMetaType type)
{
QtProtobufPrivate::SerializationHandler handler;
QReadLocker locker(&m_lock);
auto it = m_registry.constFind(type);
if (it != m_registry.constEnd())
handler = it.value();
return handler;
}
private:
QReadWriteLock m_lock;
QHash<QMetaType, QtProtobufPrivate::SerializationHandler> m_registry;
};
Q_GLOBAL_STATIC(HandlersRegistry, handlersRegistry)
inline bool
isOneofOrOptionalField(const QtProtobufPrivate::QProtobufPropertyOrderingInfo &fieldInfo)
{
return fieldInfo.getFieldFlags() & QtProtobufPrivate::Oneof
|| fieldInfo.getFieldFlags() & QtProtobufPrivate::Optional;
|| fieldInfo.getFieldFlags() & QtProtobufPrivate::Optional;
}
} // namespace
void QtProtobufPrivate::registerHandler(QMetaType type,
const QtProtobufPrivate::SerializationHandler &handlers)
{
handlersRegistry->registerHandler(type, handlers);
}
QtProtobufPrivate::SerializationHandler QtProtobufPrivate::findHandler(QMetaType type)
{
if (!handlersRegistry.exists())
return {};
return handlersRegistry->findHandler(type);
}
/*!
\class QProtobufSerializer
\inmodule QtProtobuf

View File

@ -2,18 +2,14 @@
// Copyright (C) 2019 Alexey Edelev <semlanik@gmail.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include <QtProtobuf/qtprotobufglobal.h>
#include "qtprotobuflogging_p.h"
#include "qtprotobuftypes.h"
#include "qprotobufregistration.h"
#include <QtCore/qreadwritelock.h>
#include <QtCore/qmutex.h>
#include <QtCore/qpair.h>
#include <QtProtobuf/private/qtprotobuflogging_p.h>
#include "qtprotobuftypes.h"
#include <limits>
#include <mutex>
QT_BEGIN_NAMESPACE
@ -194,111 +190,6 @@ namespace QtProtobufPrivate {
}
}
namespace QtProtobuf {
template<typename T>
void registerBasicConverters()
{
QMetaType::registerConverter<int32_t, T>(T::fromType);
QMetaType::registerConverter<T, int32_t>(T::toType);
QMetaType::registerConverter<int64_t, T>(T::fromType);
QMetaType::registerConverter<T, int64_t>(T::toType);
QMetaType::registerConverter<uint32_t, T>(T::fromType);
QMetaType::registerConverter<T, uint32_t>(T::toType);
QMetaType::registerConverter<uint64_t, T>(T::fromType);
QMetaType::registerConverter<T, uint64_t>(T::toType);
if constexpr (!std::is_same_v<long long, int64_t>) {
QMetaType::registerConverter<long long, T>(T::fromType);
QMetaType::registerConverter<T, long long>(T::toType);
QMetaType::registerConverter<unsigned long long, T>(T::fromType);
QMetaType::registerConverter<T, unsigned long long>(T::toType);
}
QMetaType::registerConverter<double, T>(T::fromType);
QMetaType::registerConverter<T, double>(T::toType);
QMetaType::registerConverter<T, QString>(T::toString);
}
Q_CONSTINIT QBasicMutex registerMutex;
std::vector<QtProtobuf::RegisterFunction> &registerFunctions()
{
// no need for implicit sharing etc, so stick with std::vector
static std::vector<QtProtobuf::RegisterFunction> registrationList;
return registrationList;
}
ProtoTypeRegistrar::ProtoTypeRegistrar(QtProtobuf::RegisterFunction initializer)
{
std::scoped_lock lock(registerMutex);
QtProtobuf::registerFunctions().push_back(initializer);
}
} // namespace QtProtobuf
static void qRegisterBaseTypes()
{
[[maybe_unused]] // definitely unused
static bool registered = [] {
qRegisterMetaType<QtProtobuf::int32>();
qRegisterMetaType<QtProtobuf::int64>();
qRegisterMetaType<QtProtobuf::uint32>();
qRegisterMetaType<QtProtobuf::uint64>();
qRegisterMetaType<QtProtobuf::sint32>();
qRegisterMetaType<QtProtobuf::sint64>();
qRegisterMetaType<QtProtobuf::fixed32>();
qRegisterMetaType<QtProtobuf::fixed64>();
qRegisterMetaType<QtProtobuf::sfixed32>();
qRegisterMetaType<QtProtobuf::sfixed64>();
qRegisterMetaType<QtProtobuf::boolean>();
qRegisterMetaType<QtProtobuf::int32List>();
qRegisterMetaType<QtProtobuf::int64List>();
qRegisterMetaType<QtProtobuf::uint32List>();
qRegisterMetaType<QtProtobuf::uint64List>();
qRegisterMetaType<QtProtobuf::sint32List>();
qRegisterMetaType<QtProtobuf::sint64List>();
qRegisterMetaType<QtProtobuf::fixed32List>();
qRegisterMetaType<QtProtobuf::fixed64List>();
qRegisterMetaType<QtProtobuf::sfixed32List>();
qRegisterMetaType<QtProtobuf::sfixed64List>();
qRegisterMetaType<QtProtobuf::doubleList>();
qRegisterMetaType<QtProtobuf::floatList>();
qRegisterMetaType<QtProtobuf::boolList>();
QtProtobuf::registerBasicConverters<QtProtobuf::int32>();
QtProtobuf::registerBasicConverters<QtProtobuf::int64>();
QtProtobuf::registerBasicConverters<QtProtobuf::sfixed32>();
QtProtobuf::registerBasicConverters<QtProtobuf::sfixed64>();
QtProtobuf::registerBasicConverters<QtProtobuf::fixed32>();
QtProtobuf::registerBasicConverters<QtProtobuf::fixed64>();
return true;
}();
}
/*!
\relates QtProtobuf
Calling this function registers all, currently known, protobuf types with
the serializer registry.
\note You should not have to call this function manually, as it is called
automatically upon attempting serialization or deserialization of a protobuf
message.
*/
void qRegisterProtobufTypes()
{
qRegisterBaseTypes();
std::vector<QtProtobuf::RegisterFunction> registrationList;
// Move the list to a local variable, emptying the global one.
{
std::scoped_lock lock(QtProtobuf::registerMutex);
registrationList.swap(QtProtobuf::registerFunctions());
}
for (QtProtobuf::RegisterFunction registerFunc : registrationList)
registerFunc();
}
QT_IMPL_METATYPE_EXTERN_TAGGED(QtProtobuf::int32, QtProtobuf_int32)
QT_IMPL_METATYPE_EXTERN_TAGGED(QtProtobuf::int64, QtProtobuf_int64)
QT_IMPL_METATYPE_EXTERN_TAGGED(QtProtobuf::fixed32, QtProtobuf_fixed32)

View File

@ -12,9 +12,7 @@
#include <QtCore/QtEndian>
#include <QtProtobuf/QProtobufMessage>
#include <memory>
#include <type_traits>
#include <utility>
QT_BEGIN_NAMESPACE
@ -49,8 +47,6 @@ private:
};
static_assert(std::is_trivially_destructible_v<QProtobufPropertyOrdering>);
extern Q_PROTOBUF_EXPORT void registerOrdering(QMetaType type, QProtobufPropertyOrdering ordering);
// Convenience structure to hold a reference to a single entry
struct QProtobufPropertyOrderingInfo
{
@ -155,13 +151,6 @@ using floatList = QList<float>;
using doubleList = QList<double>;
using boolList = QList<bool>;
using RegisterFunction = void (*)();
// This struct is used for type registrations in generated code
struct ProtoTypeRegistrar
{
Q_PROTOBUF_EXPORT explicit ProtoTypeRegistrar(QtProtobuf::RegisterFunction initializer);
};
template<typename T>
bool repeatedValueCompare(const QList<T> &a, const QList<T> &b)
{
@ -199,8 +188,6 @@ using qMakeUnsigned = typename qMakeUnsignedImpl<T>::type;
} // namespace QtProtobuf
Q_PROTOBUF_EXPORT void qRegisterProtobufTypes();
QT_END_NAMESPACE
QT_DECL_METATYPE_EXTERN_TAGGED(QtProtobuf::int32, QtProtobuf_int32, Q_PROTOBUF_EXPORT)

View File

@ -18,6 +18,7 @@
#include <QtProtobufQtCoreTypes/qtprotobufqtcoretypesexports.h>
#include <QtProtobuf/qtprotobuftypes.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <QtProtobuf/qprotobufserializer.h>
#include <QtCore/QVariant>

View File

@ -67,7 +67,7 @@ void QProtobufGenerator::GenerateSources(const FileDescriptor *file,
sourcePrinter->Print({{"include", basename + CommonTemplates::ProtoFileSuffix()}},
CommonTemplates::InternalIncludeTemplate());
registrationPrinter->Print({{"include", "QtProtobuf/qprotobufserializer.h"}},
registrationPrinter->Print({{"include", "QtProtobuf/qprotobufregistration.h"}},
CommonTemplates::ExternalIncludeTemplate());
registrationPrinter->Print({{"include", basename + CommonTemplates::ProtoFileSuffix()}},
@ -85,7 +85,7 @@ void QProtobufGenerator::GenerateSources(const FileDescriptor *file,
CommonTemplates::ExternalIncludeTemplate());
}
sourcePrinter->Print({{"include", "QtProtobuf/qprotobufserializer.h"}},
sourcePrinter->Print({{"include", "QtProtobuf/qprotobufregistration.h"}},
CommonTemplates::ExternalIncludeTemplate());
sourcePrinter->Print({{"include", "cmath"}},

View File

@ -7,6 +7,7 @@
#include <QtProtobuf/private/qprotobufserializer_p.h>
#include "qprotobufanysupport.h"
#include "qprotobufregistration.h"
#include <google/protobuf/any.qpb.h>

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "qtgrpc/tests/testservice.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtgrpc::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "qtgrpc/tests/testservice.qpb.h"
namespace qtgrpc::tests {

View File

@ -6,6 +6,7 @@
#include <QVariant>
#include <qtprotobuftypes.h>
#include <qprotobufregistration.h>
class QtProtobufConverterTest : public QObject
{

View File

@ -6,6 +6,7 @@
#include <QtProtobuf/qprotobufjsonserializer.h>
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <optional.qpb.h>

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "annotation.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtprotobufnamespace::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "annotation.qpb.h"
namespace qtprotobufnamespace::tests {

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "extranamespace.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace MyTopLevelNamespace::qtprotobufnamespace::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "extranamespace.qpb.h"
namespace MyTopLevelNamespace::qtprotobufnamespace::tests {

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "fieldindexrange.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtprotobufnamespace::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "fieldindexrange.qpb.h"
namespace qtprotobufnamespace::tests {

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "qtprotobufnamespace/optional/tests/optional.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtprotobufnamespace::optional::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "qtprotobufnamespace/optional/tests/optional.qpb.h"
namespace qtprotobufnamespace::optional::tests {

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "qtprotobufnamespace/tests/basicmessages.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtprotobufnamespace::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "qtprotobufnamespace/tests/basicmessages.qpb.h"
namespace qtprotobufnamespace::tests {

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "qtprotobufnamespace/tests/mapmessages.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtprotobufnamespace::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "qtprotobufnamespace/tests/mapmessages.qpb.h"
namespace qtprotobufnamespace::tests {

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "qtprotobufnamespace/tests/oneofmessages.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtprotobufnamespace::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "qtprotobufnamespace/tests/oneofmessages.qpb.h"
namespace qtprotobufnamespace::tests {

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "qtprotobufnamespace/tests/repeatedmessages.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtprotobufnamespace::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "qtprotobufnamespace/tests/repeatedmessages.qpb.h"
namespace qtprotobufnamespace::tests {

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "annotation.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtprotobufnamespace::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "annotation.qpb.h"
namespace qtprotobufnamespace::tests {

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "anymessages.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtproto::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "anymessages.qpb.h"
namespace qtproto::tests {

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "basicmessages.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtprotobufnamespace::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "basicmessages.qpb.h"
namespace qtprotobufnamespace::tests {

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "extranamespace.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtprotobufnamespace::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "extranamespace.qpb.h"
namespace qtprotobufnamespace::tests {

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "fieldindexrange.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtprotobufnamespace::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "fieldindexrange.qpb.h"
namespace qtprotobufnamespace::tests {

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "mapmessages.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtprotobufnamespace::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "mapmessages.qpb.h"
namespace qtprotobufnamespace::tests {

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "oneofmessages.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtprotobufnamespace::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "oneofmessages.qpb.h"
namespace qtprotobufnamespace::tests {

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "optional.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtprotobufnamespace::optional::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "optional.qpb.h"
namespace qtprotobufnamespace::optional::tests {

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "repeatedmessages.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtprotobufnamespace::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "repeatedmessages.qpb.h"
namespace qtprotobufnamespace::tests {

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "repeatednonpackedmessages.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtprotobufnamespace::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "repeatednonpackedmessages.qpb.h"
namespace qtprotobufnamespace::tests {

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "repeatednonpackedmessages.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtprotobufnamespace::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "repeatednonpackedmessages.qpb.h"
namespace qtprotobufnamespace::tests {

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "nopackage.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarTestEnumGadget(TestEnumGadget::registerTypes);

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "nopackage.qpb.h"
static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarEmptyMessage(qRegisterProtobufType<EmptyMessage>);

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "nopackageexternal.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "nopackageexternal.qpb.h"
static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarSimpleIntMessageExt(qRegisterProtobufType<SimpleIntMessageExt>);

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "basicmessages.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtprotobufnamespace::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "basicmessages.qpb.h"
namespace qtprotobufnamespace::tests {

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "enummessages.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtprotobufnamespace::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "enummessages.qpb.h"
namespace qtprotobufnamespace::tests {

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "oneofmessages.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtprotobufnamespace::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "oneofmessages.qpb.h"
namespace qtprotobufnamespace::tests {

View File

@ -1,7 +1,7 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "repeatedmessages.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include <cmath>
namespace qtprotobufnamespace::tests {

View File

@ -1,4 +1,4 @@
#include <QtProtobuf/qprotobufserializer.h>
#include <QtProtobuf/qprotobufregistration.h>
#include "repeatedmessages.qpb.h"
namespace qtprotobufnamespace::tests {