Dre*_*rew 2 serialization protocols protocol-buffers
我正在尝试解析一条非常大的消息(大约25个字段)并将它们序列化.消息中的字段始终以相同的顺序出现,并且在proto文件中我相应地编号.是否有方法使用标记值(proto文件中的数字)设置字段?
谢谢,Chem.
google::protobuf::Message myMessage;
const google::protobuf::Descriptor * myDescriptor = myMessage.GetDescriptor();
const google::protobuf::FieldDescriptor * myField = myDescriptor->FindFieldByNumber(9001);
const google::protobuf::Reflection * myReflection = myMessage.GetReflection();
myReflection->SetInt32( &myMessage, myField, 7);
显然,您需要更改字段编号,字段类型以及要设置的值.
| 归档时间: | 
 | 
| 查看次数: | 983 次 | 
| 最近记录: |