/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */


#include "non-final-properties.qpb.h"

#include <QtProtobuf/qprotobufregistration.h>

#include <cmath>


class TestMessages_QtProtobufData : public QSharedData
{
public:
    TestMessages_QtProtobufData()
        : QSharedData(),
          m_field1(0)
    {
    }

    TestMessages_QtProtobufData(const TestMessages_QtProtobufData &other)
        : QSharedData(other),
          m_field1(other.m_field1),
          m_field2(other.m_field2),
          m_field3(other.m_field3),
          m_field4(other.m_field4),
          m_fieldOneOf(other.m_fieldOneOf)
    {
    }

    QtProtobuf::int32 m_field1;
    QtProtobuf::uint32List m_field2;
    std::optional<QtProtobuf::sint32> m_field3;
    TestMessages::Field4Entry m_field4;
    QtProtobufPrivate::QProtobufOneof m_fieldOneOf;
};

TestMessages::~TestMessages() = default;

static constexpr struct {
    QtProtobufPrivate::QProtobufPropertyOrdering::Data data;
    const std::array<uint, 25> qt_protobuf_TestMessages_uint_data;
    const char qt_protobuf_TestMessages_char_data[56];
} qt_protobuf_TestMessages_metadata {
    // data
    {
        0, /* = version */
        6, /* = num fields */
        7, /* = field number offset */
        13, /* = property index offset */
        19, /* = field flags offset */
        12, /* = message full name length */
    },
    // uint_data
    {
        // JSON name offsets:
        13, /* = field1 */
        20, /* = field2 */
        27, /* = field3 */
        34, /* = field4 */
        41, /* = field5 */
        48, /* = field6 */
        55, /* = end-of-string-marker */
        // Field numbers:
        1, /* = field1 */
        2, /* = field2 */
        3, /* = field3 */
        4, /* = field4 */
        5, /* = field5 */
        6, /* = field6 */
        // Property indices:
        0, /* = field1 */
        1, /* = field2 */
        2, /* = field3 */
        4, /* = field4 */
        5, /* = field5 */
        7, /* = field6 */
        // Field flags:
        uint(QtProtobufPrivate::FieldFlag::NoFlags), /* = field1 */
        uint(QtProtobufPrivate::FieldFlag::Repeated), /* = field2 */
        uint(QtProtobufPrivate::FieldFlag::Optional | QtProtobufPrivate::FieldFlag::ExplicitPresence), /* = field3 */
        uint(QtProtobufPrivate::FieldFlag::Map | QtProtobufPrivate::FieldFlag::Message), /* = field4 */
        uint(QtProtobufPrivate::FieldFlag::Oneof | QtProtobufPrivate::FieldFlag::ExplicitPresence), /* = field5 */
        uint(QtProtobufPrivate::FieldFlag::Oneof | QtProtobufPrivate::FieldFlag::ExplicitPresence), /* = field6 */
    },
    // char_data
    /* metadata char_data: */
    "TestMessages\0" /* = full message name */
    /* field char_data: */
    "field1\0field2\0field3\0field4\0field5\0"
    "field6\0"
};

const QtProtobufPrivate::QProtobufPropertyOrdering TestMessages::staticPropertyOrdering = {
    &qt_protobuf_TestMessages_metadata.data
};

void TestMessages::registerTypes()
{
    qRegisterMetaType<TestMessages>();
    qRegisterMetaType<QList<TestMessages>>();
    qRegisterMetaType<TestMessages::Field4Entry>();
    qRegisterProtobufMapType<QtProtobuf::sint64, QtProtobuf::uint32>();
}

TestMessages::TestMessages()
    : QProtobufMessage(&TestMessages::staticMetaObject, &TestMessages::staticPropertyOrdering),
      dptr(new TestMessages_QtProtobufData)
{
}

TestMessages::TestMessages(const TestMessages &other)
    = default;
TestMessages &TestMessages::operator =(const TestMessages &other)
{
    TestMessages temp(other);
    swap(temp);
    return *this;
}
TestMessages::TestMessages(TestMessages &&other) noexcept
    = default;
TestMessages::operator QVariant() const
{
    return QVariant::fromValue(*this);
}
bool comparesEqual(const TestMessages &lhs, const TestMessages &rhs) noexcept
{
    return operator ==(static_cast<const QProtobufMessage&>(lhs),
                       static_cast<const QProtobufMessage&>(rhs))
        && lhs.dptr->m_field1 == rhs.dptr->m_field1
        && lhs.dptr->m_field2 == rhs.dptr->m_field2
        && lhs.dptr->m_field3 == rhs.dptr->m_field3
        && lhs.dptr->m_field4 == rhs.dptr->m_field4
        && lhs.dptr->m_fieldOneOf == rhs.dptr->m_fieldOneOf;
}

QtProtobuf::int32 TestMessages::field1() const
{
    return dptr->m_field1;
}

const QtProtobuf::uint32List &TestMessages::field2() const &
{
    return dptr->m_field2;
}

QtProtobuf::sint32 TestMessages::field3_p() const
{
    return dptr->m_field3 ?
        dptr->m_field3.value() : QtProtobuf::sint32();
}

bool TestMessages::hasField3() const
{
    return dptr->m_field3.has_value();
}
QtProtobuf::sint32 TestMessages::field3() const
{
    Q_ASSERT(dptr->m_field3.has_value());
    return dptr->m_field3.value();
}

const TestMessages::Field4Entry &TestMessages::field4() const &
{
    return dptr->m_field4;
}

QtProtobuf::uint64 TestMessages::field5_p() const
{
    return dptr->m_fieldOneOf.holdsField(5) ?
        dptr->m_fieldOneOf.value<QtProtobuf::uint64>() : QtProtobuf::uint64(0);
}

bool TestMessages::hasField5() const
{
    return dptr->m_fieldOneOf.holdsField(5);
}
QtProtobuf::uint64 TestMessages::field5() const
{
    Q_ASSERT(dptr->m_fieldOneOf.holdsField(5));
    return dptr->m_fieldOneOf.value<QtProtobuf::uint64>();
}

float TestMessages::field6_p() const
{
    return dptr->m_fieldOneOf.holdsField(6) ?
        dptr->m_fieldOneOf.value<float>() : float(0.0);
}

bool TestMessages::hasField6() const
{
    return dptr->m_fieldOneOf.holdsField(6);
}
float TestMessages::field6() const
{
    Q_ASSERT(dptr->m_fieldOneOf.holdsField(6));
    return dptr->m_fieldOneOf.value<float>();
}

void TestMessages::setField1(QtProtobuf::int32 field1)
{
    if (dptr->m_field1 != field1) {
        dptr.detach();
        dptr->m_field1 = field1;
    }
}

void TestMessages::setField2(const QtProtobuf::uint32List &field2)
{
    if (dptr->m_field2 != field2) {
        dptr.detach();
        dptr->m_field2 = field2;
    }
}

void TestMessages::setField2(QtProtobuf::uint32List &&field2)
{
    if (dptr->m_field2 != field2) {
        dptr.detach();
        dptr->m_field2 = std::move(field2);
    }
}

void TestMessages::setField3(QtProtobuf::sint32 field3)
{
    if (!dptr->m_field3 || dptr->m_field3.value() != field3) {
        dptr.detach();
        dptr->m_field3 = field3;
    }
}

void TestMessages::setField3_p(QtProtobuf::sint32 field3)
{
    if (!dptr->m_field3 || dptr->m_field3 != field3) {
        dptr.detach();
        dptr->m_field3 = field3;
    }
}

void TestMessages::clearField3()
{
    if (dptr->m_field3.has_value()) {
        dptr.detach();
        dptr->m_field3.reset();
    }
}
void TestMessages::setField4(const TestMessages::Field4Entry &field4)
{
    if (dptr->m_field4 != field4) {
        dptr.detach();
        dptr->m_field4 = field4;
    }
}

void TestMessages::setField4(TestMessages::Field4Entry &&field4)
{
    if (dptr->m_field4 != field4) {
        dptr.detach();
        dptr->m_field4 = std::move(field4);
    }
}

void TestMessages::setField5(QtProtobuf::uint64 field5)
{
    if (!dptr->m_fieldOneOf.isEqual(field5, 5)) {
        dptr.detach();
        dptr->m_fieldOneOf.setValue(field5, 5);
    }
}

void TestMessages::setField5_p(QtProtobuf::uint64 field5)
{
    if (!dptr->m_fieldOneOf.isEqual(field5, 5)) {
        dptr.detach();
        dptr->m_fieldOneOf.setValue(field5, 5);
    }
}

void TestMessages::setField6(float field6)
{
    if (!dptr->m_fieldOneOf.isEqual(field6, 6)) {
        dptr.detach();
        dptr->m_fieldOneOf.setValue(field6, 6);
    }
}

void TestMessages::setField6_p(float field6)
{
    if (!dptr->m_fieldOneOf.isEqual(field6, 6)) {
        dptr.detach();
        dptr->m_fieldOneOf.setValue(field6, 6);
    }
}

TestMessages::FieldOneOfFields TestMessages::fieldOneOfField() const
{
    return static_cast<FieldOneOfFields>(dptr->m_fieldOneOf.fieldNumber());
}
void TestMessages::clearFieldOneOf()
{
    if (dptr->m_fieldOneOf.fieldNumber() != QtProtobuf::InvalidFieldNumber) {
        dptr.detach();
        dptr->m_fieldOneOf = QtProtobufPrivate::QProtobufOneof();
    }
}

#include "moc_non-final-properties.qpb.cpp"
