在pbtools中编码重复的条目

问题描述 投票:0回答:1

我有一个带有一堆重复结构的protobuf模式。有点像

syntax = "proto3";
package My

message TopLevel 
{
   string swVersion = 3;
   string reportMac = 4;
   string reportSsid = 6
}

message Temperature
{
   required uint64 ts = 1;
   required uint32 source = 3;
   repeated sint32 readings = 4;
}

message MyMessage
{
   required TopLevel topLevel = 1;
   repeated Temperature temperature = 2;
}

我使用pbtools进行编译,并获得用于温度和读数的结构和功能。但是,我很难弄清楚如何动态添加“温度”条目。还是我不走运,pbtools要求提前告诉我我有多少条目。一个问题是数据在生成时就被编码了,我不知道每个报告将有多少内容。我附上了生成的代码。

protocol-buffers
1个回答
0
投票

[pbtools需要添加任何项目之前的长度。

© www.soinside.com 2019 - 2024. All rights reserved.