Serialized protocol buffers do not contain any information to allow you to
determine their size, so you have to know the size you expect before you
start parsing. The most common approach is to just prefix the serialized
protobuf with a varint
<https://developers.google.com/protocol-buffers/docs/encoding#varints>
indicating the size in bytes. Then on the parsing side you just read the
size prefix first and then you know how many bytes to expect.

For some languages we include this functionality as part of the protobuf
library; for example in Java you can use writeDelimitedTo and
parseDelimitedFrom to use this varint-prefixed format. In C++ you have to
write a little bit of boilerplate to accomplish the same thing.

On Tue, Nov 15, 2016 at 6:46 AM, <vladimir.dumanovs...@wayray.com> wrote:

> Goodday! I need to parse data from the byte array. Byte array can does not
> contain enough bytes, but I can add one byte or more if needed.
> I tried pars a byte array that contains enough bytes for parse one but not
> two pfb objs.
> Does exist true way for parse a one pbf from a byte array that contains
> enough or more bytes? Can I detect the usefull bytes size?
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to protobuf@googlegroups.com.
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to