Add qtprotobufgen Oneof generator tests

Change-Id: I0982492014a668897ea81ab5a7d13a070b88f144
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Konrad Kujawa 2023-03-30 12:48:52 +02:00
parent b2f65ad936
commit f674a912b1
9 changed files with 1385 additions and 0 deletions

View File

@ -36,6 +36,7 @@ qt_add_protobuf(tst_qtprotobufgen
PROTO_FILES PROTO_FILES
../shared/data/proto/basicmessages.proto ../shared/data/proto/basicmessages.proto
../shared/data/proto/mapmessages.proto ../shared/data/proto/mapmessages.proto
../shared/data/proto/oneofmessages.proto
../shared/data/proto/repeatedmessages.proto ../shared/data/proto/repeatedmessages.proto
GENERATE_PACKAGE_SUBFOLDERS GENERATE_PACKAGE_SUBFOLDERS
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/qt_protobuf_generated/folder" OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/qt_protobuf_generated/folder"

View File

@ -0,0 +1,485 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "qtprotobufnamespace/tests/oneofmessages.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
namespace qtprotobufnamespace::tests {
OneofSimpleMessage::~OneofSimpleMessage() = default;
static constexpr struct {
QtProtobufPrivate::QProtobufPropertyOrdering::Data data;
const std::array<uint, 9> qt_protobuf_OneofSimpleMessage_uint_data;
const char qt_protobuf_OneofSimpleMessage_char_data[88];
} qt_protobuf_OneofSimpleMessage_metadata {
// data
{
0, /* = version */
2, /* = num fields */
3, /* = field number offset */
5, /* = property index offset */
7, /* = field flags offset */
44, /* = message full name length */
},
// uint_data
{
// JSON name offsets:
45, /* = testOneofFieldInt */
63, /* = testOneofFieldSecondInt */
87, /* = end-of-string-marker */
// Field numbers:
1, /* = testOneofFieldInt */
2, /* = testOneofFieldSecondInt */
// Property indices:
0, /* = testOneofFieldInt */
2, /* = testOneofFieldSecondInt */
// Field flags:
QtProtobufPrivate::Oneof, /* = testOneofFieldInt */
QtProtobufPrivate::Oneof, /* = testOneofFieldSecondInt */
},
// char_data
/* metadata char_data: */
"qtprotobufnamespace.tests.OneofSimpleMessage\0" /* = full message name */
/* field char_data: */
"testOneofFieldInt\0testOneofFieldSecondInt\0"
};
const QtProtobufPrivate::QProtobufPropertyOrdering OneofSimpleMessage::propertyOrdering = {
&qt_protobuf_OneofSimpleMessage_metadata.data
};
void OneofSimpleMessage::registerTypes()
{
qRegisterMetaType<OneofSimpleMessage>();
qRegisterMetaType<OneofSimpleMessageRepeated>();
}
OneofSimpleMessage::OneofSimpleMessage()
: QProtobufMessage(&OneofSimpleMessage::staticMetaObject)
{
}
OneofSimpleMessage::OneofSimpleMessage(const OneofSimpleMessage &other)
: QProtobufMessage(other),
m_testOneof(other.m_testOneof)
{
}
OneofSimpleMessage &OneofSimpleMessage::operator =(const OneofSimpleMessage &other)
{
QProtobufMessage::operator=(other);
m_testOneof = other.m_testOneof;
return *this;
}
OneofSimpleMessage::OneofSimpleMessage(OneofSimpleMessage &&other) noexcept
: QProtobufMessage(std::move(other)),
m_testOneof(std::move(other.m_testOneof))
{
}
OneofSimpleMessage &OneofSimpleMessage::operator =(OneofSimpleMessage &&other) noexcept
{
QProtobufMessage::operator=(std::move(other));
m_testOneof = std::move(other.m_testOneof);
return *this;
}
bool OneofSimpleMessage::operator ==(const OneofSimpleMessage &other) const
{
return QProtobufMessage::isEqual(*this, other)
&& m_testOneof == other.m_testOneof
;
}
bool OneofSimpleMessage::operator !=(const OneofSimpleMessage &other) const
{
return !this->operator ==(other);
}
QtProtobuf::int32 OneofSimpleMessage::testOneofFieldInt_p() const
{
return m_testOneof.holdsField(1) ?
m_testOneof.value<QtProtobuf::int32>() : QtProtobuf::int32(0);
}
bool OneofSimpleMessage::hasTestOneofFieldInt() const
{
return m_testOneof.holdsField(1);
}
QtProtobuf::int32 OneofSimpleMessage::testOneofFieldInt() const
{
Q_ASSERT(m_testOneof.holdsField(1));
return m_testOneof.value<QtProtobuf::int32>();
}
QtProtobuf::int32 OneofSimpleMessage::testOneofFieldSecondInt_p() const
{
return m_testOneof.holdsField(2) ?
m_testOneof.value<QtProtobuf::int32>() : QtProtobuf::int32(0);
}
bool OneofSimpleMessage::hasTestOneofFieldSecondInt() const
{
return m_testOneof.holdsField(2);
}
QtProtobuf::int32 OneofSimpleMessage::testOneofFieldSecondInt() const
{
Q_ASSERT(m_testOneof.holdsField(2));
return m_testOneof.value<QtProtobuf::int32>();
}
void OneofSimpleMessage::setTestOneofFieldInt(const QtProtobuf::int32 &testOneofFieldInt)
{
if (!m_testOneof.isEqual(testOneofFieldInt, 1)) {
m_testOneof.setValue(testOneofFieldInt, 1);
}
}
void OneofSimpleMessage::setTestOneofFieldInt_p(QtProtobuf::int32 testOneofFieldInt)
{
if (!m_testOneof.isEqual(testOneofFieldInt, 1))
m_testOneof.setValue(testOneofFieldInt, 1);
}
void OneofSimpleMessage::setTestOneofFieldSecondInt(const QtProtobuf::int32 &testOneofFieldSecondInt)
{
if (!m_testOneof.isEqual(testOneofFieldSecondInt, 2)) {
m_testOneof.setValue(testOneofFieldSecondInt, 2);
}
}
void OneofSimpleMessage::setTestOneofFieldSecondInt_p(QtProtobuf::int32 testOneofFieldSecondInt)
{
if (!m_testOneof.isEqual(testOneofFieldSecondInt, 2))
m_testOneof.setValue(testOneofFieldSecondInt, 2);
}
int OneofSimpleMessage::testOneofField() const
{
return m_testOneof.fieldNumber();
}
void OneofSimpleMessage::clearTestOneof()
{
m_testOneof = QtProtobufPrivate::QProtobufOneof();
}
OneofComplexMessage::~OneofComplexMessage() = default;
static constexpr struct {
QtProtobufPrivate::QProtobufPropertyOrdering::Data data;
const std::array<uint, 29> qt_protobuf_OneofComplexMessage_uint_data;
const char qt_protobuf_OneofComplexMessage_char_data[187];
} qt_protobuf_OneofComplexMessage_metadata {
// data
{
0, /* = version */
7, /* = num fields */
8, /* = field number offset */
15, /* = property index offset */
22, /* = field flags offset */
45, /* = message full name length */
},
// uint_data
{
// JSON name offsets:
46, /* = testFieldInt */
59, /* = testOneofFieldInt */
77, /* = testOneofComplexField */
99, /* = testOneofSecondComplexField */
127, /* = secondFieldInt */
142, /* = secondComplexField */
161, /* = secondSecondComplexField */
186, /* = end-of-string-marker */
// Field numbers:
1, /* = testFieldInt */
42, /* = testOneofFieldInt */
3, /* = testOneofComplexField */
4, /* = testOneofSecondComplexField */
43, /* = secondFieldInt */
5, /* = secondComplexField */
6, /* = secondSecondComplexField */
// Property indices:
0, /* = testFieldInt */
1, /* = testOneofFieldInt */
3, /* = testOneofComplexField */
5, /* = testOneofSecondComplexField */
7, /* = secondFieldInt */
9, /* = secondComplexField */
11, /* = secondSecondComplexField */
// Field flags:
QtProtobufPrivate::NoFlags, /* = testFieldInt */
QtProtobufPrivate::Oneof, /* = testOneofFieldInt */
QtProtobufPrivate::Oneof, /* = testOneofComplexField */
QtProtobufPrivate::Oneof, /* = testOneofSecondComplexField */
QtProtobufPrivate::Oneof, /* = secondFieldInt */
QtProtobufPrivate::Oneof, /* = secondComplexField */
QtProtobufPrivate::Oneof, /* = secondSecondComplexField */
},
// char_data
/* metadata char_data: */
"qtprotobufnamespace.tests.OneofComplexMessage\0" /* = full message name */
/* field char_data: */
"testFieldInt\0testOneofFieldInt\0testOneofComplexField\0testOneofSecondComplexField\0secondFieldInt\0"
"secondComplexField\0secondSecondComplexField\0"
};
const QtProtobufPrivate::QProtobufPropertyOrdering OneofComplexMessage::propertyOrdering = {
&qt_protobuf_OneofComplexMessage_metadata.data
};
void OneofComplexMessage::registerTypes()
{
qRegisterMetaType<OneofComplexMessage>();
qRegisterMetaType<OneofComplexMessageRepeated>();
}
OneofComplexMessage::OneofComplexMessage()
: QProtobufMessage(&OneofComplexMessage::staticMetaObject),
m_testFieldInt(0)
{
}
OneofComplexMessage::OneofComplexMessage(const OneofComplexMessage &other)
: QProtobufMessage(other),
m_testFieldInt(other.m_testFieldInt),
m_testOneof(other.m_testOneof),
m_secondOneof(other.m_secondOneof)
{
}
OneofComplexMessage &OneofComplexMessage::operator =(const OneofComplexMessage &other)
{
QProtobufMessage::operator=(other);
setTestFieldInt(other.m_testFieldInt);
m_testOneof = other.m_testOneof;
m_secondOneof = other.m_secondOneof;
return *this;
}
OneofComplexMessage::OneofComplexMessage(OneofComplexMessage &&other) noexcept
: QProtobufMessage(std::move(other)),
m_testOneof(std::move(other.m_testOneof))
,
m_secondOneof(std::move(other.m_secondOneof))
{
setTestFieldInt(std::exchange(other.m_testFieldInt, 0));
}
OneofComplexMessage &OneofComplexMessage::operator =(OneofComplexMessage &&other) noexcept
{
QProtobufMessage::operator=(std::move(other));
setTestFieldInt(std::exchange(other.m_testFieldInt, 0));
m_testOneof = std::move(other.m_testOneof);
m_secondOneof = std::move(other.m_secondOneof);
return *this;
}
bool OneofComplexMessage::operator ==(const OneofComplexMessage &other) const
{
return QProtobufMessage::isEqual(*this, other)
&& m_testFieldInt == other.m_testFieldInt
&& m_testOneof == other.m_testOneof
&& m_secondOneof == other.m_secondOneof
;
}
bool OneofComplexMessage::operator !=(const OneofComplexMessage &other) const
{
return !this->operator ==(other);
}
QtProtobuf::int32 OneofComplexMessage::testOneofFieldInt_p() const
{
return m_testOneof.holdsField(42) ?
m_testOneof.value<QtProtobuf::int32>() : QtProtobuf::int32(0);
}
bool OneofComplexMessage::hasTestOneofFieldInt() const
{
return m_testOneof.holdsField(42);
}
QtProtobuf::int32 OneofComplexMessage::testOneofFieldInt() const
{
Q_ASSERT(m_testOneof.holdsField(42));
return m_testOneof.value<QtProtobuf::int32>();
}
ComplexMessage *OneofComplexMessage::testOneofComplexField_p() const
{
return m_testOneof.holdsField(3) ?
m_testOneof.value<ComplexMessage>() : nullptr;
}
bool OneofComplexMessage::hasTestOneofComplexField() const
{
return m_testOneof.holdsField(3);
}
ComplexMessage &OneofComplexMessage::testOneofComplexField() const
{
Q_ASSERT(m_testOneof.holdsField(3));
return *(m_testOneof.value<ComplexMessage>());
}
ComplexMessage *OneofComplexMessage::testOneofSecondComplexField_p() const
{
return m_testOneof.holdsField(4) ?
m_testOneof.value<ComplexMessage>() : nullptr;
}
bool OneofComplexMessage::hasTestOneofSecondComplexField() const
{
return m_testOneof.holdsField(4);
}
ComplexMessage &OneofComplexMessage::testOneofSecondComplexField() const
{
Q_ASSERT(m_testOneof.holdsField(4));
return *(m_testOneof.value<ComplexMessage>());
}
QtProtobuf::int32 OneofComplexMessage::secondFieldInt_p() const
{
return m_secondOneof.holdsField(43) ?
m_secondOneof.value<QtProtobuf::int32>() : QtProtobuf::int32(0);
}
bool OneofComplexMessage::hasSecondFieldInt() const
{
return m_secondOneof.holdsField(43);
}
QtProtobuf::int32 OneofComplexMessage::secondFieldInt() const
{
Q_ASSERT(m_secondOneof.holdsField(43));
return m_secondOneof.value<QtProtobuf::int32>();
}
ComplexMessage *OneofComplexMessage::secondComplexField_p() const
{
return m_secondOneof.holdsField(5) ?
m_secondOneof.value<ComplexMessage>() : nullptr;
}
bool OneofComplexMessage::hasSecondComplexField() const
{
return m_secondOneof.holdsField(5);
}
ComplexMessage &OneofComplexMessage::secondComplexField() const
{
Q_ASSERT(m_secondOneof.holdsField(5));
return *(m_secondOneof.value<ComplexMessage>());
}
ComplexMessage *OneofComplexMessage::secondSecondComplexField_p() const
{
return m_secondOneof.holdsField(6) ?
m_secondOneof.value<ComplexMessage>() : nullptr;
}
bool OneofComplexMessage::hasSecondSecondComplexField() const
{
return m_secondOneof.holdsField(6);
}
ComplexMessage &OneofComplexMessage::secondSecondComplexField() const
{
Q_ASSERT(m_secondOneof.holdsField(6));
return *(m_secondOneof.value<ComplexMessage>());
}
void OneofComplexMessage::setTestOneofFieldInt(const QtProtobuf::int32 &testOneofFieldInt)
{
if (!m_testOneof.isEqual(testOneofFieldInt, 42)) {
m_testOneof.setValue(testOneofFieldInt, 42);
}
}
void OneofComplexMessage::setTestOneofFieldInt_p(QtProtobuf::int32 testOneofFieldInt)
{
if (!m_testOneof.isEqual(testOneofFieldInt, 42))
m_testOneof.setValue(testOneofFieldInt, 42);
}
void OneofComplexMessage::setTestOneofComplexField(const ComplexMessage &testOneofComplexField)
{
if (!m_testOneof.isEqual(testOneofComplexField, 3)) {
m_testOneof.setValue(testOneofComplexField, 3);
}
}
void OneofComplexMessage::setTestOneofComplexField_p(ComplexMessage *testOneofComplexField)
{
const ComplexMessage &value = *testOneofComplexField; if (!m_testOneof.isEqual(value, 3))
m_testOneof.setValue(value, 3);
}
void OneofComplexMessage::setTestOneofSecondComplexField(const ComplexMessage &testOneofSecondComplexField)
{
if (!m_testOneof.isEqual(testOneofSecondComplexField, 4)) {
m_testOneof.setValue(testOneofSecondComplexField, 4);
}
}
void OneofComplexMessage::setTestOneofSecondComplexField_p(ComplexMessage *testOneofSecondComplexField)
{
const ComplexMessage &value = *testOneofSecondComplexField; if (!m_testOneof.isEqual(value, 4))
m_testOneof.setValue(value, 4);
}
void OneofComplexMessage::setSecondFieldInt(const QtProtobuf::int32 &secondFieldInt)
{
if (!m_secondOneof.isEqual(secondFieldInt, 43)) {
m_secondOneof.setValue(secondFieldInt, 43);
}
}
void OneofComplexMessage::setSecondFieldInt_p(QtProtobuf::int32 secondFieldInt)
{
if (!m_secondOneof.isEqual(secondFieldInt, 43))
m_secondOneof.setValue(secondFieldInt, 43);
}
void OneofComplexMessage::setSecondComplexField(const ComplexMessage &secondComplexField)
{
if (!m_secondOneof.isEqual(secondComplexField, 5)) {
m_secondOneof.setValue(secondComplexField, 5);
}
}
void OneofComplexMessage::setSecondComplexField_p(ComplexMessage *secondComplexField)
{
const ComplexMessage &value = *secondComplexField; if (!m_secondOneof.isEqual(value, 5))
m_secondOneof.setValue(value, 5);
}
void OneofComplexMessage::setSecondSecondComplexField(const ComplexMessage &secondSecondComplexField)
{
if (!m_secondOneof.isEqual(secondSecondComplexField, 6)) {
m_secondOneof.setValue(secondSecondComplexField, 6);
}
}
void OneofComplexMessage::setSecondSecondComplexField_p(ComplexMessage *secondSecondComplexField)
{
const ComplexMessage &value = *secondSecondComplexField; if (!m_secondOneof.isEqual(value, 6))
m_secondOneof.setValue(value, 6);
}
int OneofComplexMessage::testOneofField() const
{
return m_testOneof.fieldNumber();
}
void OneofComplexMessage::clearTestOneof()
{
m_testOneof = QtProtobufPrivate::QProtobufOneof();
}
int OneofComplexMessage::secondOneofField() const
{
return m_secondOneof.fieldNumber();
}
void OneofComplexMessage::clearSecondOneof()
{
m_secondOneof = QtProtobufPrivate::QProtobufOneof();
}
} // namespace qtprotobufnamespace::tests
#include "moc_oneofmessages.qpb.cpp"

View File

@ -0,0 +1,174 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#ifndef QPROTOBUF_ONEOFMESSAGES_H
#define QPROTOBUF_ONEOFMESSAGES_H
#include <QtProtobuf/qprotobufmessage.h>
#include <QtProtobuf/qprotobufobject.h>
#include <QtProtobuf/qprotobuflazymessagepointer.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qstring.h>
#include <QtProtobuf/qprotobufoneof.h>
#include "basicmessages.qpb.h"
#include <QtCore/qmetatype.h>
#include <QtCore/qlist.h>
#include <memory>
namespace qtprotobufnamespace::tests {
class OneofSimpleMessage;
using OneofSimpleMessageRepeated = QList<std::shared_ptr<OneofSimpleMessage>>;
class OneofComplexMessage;
using OneofComplexMessageRepeated = QList<std::shared_ptr<OneofComplexMessage>>;
class OneofSimpleMessage : public QProtobufMessage
{
Q_GADGET
Q_PROTOBUF_OBJECT
Q_DECLARE_PROTOBUF_SERIALIZERS(OneofSimpleMessage)
Q_PROPERTY(QtProtobuf::int32 testOneofFieldInt READ testOneofFieldInt_p WRITE setTestOneofFieldInt_p)
Q_PROPERTY(bool hasTestOneofFieldInt READ hasTestOneofFieldInt)
Q_PROPERTY(QtProtobuf::int32 testOneofFieldSecondInt READ testOneofFieldSecondInt_p WRITE setTestOneofFieldSecondInt_p)
Q_PROPERTY(bool hasTestOneofFieldSecondInt READ hasTestOneofFieldSecondInt)
public:
enum QtProtobufFieldEnum {
TestOneofFieldIntProtoFieldNumber = 1,
TestOneofFieldSecondIntProtoFieldNumber = 2,
};
Q_ENUM(QtProtobufFieldEnum)
OneofSimpleMessage();
~OneofSimpleMessage();
OneofSimpleMessage(const OneofSimpleMessage &other);
OneofSimpleMessage &operator =(const OneofSimpleMessage &other);
OneofSimpleMessage(OneofSimpleMessage &&other) noexcept;
OneofSimpleMessage &operator =(OneofSimpleMessage &&other) noexcept;
bool operator ==(const OneofSimpleMessage &other) const;
bool operator !=(const OneofSimpleMessage &other) const;
bool hasTestOneofFieldInt() const;
QtProtobuf::int32 testOneofFieldInt() const;
bool hasTestOneofFieldSecondInt() const;
QtProtobuf::int32 testOneofFieldSecondInt() const;
int testOneofField() const;
void setTestOneofFieldInt(const QtProtobuf::int32 &testOneofFieldInt);
void setTestOneofFieldSecondInt(const QtProtobuf::int32 &testOneofFieldSecondInt);
void clearTestOneof();
static void registerTypes();
private:
QtProtobuf::int32 testOneofFieldInt_p() const;
QtProtobuf::int32 testOneofFieldSecondInt_p() const;
void setTestOneofFieldInt_p(QtProtobuf::int32 testOneofFieldInt);
void setTestOneofFieldSecondInt_p(QtProtobuf::int32 testOneofFieldSecondInt);
QtProtobufPrivate::QProtobufOneof m_testOneof;
};
class OneofComplexMessage : public QProtobufMessage
{
Q_GADGET
Q_PROTOBUF_OBJECT
Q_DECLARE_PROTOBUF_SERIALIZERS(OneofComplexMessage)
Q_PROPERTY(QtProtobuf::int32 testFieldInt READ testFieldInt WRITE setTestFieldInt SCRIPTABLE true)
Q_PROPERTY(QtProtobuf::int32 testOneofFieldInt READ testOneofFieldInt_p WRITE setTestOneofFieldInt_p)
Q_PROPERTY(bool hasTestOneofFieldInt READ hasTestOneofFieldInt)
Q_PROPERTY(qtprotobufnamespace::tests::ComplexMessage *testOneofComplexField READ testOneofComplexField_p WRITE setTestOneofComplexField_p)
Q_PROPERTY(bool hasTestOneofComplexField READ hasTestOneofComplexField)
Q_PROPERTY(qtprotobufnamespace::tests::ComplexMessage *testOneofSecondComplexField READ testOneofSecondComplexField_p WRITE setTestOneofSecondComplexField_p)
Q_PROPERTY(bool hasTestOneofSecondComplexField READ hasTestOneofSecondComplexField)
Q_PROPERTY(QtProtobuf::int32 secondFieldInt READ secondFieldInt_p WRITE setSecondFieldInt_p)
Q_PROPERTY(bool hasSecondFieldInt READ hasSecondFieldInt)
Q_PROPERTY(qtprotobufnamespace::tests::ComplexMessage *secondComplexField READ secondComplexField_p WRITE setSecondComplexField_p)
Q_PROPERTY(bool hasSecondComplexField READ hasSecondComplexField)
Q_PROPERTY(qtprotobufnamespace::tests::ComplexMessage *secondSecondComplexField READ secondSecondComplexField_p WRITE setSecondSecondComplexField_p)
Q_PROPERTY(bool hasSecondSecondComplexField READ hasSecondSecondComplexField)
public:
enum QtProtobufFieldEnum {
TestFieldIntProtoFieldNumber = 1,
TestOneofFieldIntProtoFieldNumber = 42,
TestOneofComplexFieldProtoFieldNumber = 3,
TestOneofSecondComplexFieldProtoFieldNumber = 4,
SecondFieldIntProtoFieldNumber = 43,
SecondComplexFieldProtoFieldNumber = 5,
SecondSecondComplexFieldProtoFieldNumber = 6,
};
Q_ENUM(QtProtobufFieldEnum)
OneofComplexMessage();
~OneofComplexMessage();
OneofComplexMessage(const OneofComplexMessage &other);
OneofComplexMessage &operator =(const OneofComplexMessage &other);
OneofComplexMessage(OneofComplexMessage &&other) noexcept;
OneofComplexMessage &operator =(OneofComplexMessage &&other) noexcept;
bool operator ==(const OneofComplexMessage &other) const;
bool operator !=(const OneofComplexMessage &other) const;
QtProtobuf::int32 testFieldInt() const
{
return m_testFieldInt;
}
bool hasTestOneofFieldInt() const;
QtProtobuf::int32 testOneofFieldInt() const;
bool hasTestOneofComplexField() const;
ComplexMessage &testOneofComplexField() const;
bool hasTestOneofSecondComplexField() const;
ComplexMessage &testOneofSecondComplexField() const;
bool hasSecondFieldInt() const;
QtProtobuf::int32 secondFieldInt() const;
bool hasSecondComplexField() const;
ComplexMessage &secondComplexField() const;
bool hasSecondSecondComplexField() const;
ComplexMessage &secondSecondComplexField() const;
int testOneofField() const;
int secondOneofField() const;
void setTestFieldInt(const QtProtobuf::int32 &testFieldInt)
{
if (m_testFieldInt != testFieldInt)
m_testFieldInt = testFieldInt;
}
void setTestOneofFieldInt(const QtProtobuf::int32 &testOneofFieldInt);
void setTestOneofComplexField(const ComplexMessage &testOneofComplexField);
void setTestOneofSecondComplexField(const ComplexMessage &testOneofSecondComplexField);
void setSecondFieldInt(const QtProtobuf::int32 &secondFieldInt);
void setSecondComplexField(const ComplexMessage &secondComplexField);
void setSecondSecondComplexField(const ComplexMessage &secondSecondComplexField);
void clearTestOneof();
void clearSecondOneof();
static void registerTypes();
private:
QtProtobuf::int32 testOneofFieldInt_p() const;
ComplexMessage *testOneofComplexField_p() const;
ComplexMessage *testOneofSecondComplexField_p() const;
QtProtobuf::int32 secondFieldInt_p() const;
ComplexMessage *secondComplexField_p() const;
ComplexMessage *secondSecondComplexField_p() const;
void setTestOneofFieldInt_p(QtProtobuf::int32 testOneofFieldInt);
void setTestOneofComplexField_p(ComplexMessage *testOneofComplexField);
void setTestOneofSecondComplexField_p(ComplexMessage *testOneofSecondComplexField);
void setSecondFieldInt_p(QtProtobuf::int32 secondFieldInt);
void setSecondComplexField_p(ComplexMessage *secondComplexField);
void setSecondSecondComplexField_p(ComplexMessage *secondSecondComplexField);
QtProtobuf::int32 m_testFieldInt;
QtProtobufPrivate::QProtobufOneof m_testOneof;
QtProtobufPrivate::QProtobufOneof m_secondOneof;
};
} // namespace qtprotobufnamespace::tests
Q_DECLARE_METATYPE(qtprotobufnamespace::tests::OneofSimpleMessage)
Q_DECLARE_METATYPE(qtprotobufnamespace::tests::OneofComplexMessage)
#endif // QPROTOBUF_ONEOFMESSAGES_H

View File

@ -0,0 +1,8 @@
#include <QtProtobuf/qprotobufserializer.h>
#include "qtprotobufnamespace/tests/oneofmessages.qpb.h"
namespace qtprotobufnamespace::tests {
static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarOneofSimpleMessage(qRegisterProtobufType<OneofSimpleMessage>);
static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarOneofComplexMessage(qRegisterProtobufType<OneofComplexMessage>);
} // namespace qtprotobufnamespace::tests

View File

@ -0,0 +1,485 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#include "oneofmessages.qpb.h"
#include <QtProtobuf/qprotobufserializer.h>
namespace qtprotobufnamespace::tests {
OneofSimpleMessage::~OneofSimpleMessage() = default;
static constexpr struct {
QtProtobufPrivate::QProtobufPropertyOrdering::Data data;
const std::array<uint, 9> qt_protobuf_OneofSimpleMessage_uint_data;
const char qt_protobuf_OneofSimpleMessage_char_data[88];
} qt_protobuf_OneofSimpleMessage_metadata {
// data
{
0, /* = version */
2, /* = num fields */
3, /* = field number offset */
5, /* = property index offset */
7, /* = field flags offset */
44, /* = message full name length */
},
// uint_data
{
// JSON name offsets:
45, /* = testOneofFieldInt */
63, /* = testOneofFieldSecondInt */
87, /* = end-of-string-marker */
// Field numbers:
1, /* = testOneofFieldInt */
2, /* = testOneofFieldSecondInt */
// Property indices:
0, /* = testOneofFieldInt */
2, /* = testOneofFieldSecondInt */
// Field flags:
QtProtobufPrivate::Oneof, /* = testOneofFieldInt */
QtProtobufPrivate::Oneof, /* = testOneofFieldSecondInt */
},
// char_data
/* metadata char_data: */
"qtprotobufnamespace.tests.OneofSimpleMessage\0" /* = full message name */
/* field char_data: */
"testOneofFieldInt\0testOneofFieldSecondInt\0"
};
const QtProtobufPrivate::QProtobufPropertyOrdering OneofSimpleMessage::propertyOrdering = {
&qt_protobuf_OneofSimpleMessage_metadata.data
};
void OneofSimpleMessage::registerTypes()
{
qRegisterMetaType<OneofSimpleMessage>();
qRegisterMetaType<OneofSimpleMessageRepeated>();
}
OneofSimpleMessage::OneofSimpleMessage()
: QProtobufMessage(&OneofSimpleMessage::staticMetaObject)
{
}
OneofSimpleMessage::OneofSimpleMessage(const OneofSimpleMessage &other)
: QProtobufMessage(other),
m_testOneof(other.m_testOneof)
{
}
OneofSimpleMessage &OneofSimpleMessage::operator =(const OneofSimpleMessage &other)
{
QProtobufMessage::operator=(other);
m_testOneof = other.m_testOneof;
return *this;
}
OneofSimpleMessage::OneofSimpleMessage(OneofSimpleMessage &&other) noexcept
: QProtobufMessage(std::move(other)),
m_testOneof(std::move(other.m_testOneof))
{
}
OneofSimpleMessage &OneofSimpleMessage::operator =(OneofSimpleMessage &&other) noexcept
{
QProtobufMessage::operator=(std::move(other));
m_testOneof = std::move(other.m_testOneof);
return *this;
}
bool OneofSimpleMessage::operator ==(const OneofSimpleMessage &other) const
{
return QProtobufMessage::isEqual(*this, other)
&& m_testOneof == other.m_testOneof
;
}
bool OneofSimpleMessage::operator !=(const OneofSimpleMessage &other) const
{
return !this->operator ==(other);
}
QtProtobuf::int32 OneofSimpleMessage::testOneofFieldInt_p() const
{
return m_testOneof.holdsField(1) ?
m_testOneof.value<QtProtobuf::int32>() : QtProtobuf::int32(0);
}
bool OneofSimpleMessage::hasTestOneofFieldInt() const
{
return m_testOneof.holdsField(1);
}
QtProtobuf::int32 OneofSimpleMessage::testOneofFieldInt() const
{
Q_ASSERT(m_testOneof.holdsField(1));
return m_testOneof.value<QtProtobuf::int32>();
}
QtProtobuf::int32 OneofSimpleMessage::testOneofFieldSecondInt_p() const
{
return m_testOneof.holdsField(2) ?
m_testOneof.value<QtProtobuf::int32>() : QtProtobuf::int32(0);
}
bool OneofSimpleMessage::hasTestOneofFieldSecondInt() const
{
return m_testOneof.holdsField(2);
}
QtProtobuf::int32 OneofSimpleMessage::testOneofFieldSecondInt() const
{
Q_ASSERT(m_testOneof.holdsField(2));
return m_testOneof.value<QtProtobuf::int32>();
}
void OneofSimpleMessage::setTestOneofFieldInt(const QtProtobuf::int32 &testOneofFieldInt)
{
if (!m_testOneof.isEqual(testOneofFieldInt, 1)) {
m_testOneof.setValue(testOneofFieldInt, 1);
}
}
void OneofSimpleMessage::setTestOneofFieldInt_p(QtProtobuf::int32 testOneofFieldInt)
{
if (!m_testOneof.isEqual(testOneofFieldInt, 1))
m_testOneof.setValue(testOneofFieldInt, 1);
}
void OneofSimpleMessage::setTestOneofFieldSecondInt(const QtProtobuf::int32 &testOneofFieldSecondInt)
{
if (!m_testOneof.isEqual(testOneofFieldSecondInt, 2)) {
m_testOneof.setValue(testOneofFieldSecondInt, 2);
}
}
void OneofSimpleMessage::setTestOneofFieldSecondInt_p(QtProtobuf::int32 testOneofFieldSecondInt)
{
if (!m_testOneof.isEqual(testOneofFieldSecondInt, 2))
m_testOneof.setValue(testOneofFieldSecondInt, 2);
}
int OneofSimpleMessage::testOneofField() const
{
return m_testOneof.fieldNumber();
}
void OneofSimpleMessage::clearTestOneof()
{
m_testOneof = QtProtobufPrivate::QProtobufOneof();
}
OneofComplexMessage::~OneofComplexMessage() = default;
static constexpr struct {
QtProtobufPrivate::QProtobufPropertyOrdering::Data data;
const std::array<uint, 29> qt_protobuf_OneofComplexMessage_uint_data;
const char qt_protobuf_OneofComplexMessage_char_data[187];
} qt_protobuf_OneofComplexMessage_metadata {
// data
{
0, /* = version */
7, /* = num fields */
8, /* = field number offset */
15, /* = property index offset */
22, /* = field flags offset */
45, /* = message full name length */
},
// uint_data
{
// JSON name offsets:
46, /* = testFieldInt */
59, /* = testOneofFieldInt */
77, /* = testOneofComplexField */
99, /* = testOneofSecondComplexField */
127, /* = secondFieldInt */
142, /* = secondComplexField */
161, /* = secondSecondComplexField */
186, /* = end-of-string-marker */
// Field numbers:
1, /* = testFieldInt */
42, /* = testOneofFieldInt */
3, /* = testOneofComplexField */
4, /* = testOneofSecondComplexField */
43, /* = secondFieldInt */
5, /* = secondComplexField */
6, /* = secondSecondComplexField */
// Property indices:
0, /* = testFieldInt */
1, /* = testOneofFieldInt */
3, /* = testOneofComplexField */
5, /* = testOneofSecondComplexField */
7, /* = secondFieldInt */
9, /* = secondComplexField */
11, /* = secondSecondComplexField */
// Field flags:
QtProtobufPrivate::NoFlags, /* = testFieldInt */
QtProtobufPrivate::Oneof, /* = testOneofFieldInt */
QtProtobufPrivate::Oneof, /* = testOneofComplexField */
QtProtobufPrivate::Oneof, /* = testOneofSecondComplexField */
QtProtobufPrivate::Oneof, /* = secondFieldInt */
QtProtobufPrivate::Oneof, /* = secondComplexField */
QtProtobufPrivate::Oneof, /* = secondSecondComplexField */
},
// char_data
/* metadata char_data: */
"qtprotobufnamespace.tests.OneofComplexMessage\0" /* = full message name */
/* field char_data: */
"testFieldInt\0testOneofFieldInt\0testOneofComplexField\0testOneofSecondComplexField\0secondFieldInt\0"
"secondComplexField\0secondSecondComplexField\0"
};
const QtProtobufPrivate::QProtobufPropertyOrdering OneofComplexMessage::propertyOrdering = {
&qt_protobuf_OneofComplexMessage_metadata.data
};
void OneofComplexMessage::registerTypes()
{
qRegisterMetaType<OneofComplexMessage>();
qRegisterMetaType<OneofComplexMessageRepeated>();
}
OneofComplexMessage::OneofComplexMessage()
: QProtobufMessage(&OneofComplexMessage::staticMetaObject),
m_testFieldInt(0)
{
}
OneofComplexMessage::OneofComplexMessage(const OneofComplexMessage &other)
: QProtobufMessage(other),
m_testFieldInt(other.m_testFieldInt),
m_testOneof(other.m_testOneof),
m_secondOneof(other.m_secondOneof)
{
}
OneofComplexMessage &OneofComplexMessage::operator =(const OneofComplexMessage &other)
{
QProtobufMessage::operator=(other);
setTestFieldInt(other.m_testFieldInt);
m_testOneof = other.m_testOneof;
m_secondOneof = other.m_secondOneof;
return *this;
}
OneofComplexMessage::OneofComplexMessage(OneofComplexMessage &&other) noexcept
: QProtobufMessage(std::move(other)),
m_testOneof(std::move(other.m_testOneof))
,
m_secondOneof(std::move(other.m_secondOneof))
{
setTestFieldInt(std::exchange(other.m_testFieldInt, 0));
}
OneofComplexMessage &OneofComplexMessage::operator =(OneofComplexMessage &&other) noexcept
{
QProtobufMessage::operator=(std::move(other));
setTestFieldInt(std::exchange(other.m_testFieldInt, 0));
m_testOneof = std::move(other.m_testOneof);
m_secondOneof = std::move(other.m_secondOneof);
return *this;
}
bool OneofComplexMessage::operator ==(const OneofComplexMessage &other) const
{
return QProtobufMessage::isEqual(*this, other)
&& m_testFieldInt == other.m_testFieldInt
&& m_testOneof == other.m_testOneof
&& m_secondOneof == other.m_secondOneof
;
}
bool OneofComplexMessage::operator !=(const OneofComplexMessage &other) const
{
return !this->operator ==(other);
}
QtProtobuf::int32 OneofComplexMessage::testOneofFieldInt_p() const
{
return m_testOneof.holdsField(42) ?
m_testOneof.value<QtProtobuf::int32>() : QtProtobuf::int32(0);
}
bool OneofComplexMessage::hasTestOneofFieldInt() const
{
return m_testOneof.holdsField(42);
}
QtProtobuf::int32 OneofComplexMessage::testOneofFieldInt() const
{
Q_ASSERT(m_testOneof.holdsField(42));
return m_testOneof.value<QtProtobuf::int32>();
}
ComplexMessage *OneofComplexMessage::testOneofComplexField_p() const
{
return m_testOneof.holdsField(3) ?
m_testOneof.value<ComplexMessage>() : nullptr;
}
bool OneofComplexMessage::hasTestOneofComplexField() const
{
return m_testOneof.holdsField(3);
}
ComplexMessage &OneofComplexMessage::testOneofComplexField() const
{
Q_ASSERT(m_testOneof.holdsField(3));
return *(m_testOneof.value<ComplexMessage>());
}
ComplexMessage *OneofComplexMessage::testOneofSecondComplexField_p() const
{
return m_testOneof.holdsField(4) ?
m_testOneof.value<ComplexMessage>() : nullptr;
}
bool OneofComplexMessage::hasTestOneofSecondComplexField() const
{
return m_testOneof.holdsField(4);
}
ComplexMessage &OneofComplexMessage::testOneofSecondComplexField() const
{
Q_ASSERT(m_testOneof.holdsField(4));
return *(m_testOneof.value<ComplexMessage>());
}
QtProtobuf::int32 OneofComplexMessage::secondFieldInt_p() const
{
return m_secondOneof.holdsField(43) ?
m_secondOneof.value<QtProtobuf::int32>() : QtProtobuf::int32(0);
}
bool OneofComplexMessage::hasSecondFieldInt() const
{
return m_secondOneof.holdsField(43);
}
QtProtobuf::int32 OneofComplexMessage::secondFieldInt() const
{
Q_ASSERT(m_secondOneof.holdsField(43));
return m_secondOneof.value<QtProtobuf::int32>();
}
ComplexMessage *OneofComplexMessage::secondComplexField_p() const
{
return m_secondOneof.holdsField(5) ?
m_secondOneof.value<ComplexMessage>() : nullptr;
}
bool OneofComplexMessage::hasSecondComplexField() const
{
return m_secondOneof.holdsField(5);
}
ComplexMessage &OneofComplexMessage::secondComplexField() const
{
Q_ASSERT(m_secondOneof.holdsField(5));
return *(m_secondOneof.value<ComplexMessage>());
}
ComplexMessage *OneofComplexMessage::secondSecondComplexField_p() const
{
return m_secondOneof.holdsField(6) ?
m_secondOneof.value<ComplexMessage>() : nullptr;
}
bool OneofComplexMessage::hasSecondSecondComplexField() const
{
return m_secondOneof.holdsField(6);
}
ComplexMessage &OneofComplexMessage::secondSecondComplexField() const
{
Q_ASSERT(m_secondOneof.holdsField(6));
return *(m_secondOneof.value<ComplexMessage>());
}
void OneofComplexMessage::setTestOneofFieldInt(const QtProtobuf::int32 &testOneofFieldInt)
{
if (!m_testOneof.isEqual(testOneofFieldInt, 42)) {
m_testOneof.setValue(testOneofFieldInt, 42);
}
}
void OneofComplexMessage::setTestOneofFieldInt_p(QtProtobuf::int32 testOneofFieldInt)
{
if (!m_testOneof.isEqual(testOneofFieldInt, 42))
m_testOneof.setValue(testOneofFieldInt, 42);
}
void OneofComplexMessage::setTestOneofComplexField(const ComplexMessage &testOneofComplexField)
{
if (!m_testOneof.isEqual(testOneofComplexField, 3)) {
m_testOneof.setValue(testOneofComplexField, 3);
}
}
void OneofComplexMessage::setTestOneofComplexField_p(ComplexMessage *testOneofComplexField)
{
const ComplexMessage &value = *testOneofComplexField; if (!m_testOneof.isEqual(value, 3))
m_testOneof.setValue(value, 3);
}
void OneofComplexMessage::setTestOneofSecondComplexField(const ComplexMessage &testOneofSecondComplexField)
{
if (!m_testOneof.isEqual(testOneofSecondComplexField, 4)) {
m_testOneof.setValue(testOneofSecondComplexField, 4);
}
}
void OneofComplexMessage::setTestOneofSecondComplexField_p(ComplexMessage *testOneofSecondComplexField)
{
const ComplexMessage &value = *testOneofSecondComplexField; if (!m_testOneof.isEqual(value, 4))
m_testOneof.setValue(value, 4);
}
void OneofComplexMessage::setSecondFieldInt(const QtProtobuf::int32 &secondFieldInt)
{
if (!m_secondOneof.isEqual(secondFieldInt, 43)) {
m_secondOneof.setValue(secondFieldInt, 43);
}
}
void OneofComplexMessage::setSecondFieldInt_p(QtProtobuf::int32 secondFieldInt)
{
if (!m_secondOneof.isEqual(secondFieldInt, 43))
m_secondOneof.setValue(secondFieldInt, 43);
}
void OneofComplexMessage::setSecondComplexField(const ComplexMessage &secondComplexField)
{
if (!m_secondOneof.isEqual(secondComplexField, 5)) {
m_secondOneof.setValue(secondComplexField, 5);
}
}
void OneofComplexMessage::setSecondComplexField_p(ComplexMessage *secondComplexField)
{
const ComplexMessage &value = *secondComplexField; if (!m_secondOneof.isEqual(value, 5))
m_secondOneof.setValue(value, 5);
}
void OneofComplexMessage::setSecondSecondComplexField(const ComplexMessage &secondSecondComplexField)
{
if (!m_secondOneof.isEqual(secondSecondComplexField, 6)) {
m_secondOneof.setValue(secondSecondComplexField, 6);
}
}
void OneofComplexMessage::setSecondSecondComplexField_p(ComplexMessage *secondSecondComplexField)
{
const ComplexMessage &value = *secondSecondComplexField; if (!m_secondOneof.isEqual(value, 6))
m_secondOneof.setValue(value, 6);
}
int OneofComplexMessage::testOneofField() const
{
return m_testOneof.fieldNumber();
}
void OneofComplexMessage::clearTestOneof()
{
m_testOneof = QtProtobufPrivate::QProtobufOneof();
}
int OneofComplexMessage::secondOneofField() const
{
return m_secondOneof.fieldNumber();
}
void OneofComplexMessage::clearSecondOneof()
{
m_secondOneof = QtProtobufPrivate::QProtobufOneof();
}
} // namespace qtprotobufnamespace::tests
#include "moc_oneofmessages.qpb.cpp"

View File

@ -0,0 +1,174 @@
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
#ifndef QPROTOBUF_ONEOFMESSAGES_H
#define QPROTOBUF_ONEOFMESSAGES_H
#include <QtProtobuf/qprotobufmessage.h>
#include <QtProtobuf/qprotobufobject.h>
#include <QtProtobuf/qprotobuflazymessagepointer.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qstring.h>
#include <QtProtobuf/qprotobufoneof.h>
#include "basicmessages.qpb.h"
#include <QtCore/qmetatype.h>
#include <QtCore/qlist.h>
#include <memory>
namespace qtprotobufnamespace::tests {
class OneofSimpleMessage;
using OneofSimpleMessageRepeated = QList<std::shared_ptr<OneofSimpleMessage>>;
class OneofComplexMessage;
using OneofComplexMessageRepeated = QList<std::shared_ptr<OneofComplexMessage>>;
class OneofSimpleMessage : public QProtobufMessage
{
Q_GADGET
Q_PROTOBUF_OBJECT
Q_DECLARE_PROTOBUF_SERIALIZERS(OneofSimpleMessage)
Q_PROPERTY(QtProtobuf::int32 testOneofFieldInt READ testOneofFieldInt_p WRITE setTestOneofFieldInt_p)
Q_PROPERTY(bool hasTestOneofFieldInt READ hasTestOneofFieldInt)
Q_PROPERTY(QtProtobuf::int32 testOneofFieldSecondInt READ testOneofFieldSecondInt_p WRITE setTestOneofFieldSecondInt_p)
Q_PROPERTY(bool hasTestOneofFieldSecondInt READ hasTestOneofFieldSecondInt)
public:
enum QtProtobufFieldEnum {
TestOneofFieldIntProtoFieldNumber = 1,
TestOneofFieldSecondIntProtoFieldNumber = 2,
};
Q_ENUM(QtProtobufFieldEnum)
OneofSimpleMessage();
~OneofSimpleMessage();
OneofSimpleMessage(const OneofSimpleMessage &other);
OneofSimpleMessage &operator =(const OneofSimpleMessage &other);
OneofSimpleMessage(OneofSimpleMessage &&other) noexcept;
OneofSimpleMessage &operator =(OneofSimpleMessage &&other) noexcept;
bool operator ==(const OneofSimpleMessage &other) const;
bool operator !=(const OneofSimpleMessage &other) const;
bool hasTestOneofFieldInt() const;
QtProtobuf::int32 testOneofFieldInt() const;
bool hasTestOneofFieldSecondInt() const;
QtProtobuf::int32 testOneofFieldSecondInt() const;
int testOneofField() const;
void setTestOneofFieldInt(const QtProtobuf::int32 &testOneofFieldInt);
void setTestOneofFieldSecondInt(const QtProtobuf::int32 &testOneofFieldSecondInt);
void clearTestOneof();
static void registerTypes();
private:
QtProtobuf::int32 testOneofFieldInt_p() const;
QtProtobuf::int32 testOneofFieldSecondInt_p() const;
void setTestOneofFieldInt_p(QtProtobuf::int32 testOneofFieldInt);
void setTestOneofFieldSecondInt_p(QtProtobuf::int32 testOneofFieldSecondInt);
QtProtobufPrivate::QProtobufOneof m_testOneof;
};
class OneofComplexMessage : public QProtobufMessage
{
Q_GADGET
Q_PROTOBUF_OBJECT
Q_DECLARE_PROTOBUF_SERIALIZERS(OneofComplexMessage)
Q_PROPERTY(QtProtobuf::int32 testFieldInt READ testFieldInt WRITE setTestFieldInt SCRIPTABLE true)
Q_PROPERTY(QtProtobuf::int32 testOneofFieldInt READ testOneofFieldInt_p WRITE setTestOneofFieldInt_p)
Q_PROPERTY(bool hasTestOneofFieldInt READ hasTestOneofFieldInt)
Q_PROPERTY(qtprotobufnamespace::tests::ComplexMessage *testOneofComplexField READ testOneofComplexField_p WRITE setTestOneofComplexField_p)
Q_PROPERTY(bool hasTestOneofComplexField READ hasTestOneofComplexField)
Q_PROPERTY(qtprotobufnamespace::tests::ComplexMessage *testOneofSecondComplexField READ testOneofSecondComplexField_p WRITE setTestOneofSecondComplexField_p)
Q_PROPERTY(bool hasTestOneofSecondComplexField READ hasTestOneofSecondComplexField)
Q_PROPERTY(QtProtobuf::int32 secondFieldInt READ secondFieldInt_p WRITE setSecondFieldInt_p)
Q_PROPERTY(bool hasSecondFieldInt READ hasSecondFieldInt)
Q_PROPERTY(qtprotobufnamespace::tests::ComplexMessage *secondComplexField READ secondComplexField_p WRITE setSecondComplexField_p)
Q_PROPERTY(bool hasSecondComplexField READ hasSecondComplexField)
Q_PROPERTY(qtprotobufnamespace::tests::ComplexMessage *secondSecondComplexField READ secondSecondComplexField_p WRITE setSecondSecondComplexField_p)
Q_PROPERTY(bool hasSecondSecondComplexField READ hasSecondSecondComplexField)
public:
enum QtProtobufFieldEnum {
TestFieldIntProtoFieldNumber = 1,
TestOneofFieldIntProtoFieldNumber = 42,
TestOneofComplexFieldProtoFieldNumber = 3,
TestOneofSecondComplexFieldProtoFieldNumber = 4,
SecondFieldIntProtoFieldNumber = 43,
SecondComplexFieldProtoFieldNumber = 5,
SecondSecondComplexFieldProtoFieldNumber = 6,
};
Q_ENUM(QtProtobufFieldEnum)
OneofComplexMessage();
~OneofComplexMessage();
OneofComplexMessage(const OneofComplexMessage &other);
OneofComplexMessage &operator =(const OneofComplexMessage &other);
OneofComplexMessage(OneofComplexMessage &&other) noexcept;
OneofComplexMessage &operator =(OneofComplexMessage &&other) noexcept;
bool operator ==(const OneofComplexMessage &other) const;
bool operator !=(const OneofComplexMessage &other) const;
QtProtobuf::int32 testFieldInt() const
{
return m_testFieldInt;
}
bool hasTestOneofFieldInt() const;
QtProtobuf::int32 testOneofFieldInt() const;
bool hasTestOneofComplexField() const;
ComplexMessage &testOneofComplexField() const;
bool hasTestOneofSecondComplexField() const;
ComplexMessage &testOneofSecondComplexField() const;
bool hasSecondFieldInt() const;
QtProtobuf::int32 secondFieldInt() const;
bool hasSecondComplexField() const;
ComplexMessage &secondComplexField() const;
bool hasSecondSecondComplexField() const;
ComplexMessage &secondSecondComplexField() const;
int testOneofField() const;
int secondOneofField() const;
void setTestFieldInt(const QtProtobuf::int32 &testFieldInt)
{
if (m_testFieldInt != testFieldInt)
m_testFieldInt = testFieldInt;
}
void setTestOneofFieldInt(const QtProtobuf::int32 &testOneofFieldInt);
void setTestOneofComplexField(const ComplexMessage &testOneofComplexField);
void setTestOneofSecondComplexField(const ComplexMessage &testOneofSecondComplexField);
void setSecondFieldInt(const QtProtobuf::int32 &secondFieldInt);
void setSecondComplexField(const ComplexMessage &secondComplexField);
void setSecondSecondComplexField(const ComplexMessage &secondSecondComplexField);
void clearTestOneof();
void clearSecondOneof();
static void registerTypes();
private:
QtProtobuf::int32 testOneofFieldInt_p() const;
ComplexMessage *testOneofComplexField_p() const;
ComplexMessage *testOneofSecondComplexField_p() const;
QtProtobuf::int32 secondFieldInt_p() const;
ComplexMessage *secondComplexField_p() const;
ComplexMessage *secondSecondComplexField_p() const;
void setTestOneofFieldInt_p(QtProtobuf::int32 testOneofFieldInt);
void setTestOneofComplexField_p(ComplexMessage *testOneofComplexField);
void setTestOneofSecondComplexField_p(ComplexMessage *testOneofSecondComplexField);
void setSecondFieldInt_p(QtProtobuf::int32 secondFieldInt);
void setSecondComplexField_p(ComplexMessage *secondComplexField);
void setSecondSecondComplexField_p(ComplexMessage *secondSecondComplexField);
QtProtobuf::int32 m_testFieldInt;
QtProtobufPrivate::QProtobufOneof m_testOneof;
QtProtobufPrivate::QProtobufOneof m_secondOneof;
};
} // namespace qtprotobufnamespace::tests
Q_DECLARE_METATYPE(qtprotobufnamespace::tests::OneofSimpleMessage)
Q_DECLARE_METATYPE(qtprotobufnamespace::tests::OneofComplexMessage)
#endif // QPROTOBUF_ONEOFMESSAGES_H

View File

@ -0,0 +1,8 @@
#include <QtProtobuf/qprotobufserializer.h>
#include "oneofmessages.qpb.h"
namespace qtprotobufnamespace::tests {
static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarOneofSimpleMessage(qRegisterProtobufType<OneofSimpleMessage>);
static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarOneofComplexMessage(qRegisterProtobufType<OneofComplexMessage>);
} // namespace qtprotobufnamespace::tests

View File

@ -220,6 +220,11 @@ void tst_qtprotobufgen::cmakeGeneratedFile_data()
<< "/folder/qtprotobufnamespace/tests/" << "/folder/qtprotobufnamespace/tests/"
<< QString(extension); << QString(extension);
QTest::addRow("oneofmessages%s", extension.data())
<< "oneofmessages"
<< "/folder/qtprotobufnamespace/tests/"
<< QString(extension);
QTest::addRow("repeatedmessages%s", extension.data()) QTest::addRow("repeatedmessages%s", extension.data())
<< "repeatedmessages" << "repeatedmessages"
<< "/folder/qtprotobufnamespace/tests/" << "/folder/qtprotobufnamespace/tests/"
@ -297,6 +302,13 @@ void tst_qtprotobufgen::cmdLineGeneratedFile_data()
<< QString(extension) << QString(extension)
<< "qtprotobufnamespace/tests/"; << "qtprotobufnamespace/tests/";
QTest::addRow("oneofmessages%s", extension.data())
<< "oneofmessages"
<< "GENERATE_PACKAGE_SUBFOLDERS"
<< "/folder/"
<< QString(extension)
<< "qtprotobufnamespace/tests/";
QTest::addRow("repeatedmessages%s", extension.data()) QTest::addRow("repeatedmessages%s", extension.data())
<< "repeatedmessages" << "repeatedmessages"
<< "GENERATE_PACKAGE_SUBFOLDERS" << "GENERATE_PACKAGE_SUBFOLDERS"
@ -421,6 +433,11 @@ void tst_qtprotobufgen::cmdLineGeneratedNoOptions_data()
<< "/no-options/" << "/no-options/"
<< QString(extension); << QString(extension);
QTest::addRow("oneofmessages%s", extension.data())
<< "oneofmessages"
<< "/no-options/"
<< QString(extension);
QTest::addRow("repeatedmessages%s", extension.data()) QTest::addRow("repeatedmessages%s", extension.data())
<< "repeatedmessages" << "repeatedmessages"
<< "/no-options/" << "/no-options/"

View File

@ -0,0 +1,33 @@
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
syntax = "proto3";
import "basicmessages.proto";
package qtprotobufnamespace.tests;
message OneofSimpleMessage
{
oneof testOneof
{
int32 testOneofFieldInt = 1;
int32 testOneofFieldSecondInt = 2;
}
}
message OneofComplexMessage
{
int32 testFieldInt = 1;
oneof testOneof
{
int32 testOneofFieldInt = 42;
ComplexMessage testOneofComplexField = 3;
ComplexMessage testOneofSecondComplexField = 4;
}
oneof secondOneof
{
int32 secondFieldInt = 43;
ComplexMessage secondComplexField = 5;
ComplexMessage secondSecondComplexField = 6;
}
}