Re: [protobuf] How to serialize/deserialize bytes data?

2016-12-22 Thread Henner Zeller
On 22 December 2016 at 14:50, wrote: > Thanks for the reply. > > My question here is: I use protobuffer to store a bytes data, how can I > retrieve it back? Symmetric to the SerializeToArray(), use ParseFromArray() or ParseFromString() to parse a serialized version of a protocol buffer back. >

Re: [protobuf] How to serialize/deserialize bytes data?

2016-12-22 Thread song1219
Thanks for the reply. My question here is: I use protobuffer to store a bytes data, how can I retrieve it back? In my previous example, just offset 2 from the protobuffer data? However, the size field may vary, right? On Thursday, December 22, 2016 at 2:13:14 PM UTC-8, Adam Cozzette wrote: > >

Re: [protobuf] How to serialize/deserialize bytes data?

2016-12-22 Thread 'Adam Cozzette' via Protocol Buffers
It looks like you are building up a protocol buffer containing a serialized protocol buffer, which itself contains a serialized protocol buffer, which in turn contains a serialized protocol buffer, etc. Each level of nesting requires an additional two bytes: one byte for the tag number and a second

[protobuf] How to serialize/deserialize bytes data?

2016-12-22 Thread song1219
I defined a simple bytes message below message MfStream { bytes message=1; } and run a test below, in which I use for a loop to keep serialize/deserialize the bytes message. char buf[1024]; int tmp = 1; MfStream testMsg; testMsg.set_message(&tmp, sizeof(tmp)); for (int i=0; i<5; i++) { int