Re: [protobuf] Re: Will ByteSize() return a fixed size for fixed object bype if I upgrade Google Protocol Buffer?

2016-09-27 Thread job4charlie
thanks a lot! that's exactly the thing(delimited serialization) I have been looking for, though not supported by build-in fun in c++, which is great! all the best, Charlie 发自我的小米手机在 Adam Cozzette ,2016年9月27日 上午11:39写道:I see, if you're just writing length delimiters then the most common conventi

Re: [protobuf] Re: Will ByteSize() return a fixed size for fixed object bype if I upgrade Google Protocol Buffer?

2016-09-27 Thread 'Adam Cozzette' via Protocol Buffers
I see, if you're just writing length delimiters then the most common convention is to write the size as a varint right in front of the message itself. Then to read the message you just read the varint prefix first to find out how many more bytes to read. In Java we have built-in support for this (w

Re: [protobuf] Re: Will ByteSize() return a fixed size for fixed object bype if I upgrade Google Protocol Buffer?

2016-09-26 Thread job4charlie
hi Adam, many thanks for the clarification and for sure I will stick to fix-sized type. the whole story was: - before I write a message to file, I have to write the length of the object first, so I can parse and reconstruct it in memory thru SerializeFromArray(char*, size). - when I do it, I defin

Re: [protobuf] Re: Will ByteSize() return a fixed size for fixed object bype if I upgrade Google Protocol Buffer?

2016-09-26 Thread 'Adam Cozzette' via Protocol Buffers
Yes, in your case the serialized size will remain the same because you are using simple fixed-size fields and always initializing them. There are a few things to watch out for, though: - If you use proto3 syntax, zero-valued fields will be omitted from the serialized output because zero is the def