google::protobuf的使用 c+ https://blog.csdn.net/u011573853/article/details/73060934

本文详细介绍了如何在C++项目中使用Google的Protocol Buffers(protobuf)进行数据序列化,包括安装步骤、基本概念、消息定义、代码生成、序列化与反序列化操作,以及protobuf在实际开发中的优势。
摘要由CSDN通过智能技术生成
// 如果使用此注释,则使用proto3; 否则使用proto2
syntax = "proto3";

// 引入外部的proto对象
import "google/protobuf/any.proto";

// 生成类的包名
option java_package = "proto.complex";

//生成的数据访问类的类名  
option java_outer_classname = "MyComplexObjectEntity";



message ComplexObject {  
    // Message里每个成员变量都有一个唯一的数字标志(   Assigning Tags)
    int32 id = 1;//  singular, 默认值,表示成员只有0个或者1个
    string name = 2;// 
    string email = 3;//
    repeated string sons = 4; // repeated 列表
    Gender gender = 5; // Enum值
    repeated Result result = 6; // 新的对象List
    repeated google.protobuf.Any any = 7; // Any对象
    map<string, cameraParam> cameramap = 8; // 定义Map对象

    // reserved
    reserved 12, 15, 9 to 11; // 预留将来使用的Assigning Tags,
    reserved "foo", "bar"; // 预留将来使用的filed name
} 

//编译后的c++不能编过,要加括号,对 (std::numeric_limits<::PROTOBUF_NAMESPACE_
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值