Qt Protobuf

Qt Protobuf

The Qt Protobuf generator plugin generates Qt-based classes from .proto files. You can use the classes to serialize and deserialize their associated protobuf messages.

​Qt-Protobuf生成器插件从.proto文件生成基于Qt的类。可以使用这些类来序列化和反序列化其关联的Protobuf消息。

Overview

概况

What are protocol buffers?

什么是协议缓冲区?

Protocol buffers are a language-neutral, platform-neutral, and extensible mechanism for serializing structured data, which is compact and easy to use:

协议缓冲区是一种与语言无关、与平台无关且可扩展的机制,用于序列化结构化数据,结构紧凑且易于使用:

  • A user defines the structure of data in .proto files.
  • 用户定义.proto文件中的数据结构。
  • Proto compiler is invoked at build time on .proto files to generate code in various programming languages.
  • Proto编译器在.Proto文件的构建时被调用,以生成各种编程语言的代码。

The provided format is suitable for network traffic or long-term data storage.

所提供的格式适合于网络流量或长期数据存储。

Which problems do protocol buffers solve?

协议缓冲区可以解决哪些问题?

Protocol buffers provide a serialization format for packets of typed and structured data that are up to a few megabytes in size. Moreover, it can be extended with new information without invalidating existing data or requiring code to be updated. For more information, see Protocol Buffers Overview.

​协议缓冲区为大小高达几兆字节的类型化和结构化数据包提供序列化格式。此外,它可以用新信息进行扩展,而不会使现有数据无效或需要更新代码。有关更多信息,请参阅协议缓冲区概述。

What are the benefits of using Qt Protobuf?

使用Qt Protobuf有什么好处?

You can use a Protocol buffers mechanism in any Qt-based project:

可以在任何基于Qt的项目中使用协议缓冲机制:

  • No need to call a protocol buffer compiler explicitly.
  • 无需显式调用协议缓冲区编译器。
  • No need to integrate generated code into project tree manually.
  • 无需手动将生成的代码集成到项目树中。
  • Convenient serialization and deserialization API.
  • 方便的序列化和反序列化API。
  • Integrated properties mechanism for generated protobuf messages.
  • 生成的protobuf消息的集成属性机制。
  • Integrated gRPC-client support (see QtGrpc module).
  • ​集成gRPC客户端支持(请参阅QtGrpc模块)。

Incoming features

传入功能

  • Enabling using Qt Core and Qt GUI types as a part of *.proto schema.
  • 启用使用Qt Core和Qt GUI类型作为*.proto模式的一部分。
  • Enabling gRPC-server support.
  • 正在启用gRPC服务器支持。
  • Enabling QML-types support for generated protobuf messages.
  • 正在启用gRPC服务器支持。

Using Qt Protobuf

使用Qt Protobuf

Google protocol buffers provide a generator called protoc that supports extensions. The qtprotobufgen Tool is an extension for protoc and requires that you install protoc on your host system. For more information about the installation, see Protoc Installation.

​谷歌协议缓冲区提供了一个名为protoc的生成器,支持扩展。qtprotobufgen工具是protoc的扩展,需要在主机系统上安装protoc。有关安装的更多信息,请参阅Protoc安装。

Example of installation for Linux, using apt:

Linux安装示例,使用apt:

apt install -y protobuf-compiler
protoc --version  # Ensure compiler version is 3+

For more information about component API usage, see CMake API.

有关组件API用法的更多信息,请参阅CMake API。

CMake API

Class Documentation

C++ Classes

Examples

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值