Oh, I see. No, CodedOutputStream doesn't support seek functionality, so I
guess you'd have to go with b). Just make sure that you're using
WriteLittleEndian64 and not WriteVarint64.

On Sat, Nov 14, 2009 at 12:05 PM, Fishtank <saptarshi.g...@gmail.com> wrote:

>
> That's because I don't know the size of data1(and it is not from
> protobuf parse)
> I'm using protobuf for the stream libraries.
> I can either a) loop through the calculation to get the total data
> size, then loop again writing size and data
> or b) loop once, write, get size, seek and adjust size.
>
> Regards
> sapsi
>
>
> On Nov 14, 2:56 pm, Jason Hsueh <jas...@google.com> wrote:
> > Why can't you write the actual size of data rather than a 0? Just use the
> > ByteSize() method to find out how much data will be written for a
> protocol
> > buffer.
> >
> > On Sat, Nov 14, 2009 at 11:39 AM, Fishtank <saptarshi.g...@gmail.com>
> wrote:
> >
> > > Hello,
> > > I'm using  the following idiom
> > >  ZeroCopyOutputStream* raw_output = new FileOutputStream(fd);
> > >  CodedOutputStream* coded_output = new CodedOutputStream(raw_output);
> >
> > > The format i'd like is uint64_t, followed by data1, followed by data2.
> > > I write a 0 for the uint64_t, write the data1, record the bytes written
> > > (B), then write data2.
> > > I'd like to seek to the beginning of the file and change the uint64_t
> > > val (which was 0 ) to B.
> > > (data2 is updated much more frequently than data1)
> >
> > > It appears codedoutputstream doesn't have a seek, so I'm thinking ,
> > > after the above steps
> > > a) deleting the CodedOutputStream and Zero...
> > > b) seek on the fd, and update the value.
> >
> > > Does this sound right?
> > > Regards
> > > Sapsi
> >
>

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

Reply via email to