This is a FAQ.

[EMAIL PROTECTED] wrote:
> Hi, Kenton,
>
> The main problem is how can I serialize two different objects into one
> stream.
>
> e.g.  If I serialize the Text object into one file, how can I append
> another object Image into the file.
>      Also the methods how to deserialize?   Thanks.
>   
The normal API for serializing messages produces a series of numbered 
fields on the wire.  This is not a delimited format, so if you 
concatenate two such encodings you get nonsense unless they are the 
exact same type (in which case deserializing them produces the the same 
result as the two messages being merged into one).

There have been _many_ threads on the this list that talk about how to 
have delimited messages.  The main need is to write the length of the 
message before the message itself and use this when writing your 
decoder.  There are several equivalent but incompatible ways to do 
this.  Some people prefer to write a field tag to the wire as well, 
which means the result looks like a proper protocol-buffer on the wire, 
but for some meta-message that may or may not have been explicitly defined.

Mainly I have not heard that the main Google protobuf API provids a 
simple agreed upon way to write and read back a delimited message.  The 
Haskell project (which is mine) and a C# project both have ways of doing 
this.

Hopefully this FAQ will eventually lead to a simple delimited API being 
added to all the implementations.

-- 
Chris


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to