You can use TextFormat for this.  Say your file is going to have a set of
FooMessages in it.  Then, define a message like:

  message FooSet {
    repeated FooMessage foo = 1;

Now, your file can look like this:

  foo {
    ... contents of the first FooMessage ...
  foo {
    ... the second FooMessage ...

Now parse the entire file as a single FooSet.

BTW, protoc can do text<->binary conversion from the command line:

  protoc foo.proto --encode=FooSet < text_data > binary_data

Hope that helps.

On Sun, Oct 5, 2008 at 11:43 PM, Akhilesh <[EMAIL PROTECTED]> wrote:

> More over, I could use TextFormat class for reading a single message
> in TEXT format. But there is a restriction here, If I have multiple
> messages in the same file, then it's not possible to create multiple
> messages while parser is reading from input stream.
> Please correct me if I am wrong.
> Finally Aim is: If I have *multiple* messages written in *text* in any
> file, I want to open a stream to read this file. And now I should be
> able to simply wrap this stream in suitable PB streams and simple call
> any function that will go on reading the stream and provide me an
> array of PB Messages in Binary format as a result.
> So is there anything like that? Or I'll have to write my code above PB
> api?
> Thanks in advance.
> >

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