Re: [protobuf] Parse sub message from binary encoding

2020-05-28 Thread 'Adam Cozzette' via Protocol Buffers
I'm not sure which is cheaper, and it might depend on the situation. But
unless you're trying to do something unusual, it's probably best to just
parse the parent message normally and access the submessage from there.

On Thu, May 28, 2020 at 2:01 AM R P  wrote:

> Appreciate your answer!
>
> I've no deep insights into protobuf. What happens if i parse a binary as
> EmptyMessage? Is it less costly than parsing as a concrete message (e.g.
> Test3 from the example)?
>
> BR
> Rainer
>
> On Tuesday, May 26, 2020 at 5:53:10 PM UTC+2, Adam Cozzette wrote:
>>
>> Why not just parse the entire parent message? But if you really want to
>> avoid that for some reason, probably the easiest approach is to parse the
>> binary as an EmptyMessage, then look through the unknown fields for your
>> submessage field and parse the submessage from there.
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/protobuf/cd50ad82-f438-46c8-babf-736ca2498c84%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CADqAXr6y1r7%2BoeAGjC8qEys23m_pJq7P%3Da9K1TeHs1hGxwW%2BNw%40mail.gmail.com.


Re: [protobuf] Parse sub message from binary encoding

2020-05-28 Thread R P
Appreciate your answer!

I've no deep insights into protobuf. What happens if i parse a binary as 
EmptyMessage? Is it less costly than parsing as a concrete message (e.g. 
Test3 from the example)?

BR
Rainer

On Tuesday, May 26, 2020 at 5:53:10 PM UTC+2, Adam Cozzette wrote:
>
> Why not just parse the entire parent message? But if you really want to 
> avoid that for some reason, probably the easiest approach is to parse the 
> binary as an EmptyMessage, then look through the unknown fields for your 
> submessage field and parse the submessage from there.
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/cd50ad82-f438-46c8-babf-736ca2498c84%40googlegroups.com.


Re: [protobuf] Parse sub message from binary encoding

2020-05-26 Thread 'Adam Cozzette' via Protocol Buffers
Why not just parse the entire parent message? But if you really want to
avoid that for some reason, probably the easiest approach is to parse the
binary as an EmptyMessage, then look through the unknown fields for your
submessage field and parse the submessage from there.

On Mon, May 25, 2020 at 2:28 AM R P  wrote:

> Hello
>
> I want to parse a sub message from a binary super message.
>
> I have found some useful information about message encoding here:
> https://developers.google.com/protocol-buffers/docs/encoding#embedded
>
> From the link:
>
> message Test1 { optional int32 a = 1; }
> message Test3 { optional Test1 c = 3; }
>
> Let's say i have a binary representation of a Test3 message with the sub
> message field 'a' is set to 150:
> 1a 03 08 96 01
>
> Is there a method to parse Test1 message from this binary encoding?
>
> BR
> Rainer
>
> https://developers.google.com/protocol-buffers/docs/encoding#embedded
>
> https://developers.google.com/protocol-buffers/docs/encoding#embedded
>
> https://developers.google.com/protocol-buffers/docs/encoding#embedded
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/protobuf/24115597-43bf-4262-86e4-a861ccd13e21%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CADqAXr4gqHDMO4P8n4kOLROM5Huonqy8zvRMZyBfpMnr_OOx0Q%40mail.gmail.com.