将协议缓冲区定义拆分为多个.proto文件 [英] Splitting protocol buffer definitions into multiple .proto files
本文介绍了将协议缓冲区定义拆分为多个.proto文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在另一个协议文件中包含一个协议定义文件。例如:
I would like to include a protocol definition file in another protocol file. For example:
// base.proto:
message P_EndPoint {
required int32 id = 1;
required string host = 2;
required int32 port = 3;
}
然后在另一个文件中:
communication.proto:
// somehow include `base.proto'
// ...
message P_CommunicationProtocol {
required CP_MessageType type = 1;
optional int32 id = 2;
optional P_EndPoint identity = 3;
repeated P_EndPoint others = 4;
}
// ...
(注意:developers.google。 com在我的语言环境中不可用)
(Note: developers.google.com is not available in my locale)
推荐答案
import "myproject/base.proto";
文档: http://developers.google.com/protocol-buffers/docs/proto#other
这篇关于将协议缓冲区定义拆分为多个.proto文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文