protobuf 嵌套示例
1.嵌套 Message
message Person
{
required string name = 1;
required int32 id = 2; // Unique ID number for this person.
optional string email = 3;
enum PhoneType
{
MOBILE = 0;
HOME = 1;
WORK = 2;
}
message PhoneNumber
{
required string number = 1;
optional PhoneType type = 2 [default = HOME];
}
repeated PhoneNumber phone = 4;
}
2. Import Message
在一个 .proto 文件中,还可以用 Import 关键字引入在其他 .proto 文件中定义的消息,这可以称做 Import Message,或者 Dependency Message。
import common.header;
message youMsg
{
required common.info_header header = 1;
required string youPrivateData = 2;
}
Import Message 的用处主要在于提供了方便的代码管理机制,类似 C 语言中的头文件。您可以将一些公用的 Message 定义在一个 package 中,然后在别的 .proto 文件中引入该 package,进而使用其中的消息定义。Google Protocol Buffer 可以很好地支持嵌套 Message 和引入 Message。
3.更多关于动态编译的内容,参数[1]
原文
[1]http://www.ibm.com/developerworks/cn/linux/l-cn-gpb/
[2]https://developers.google.com/protocol-buffers/docs/overview?hl=zh-CN
[3]https://developers.google.com/protocol-buffers/docs/cpptutorial?hl=zh-CN
protobuf 嵌套示例的更多相关文章
- javascript模板库jsrender for循环嵌套示例
最近在参与整合前端的框架,我们知道javascript最强大的模板引擎之一当属jsrender,号称下一代jquery模板引擎的标准实现. 通常在模板merge的过程中,我们会遇到两次乃至三级嵌套的情 ...
- linux下安装protobuf教程+示例(详细)
(.pb.h:9:42: fatal error: google/protobuf/stubs/common.h: No such file or directory 看这个就应该知道是没有找到头文件 ...
- google protobuf 使用示例
定义.proto接口文件 package tutorial; message Person { required ; required int32 id = ; //unique ID number ...
- Python3基础 if嵌套示例
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- C语言for循环嵌套示例
打印九九乘法表 #include <stdio.h> int main() { int n,i,j; for (i=1;i<=9;i++) printf("%-4d&q ...
- vue-父子组件嵌套的示例
组件注册: // 注册组件 Vue.component('my-component', { template: '<div>A custom component!</div>' ...
- python下使用protobuf
python解决ImportError: No module named google.protobuf 关于protocol buffer的优点,就过多涉及:如果涉及到数据传输和解析,使用pb会比自 ...
- python读写protobuf
0. 前期准备 官方protobuf定义 https://code.google.com/p/protobuf/ python使用指南 https://developers.google. ...
- 最常用的两种C++序列化方案的使用心得(protobuf和boost serialization)
导读 1. 什么是序列化? 2. 为什么要序列化?好处在哪里? 3. C++对象序列化的四种方法 4. 最常用的两种序列化方案使用心得 正文 1. 什么是序列化? 程序员在编写应用程序的时候往往需要将 ...
随机推荐
- 升级到AndroidStudio3.2.1的注意事项
升级到AndroidStudio3.2.1的注意事项 即不用再在二级结构的build.gradle中的compileSdkVersion 28 下声明 buildToolsVersion &q ...
- 报错:-bash: locate: command not found
-bash: locate: command not found 查看某些文件在哪些地方,需要用到 locate 命令 但是在安装 yum install locate 会报以下错误: -bash: ...
- HTML中元素的定位方式
初中物理就学过,位置是相对的,要有参照物,因此,所有定位都是相对参照物的定位. position 属性: 规定元素的定位类型,该属性的可选值有static.relative.absolute.fixe ...
- js原型鏈與js繼承解析
最近在網上看了諸多js原型鏈的解析,說得雲裡霧裡,不明所以.徹底了解後,決定出個博客記錄一下,一是方便後來人學習,二是方便日後複習. 首先,我們來看一下構造函數.原型.實例之間的關係圖: 所以,我們通 ...
- bzoj5293: [Bjoi2018]求和
题目链接 bzoj5293: [Bjoi2018]求和 题解 暴力 对于lca为1的好坑啊.... 代码 #include<cmath> #include<cstdio> #i ...
- 洛谷P1133 教主的花园
题目描述 教主有着一个环形的花园,他想在花园周围均匀地种上n棵树,但是教主花园的土壤很特别,每个位置适合种的树都不一样,一些树可能会因为不适合这个位置的土壤而损失观赏价值. 教主最喜欢3种树,这3种树 ...
- Codeforces Round #368 (Div. 2) B. Bakery 水题
B. Bakery 题目连接: http://www.codeforces.com/contest/707/problem/B Description Masha wants to open her ...
- 2013-2014 ACM-ICPC, NEERC, Southern Subregional Contest Problem H. Password Service dp
Problem H. Password Service 题目连接: http://www.codeforces.com/gym/100253 Description Startups are here ...
- Ubuntu下实现软路由(转)
参考:http://www.openwrt.pro/post-292.html 个人看法: 1.实现路由在Linux下必须要用到iptables进行转发,这才是路由核心. 2.我觉得对于Linux来说 ...
- MikroTik RouterOS授权级别
抄了一份来自淘宝代理商的说明: P系列许可级别(适用于联网的虚拟机,如:云主机,虚拟机,VPS等) 您必须在MikroTik官网 https://mikrotik.com/client/ 上拥有一个帐 ...