Google Protobuf Well-Known types library for QtProtobuf.
Google Protobuf Well-Known types library for QtProtobuf.
QtProtobufWellKnownTypes contains follwing Protobuf Well-Known types:
- Any
- Timestamp
- Struct
- Value
- ListValue
- SourceContext
- DoubleValue
- FloatValue
- Int64Value
- UInt64Value
- Int32Value
- UInt32Value
- BoolValue
- StringValue
- BytesValue
- Type
- Field
- Enum
- EnumValue
- Option
- Empty
- FieldMask
- Api
- Method
- Mixin
- Duration
To use well-known type in your project you may include corresponding google .proto file in your interface:
syntax = "proto3";
package somepackage;
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
message AnimationMessage {
google.protobuf.Timestamp startTime = 2;
google.protobuf.Timestamp endTime = 3;
}
service AnimationService {
rpc startAnimation(AnimationMessage) returns (google.protobuf.Empty) {}
}
uint32_t uint32
uint32 unsigned 32-bit integer
Definition: qtprotobuftypes.h:120
It's also possible to use some of generated well-known types directly, simply include corresponding header:
#include <google/protobuf/any.qpb.h>
...
google::protobuf::Any someAnyVariable;
someAnyVariable.setType_url("http://somedomain.org/someTypeDescription");
someAnyVariable.setValue(data);
...
In both scenarious you also need to link QtProtobuf WellKnownTypes library by adding following lines to CMakeLists.txt for your target.
target_link_libraries(YourTargetName PRIVATE QtProtobuf::ProtobufWellKnownTypes)