QtProtobuf Namespace

The QtProtobuf namespace contains type aliases and classes needed to support Qt Protobuf. More...

Header: #include <QtProtobuf>
CMake: find_package(Qt6 REQUIRED COMPONENTS Protobuf)
target_link_libraries(mytarget PRIVATE Qt6::Protobuf)
Since: Qt 6.5

Types

enum class WireTypes { Unknown, Varint, Fixed64, LengthDelimited, StartGroup, …, Fixed32 }
sint32
sint64
uint32
uint64

Functions

Detailed Description

Type Documentation

enum class QtProtobuf::WireTypes

The WireTypes enumeration reflects protobuf default wiretypes.

The following table shows the values in the enumeration and their corresponding types:

ConstantValueDescription
QtProtobuf::WireTypes::Unknown-1Invalid wire type
QtProtobuf::WireTypes::Varint0int32, int64, uint32, uint64, sint32, sint64, bool, enum
QtProtobuf::WireTypes::Fixed641fixed64, sfixed64, double
QtProtobuf::WireTypes::LengthDelimited2string, bytes, embedded messages, packed repeated fields
QtProtobuf::WireTypes::StartGroup3groups. Deprecated in proto syntax 3. Not supported by Qt Protobuf.
QtProtobuf::WireTypes::EndGroup4groups. Deprecated in proto syntax 3. Not supported by Qt Protobuf.
QtProtobuf::WireTypes::Fixed325fixed32, sfixed32, float

See also encoding.

[alias] QtProtobuf::sint32

sint32 is a 32-bit integer with forced sign marker that is represented in protobuf as variable size integer, an alias for WireTypes::Varint. sint32 is serialized using ZigZag conversion to reduce size of negative numbers.

See also signed-integers.

[alias] QtProtobuf::sint64

sint64 is a 64-bit integer with forced sign marker that is represented in protobuf as variable size integer, an alias for WireTypes::Varint. sint64 is serialized using ZigZag conversion to reduce size of negative numbers.

See also signed-integers.

[alias] QtProtobuf::uint32

uint32 is an unsigned 32-bit integer that is represented in protobuf as variable size integer, an alias for WireTypes::Varint.

[alias] QtProtobuf::uint64

uint64 is an unsigned 64-bit integer that is represented in protobuf as variable size integer, an alias for WireTypes::Varint.

Function Documentation

template <typename T, std::enable_if_t<std::is_enum<T>::value, bool> = true> void qRegisterProtobufEnumType()

Registers serializers for enumeration type T in QtProtobuf global serializers registry.

This function is normally called by generated code.

template <typename K, typename V, int = true> void qRegisterProtobufMapType()

Registers a Protobuf map type K and V. V must be a QProtobufMessage. This function is normally called by generated code.

template <typename T, int = true> void qRegisterProtobufType()

Registers a Protobuf type T. This function is normally called by generated code.

Q_DECL_IMPORT qRegisterProtobufTypes()

Calling this function registers all, currently known, protobuf types with the serializer registry.

Note: Only since Qt 6.6.3 version you don't have to call this function manually, as it is called automatically. For earlier versions it's better to call it before serialization/deserialization attempt.