我想知道是否有可能使用带有google协议缓冲区的地图。目前在我的.proto文件中有类似这样的内容
message MsgA
{
required string symbol = 1 ;
optional int32 freq = 2 [default = 0];
}
message MsgB
{
//What should I do to make a map<int,MsgA>
}我的问题是,在MsgB中,我想创建一个类型,它将是一个映射::有什么建议可以实现这一点吗?
发布于 2013-07-14 18:58:51
执行以下操作:
message MapEntry
{
required int32 mapKey = 1;
required MsgA mapValue = 2;
}
message MsgB
{
repeated MapEntry = 1;
}您必须编写自己的代码将地图与MsgB相互转换,但这基本上应该是微不足道的。
https://stackoverflow.com/questions/17638764
复制相似问题