On Jul 6, 2010, at 7:33 , Srivats P wrote:
@evan: That's what I'm doing currently - serializing and writing the
bytestream for the magic, checksum and actual content messages
separately and in that order - I was just wondering if I could put
them all into one message { ... } and just serialize one message
instead of three.

Well, the checksum must be a separate "message" from the content, since you need the content bytes in order to compute the checksum. At least with the "official" implementation. But you could use the content message for the "magic" bytes part.

I would just use a CodedOutputStream/CodedInputStream directly to do this, with something like the following:

CodedOutputStream out = ...;
ByteString msgBytes = msg.toByteString();
byte[] checksum = computeChecksum(msgBytes);
out.writeRawBytes(magicBytes);
out.writeRawBytes(checksum);
out.writeBytesNoTag(msgBytes);

--
Evan Jones
http://evanjones.ca/

--
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