Message from discussion
A bit more protobuf help please
Received: by 10.101.179.34 with SMTP id g34mr4083384anp.0.1318252932043;
Mon, 10 Oct 2011 06:22:12 -0700 (PDT)
X-BeenThere: protobuf@googlegroups.com
Received: by 10.100.237.8 with SMTP id k8ls4864405anh.2.gmail; Mon, 10 Oct
2011 06:22:07 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.100.193.4 with SMTP id q4mr826985anf.17.1318252927838; Mon, 10
Oct 2011 06:22:07 -0700 (PDT)
Received: by t16g2000yqm.googlegroups.com with HTTP; Mon, 10 Oct 2011 06:22:07
-0700 (PDT)
Date: Mon, 10 Oct 2011 06:22:07 -0700 (PDT)
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.0) AppleWebKit/535.1 (KHTML, like
Gecko) Chrome/14.0.835.202 Safari/535.1,gzip(gfe)
Message-ID: <d0397ea9-5001-4e42-82bd-4fb53a5203ad@t16g2000yqm.googlegroups.com>
Subject: A bit more protobuf help please
From: Dale Durham <geny...@gmail.com>
To: Protocol Buffers <protobuf@googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
Hi All,
Again I am new to this, so please continue to bear with me and thanks
to Benjamin Wright for all the help so far!! I think that I am
thinking myself into a circle between the FileDescriptors,
FileDescriptorSets, FileDescriptorProtos, and so on. It is not yet
really clear what is what between them all.
So, with help from Benjamin, I can get all the base proto and
dependency file names and field names in one way or another. Also, I
am creating the descriptors files "on the fly" if they do not already
exist for each message type (I have not control over the messsages
being passed and cannot add the deccriptors to the messages
themselves). I am still fuzzy on if I should put all the fields into
one Desriptor proto and pass that or all the files in one
DescriptorSet and pass that, or something else, but I'll figure that
out eventually.
Then I need to (or at least I THINK that I need to):
1) Create a new protobuf message based on the definition defined for
the protobuf files and fields based on all the Descriptor and
dependency stuff above (I think this should be a DynamicMessage based
on what I have seen and read)
2) Do something similar to the C++ equivalent of protobuf-
>ParseFromString(message.getData()); to deserialize and get the byte
array I have containing the actual message data into it
I suspect that since there is protobuf no parsing in Java, I'll have
to call out to protoc again, but if so am not sure what to pass it or
even if my steps above are where I really need to go next. It may be
that I need to iterate through each field, get it's type, and then
parse from the byte stream based on that iteration.
I also wonder if it would be faster and easier to just create a Java
version of the message based on the C++ version that I am being passed
in the byte array and use that instead?
The overall base steps I need to do are:
1) Get a byte array containing protobuf message that was was compiled
and serialized in C++
2) Get the structure of that message (base type and dependency files
and fields in order and I can get this now, but not sure what I am
doing is optimal)
3) Glue the message data into #2 above and display the it (again I
think this may require a protoc call out, but maybe not)
Getting the files and fields is great and cool considering that I just
started playing with these - not because I wanted to but because I
have to! Now I just want to be sure am doing it the best way and need
to figure out how best to glue it all together. Most of the examples I
can find assume the message was compiled for Java and that I know the
type (the infamous Person Class in most of them) in advance and I do
not. Any additional help or thoughts are appreciated.
Thanks again,