Hi Marc, Thanks for the clarification. If the actual .proto was there, i would not have posted that question [?] at the first place. Anyways, to decode a protocol buffer, is it not enough to have just the wire type + tag number combination? (except of course, handling of the sub-messages-ness and other ambiguities you mentioned below have to be done manually though)
Regards, Rahul Prasad On Sat, Nov 14, 2009 at 3:57 PM, Marc Gravell <marc.grav...@gmail.com>wrote: > If you treat it as a string (UTF8), you are likely to get garbage. If you > treat it as a byte[], then you just get a BLOB - you don't lose anything, > but you might not be showing some more detail that you could show. > > You could, however, check for likely-sub-message-ness - i.e. after getting > the length, you could try decoding the next few bytes as a variant, and do > the shift trick; see if it looks likely to be a sub-message etc; you could > try to validate the entire "string", see if it makes sense. Note that you > don't have to store any of the data - just follow the rules for each > wire-format until something doesn't look right or you've checked the string. > > Easiest, though, is to have the .proto available ;-p > > Marc > > 2009/11/14 rahul prasad <rahu...@gmail.com> > >> Hi, >> >> As seen from the below wire types table from protobuf documentation, if i >> try to extract a value from a protobuf that is of type 2, it could either be >> a string, byte array or a embedded message etc, If I cast the value as bytes >> or string on the decoding side, while on the encoding side it was actually >> an embedded message, what would this result in? Will I be able to retrieve >> the actual value, someway or the other doing it this way? >> >> The available wire types are as follows: >> Type Meaning Used For 0 Varint int32, int64, uint32, uint64, sint32, >> sint64, bool, enum 1 64-bit fixed64, sfixed64, double 2 >> Length-delimitedstring, bytes, embedded messages, packed repeated >> fields3Start groupgroups (deprecated)4End groupgroups >> (deprecated)532-bitfixed32, sfixed32, float >> Regards, >> Rahul Prasad >> >> >> >> >> > > > -- > Regards, > > Marc > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
<<inline: 347.gif>>