Something like protoc --decode_raw? As for manipulating these in code, there's nothing too great available if you don't have a descriptor at all. You could create a dummy message (no fields) and then get them via unknown fields in the message's reflection object, but they're not easy to manipulate. Note that the encoded information is not always sufficient for correct decoding. For example, strings, submessages, and perhaps packed arrays are encoded in the same way. I also don't think that whether zigzag encoding is used on varints is part of the serialized data. You really really really want a descriptor. If not compiled in, then passed along with the data.
-ilia On Mon, Aug 19, 2013 at 3:37 PM, Tom Ward <tw...@thefoundry.co.uk> wrote: > Hi all, > > I'm just getting to grips with protobuf and, having read through the > documentation, I'm struggling to find what I'm after. > > Basically I'm trying to work out how to deserialize a protobuf message > without using the generated headers, as we're likely to get messages that > weren't generated at compile time. I've looked through the documentation, > but I only seem to be able to find ones that use generated classes to > deserialize, or that use a Descriptor from a generated class to create a > DynamicMessage, which I can't seem to work out how to do when we don't have > the proto. > > Here's a very simple example of what I mean, where Message* is set to some > base type that allows deserialization, and then can use the reflection API > (or some factory) to correctly deal with the message: > > #include <sstream> > > #include "google/protobuf/message.h" > > int main(int argc, char **argv) > { > if( argc > 1) > { > // This will fail to compile, as Message is pure abstract > google::protobuf::Message* message = NULL; //new > google::protobuf::Message(); > std::istringstream ss(std::string(argv[1],strlen(argv[1]))); > > message->ParseFromIstream(&ss); > > // do something with the message > // ... > } > > return 0; > } > > > Apologies in advance if this has already been answered... > > Thanks > > Tom > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to protobuf+unsubscr...@googlegroups.com. > To post to this group, send email to protobuf@googlegroups.com. > Visit this group at http://groups.google.com/group/protobuf. > For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/groups/opt_out.