[英]using std::map<int , std::string> with Google Protocol Buffer
我想知道是否可以使用谷歌協議緩沖區的地圖。 我目前在.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中我想創建一個類型的地圖::有關如何實現這一點的任何建議嗎?
做這個:
message MapEntry
{
required int32 mapKey = 1;
required MsgA mapValue = 2;
}
message MsgB
{
repeated MapEntry = 1;
}
你必須編寫自己的代碼來將地圖轉換為MsgB和從MsgB轉換地圖,但這基本上應該是微不足道的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.