我有以下protoc文件:C++谷歌协议缓冲器:指定二进制流protobuf的对象
message DataChunk{
required bool isHash=1;
required int64 hash=2;
required string data=3;
}
message responseBody{
repeated DataChunk dataChunk=1;
}
和我有下面的C++函数:
void eamorr(string data){ //data is a protocol buffer stream converted to a string
responseBody rb;
rb=some_function_of(data); //what to do here?
}
字符串 “数据” 创建使用:
...
std::ostringstream stream;
rb.SerializeToOstream(&stream);
string protobufStream = stream.str();
...
我的问题是:如何将字符串转换为protoc对象,以便我可以访问成员元素?请记住,我对C++很陌生。
问候,谢谢你。现在正在工作。对不起,迟来的回复。 – Eamorr 2012-02-07 13:46:32