Thanks for your answer!

(My mistake because I am checked my code on the example binary, generated 
by add_person_cpp, who (apparently) puts each message into a separate 
message-formatted container.)


четверг, 30 мая 2013 г., 1:13:21 UTC+8 пользователь Ilia Mirkin написал:
>
> Messages aren't preceded by anything. A message inside of a message is 
> preceeded by a varint that indicates its length (there's also a 
> deprecated begin/end group mechanism that you probably don't have to 
> worry about supporting). Then, for that length after the varint, 
> decoding of the sub-message should occur. So if you have 
>
> message A { 
>   optional B b = 1; 
>   optional int32 a = 2; 
> } 
>
> message B { 
>   optional int32 x = 2; 
> } 
>
> Then the byte sequence for A might be: 
>
> <tag 1, with indication that it's length delimited> <varint len of b> 
> <tag 2 with indication that it's a varint> <varint b.x> <tag 2, with 
> indication that it's a varint> <varint a.a> 
>
> Where the "varint len of b" is a varint equal to the length of "<tag 2 
> with indication that it's a varint> <varint b.x>". (And of course 
> remember that the tags start with a 4-bit header that indicates the 
> general type of the tag, like varint, length-delimited, fixed32/64, 
> and there are special provisions for tags < 16 so that they fit into a 
> single byte. Take a look at WireFormatLite -- it has a lot of good 
> helper functions.) 
>
> Hope that helps, 
>
>   -ilia 
>
>
> On Sun, May 26, 2013 at 12:35 PM, mimocroc 
> <feklushk...@gmail.com<javascript:>> 
> wrote: 
> > Hi! 
> > 
> > I am writing my own library for working with protobuf for D language 
> > (dlang.org) and have a question: 
> > 
> > Each message is preceded by a header in the "length delimited" format 
> and 
> > has tag which contains number of field. How I can distinguish message 
> header 
> > with field number and real field tagged with the same number? After all, 
> (as 
> > I understand it) theoretically any fields can be repeated at random 
> > locations in the message. 
> > 
> > Thanks. 
> > 
> > -- 
> > 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+u...@googlegroups.com <javascript:>. 
> > To post to this group, send email to prot...@googlegroups.com<javascript:>. 
>
> > 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