> If protocol buffers doesn't use object I/O streams, which streams does
> it use?  The argument in Java simply asks for an OutputStream
> argument, and of course that could mean File, ByteArray, Object, Data,
> etc....

I mean that it only depends on the methods in OutputStream.  You can
provide anything that implements OutputStream (including
ObjectOutputStream, if you wish, but it won't encode things using
ObjectOutputStream's additional methods for encoding Java objects, it
will only write bytes to the stream).

> And perhaps more importantly, will the choice of Java stream types
> impact how GPB objects may be reconstituted in C++?  At the simplest
> level I assume this can be done:
>
> I can create a GPB class called "GPBCar".
> I have an outputstream (of some type, not sure!) over a socket in Java
> I want to write to.
> After creating my GPBCar object, I use the GPB "writeTo(output)"
> method on the Java side.
> My C++ app takes some form of this byte stream and reconstitutes my
> GPBCar instance by using the equivalent of the "parseFrom" method from
> the GPBCar.

Yep, that should work fine.

> My understanding is that I have converted my GPBCar to a series of
> bytes that represent that GPBCar instance. Now I have a C++ app at the
> other end of the socket connection.   But will the series of bytes be
> in the correct order (endianness?).  Will the outputstream type be
> particular to Java, or will I encounter problems by using certain
> specific Java outputstreams?  Should I only be using the
> CodedDataOutputStream provided by GPB? (I note that there is
> implementations of this stream in both the C++ and Java GPB
> implementations).

The bytes should arrive in the correct order because the wire format
specifies the byte order of everything (and the protocol buffer code
properly implements that).  It could get screwed up if some other
system on either end is attempting to modify the byte order, but in
general that shouldn't be the case.

What kind of OutputStream you use should have no effect, unless it's
an OutputStream that transforms the output in some way.  You don't
have to use CodedOutputStream.

- Adam

--

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@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