The outermost message is not stored with a length; this allows multiple 
messages to be merged by concatenation. The default behaviour for a protobuf 
parser at the root-object is "read until you run out of data". If you have 
written multiple messages without some kind of "framing" (usually adding 
length-prefixes manually) then it will be very hard to unscramble the data. If 
you need to append individual messages and want to parse them back 
individually, one option is to encapsulate each in a parent object with a 
"repeated" element, with a single element per object. Alternatively, add your 
own frames.

Marc

On 21 Apr 2013, at 05:07, Sean Nguyen <sontran...@gmail.com> wrote:

> Hi,
> 
> I want to calculate the protocol buffer message size without reading the 
> stream to the end? I don't see the size of the outer most message is stored. 
> For example:
> 
> message Person {
>    optional string name = 1; 
>    optional uint32 age = 2; 
> }
> 
> There is no size store for the Person message if it is the outer most 
> message. Is that correct? If it is not where I can find it?
> 
> Thanks,
> 
> Son Nguyen
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to protobuf+unsubscr...@googlegroups.com.
> To post to this group, send email to protobuf@googlegroups.com.
> Visit this group at http://groups.google.com/group/protobuf?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to