Sure, I'd be OK with adding methods to Message like:
  bool SerializeDelimitedTo(CodedOutputStream* output);
  bool SerializeDelimitedToZeroCopyStream(ZeroCopyOutputStream* output);
  bool SerializeDelimitedToFile(int file_descriptor);
  bool SerializeDelimitedToOstream(ostream* output);

  bool ParseDelimitedFrom(CodedOutputStream* input);
  bool ParseDelimitedFromZeroCopyStream(ZeroCopyInputStream* input);
  bool MergeDelimitedFrom(CodedOutputStream* input);
  bool MergeDelimitedFromZeroCopyStream(ZeroCopyInputStream* input);
  // Note that we cannot parse a length-delimited message from
  // a file descriptor or an istream since these interfaces don't provide
  // a way to push data back into the stream if we read too far.

I'm pretty swamped, though.  Does someone want to write up a patch (with
unit tests)?

On Sat, Sep 6, 2008 at 2:44 AM, <[EMAIL PROTECTED]> wrote:

> Kenton Varda wrote:
>> Feel free to use the above code (note: hasn't been compiled or tested).  I
>> guess the question is whether or not this needs to be in libprotobuf itself.
> I am in favor of putting some kind of delimited message format into the
> API, this is the requested feature.  This will keep people from being too
> creative and reinventing incompatible solutions to have delimited messages.
>  Such as the suggestions in this thread.
> The LengthDelimited functions are the most obvious: all possible
> implementation of messages must already have the functionality internally
> (as your code shows).  So a few lines of code in the API (not the generated
> code files) takes care of this feature request.  I have not checked if the
> existing API for all languages exposes enough to write the equivalent of the
> few lines of code you showed for C++.
> The most obvious use to me is reading from a continous (e.g. network)
> stream of bytes.  The outermost message needs to be delimited somehow,
> currently by the application inventing more protocol rules.
> Cheers,
> Chris

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at

Reply via email to