On 2018-06-28 03:36 PM, John Lilley wrote:

Reading about OneOf  -- can I just union all of my messages into one "container" message?

That's what I do, to map a class hierarchy to messages: I have an umbrella message corresponding to my base class, and a list of leaf node messages inside a OneOf representing all the concrete types I need to serialize. With that, serialization is a two-stage process: In the first stage I serialize into a string. In the second stage that string is then saved to a protobuf file, preceded with its size. Thus, when reading it back in, I first read that size, then the string (of the given size), which I then deserialize using the protobuf API into my actual message / class.
That trick allows me to stream arbitrary numbers of objects / messages.


Stefan

--

      ...ich hab' noch einen Koffer in Berlin...
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to