在谷歌协议缓冲区中设置重复字段时出错
Error setting repeated fields in google protocol buffers
我有一个消息类:
message Foo {
repeated Foo2 field = 1;
}
//Foo2 is another message
在我的 cpp 文件中:
Foo* ci1;
Foo* ci2;
//call some function to to assign values to ci1->field(0)
function( ci1 )
//try to copy ci1-field(0) to ci2->field(0)
ci2->set_field( 0, ci1->field(0) );
但是我收到一条错误消息:错误:"Foo"没有名为"set_field"的成员为什么它以成员身份读取set_field而不是成员字段set_函数?我是协议缓冲区的新手,所以任何帮助将不胜感激!
谢谢!
试试*ci2->add_field() = ci1->field(0)
.
更一般地说,您需要了解 protobuf 如何映射到类,以及如何处理每种字段。详细信息在文档中。
相关文章:
- 将结构字段的类型展开为可变模板参数
- 将位字段导出到数组
- 为了方便起见,我应该避免公开私有字段变量吗
- 当字段可以为null时,如何使用C++接口在Avro中写入数据
- 在java中读取c++字节的位字段
- 链接器找不到在虚拟类 c++ 中访问的静态字段的符号
- 私有字段对象与私有继承?
- 声明没有默认构造函数的字段
- C++内存模型和位字段的最大序列
- 声明为无效的变量或字段'...' Ardunio 编译器上的错误
- 如何在QByteArray中放置和检索位字段而不会感到痛苦?
- C++ win32 如何使密码字段可选并启用复制和粘贴?
- 如何通过UDP接收QByteArray并将其解析为位字段结构?
- 仅匹配集合中的某些字段
- 结构字段名称与 GDB 中的 STL 数组冲突
- 如何使用位字段将数据从二进制文件复制到结构中?
- 结构体和类的不同大小(),彼此具有相同的字段类型
- 如何避免在数据结构中包含存储为字段的类?
- 确定输入"conscalc: calc"的类型时出错。不能联合编码器。具有不同字段集的结构类型
- 在谷歌协议缓冲区中设置重复字段时出错