If the code you were given was generated by protoc, then it should declare
some message classes which inherit from google::protobuf::Message or
google::protobuf::MessageLite. If you are OK with posting the code
somewhere then I could take a look and tell you for sure.

Probably the best way to tell if your file contains a serialized protocol
buffer is to run it through protoc --decode_raw and see if that returns
reasonable results. But protobuf doesn't really define a file format so
there is not a surefire way to tell. (For example there's no magic number
and no official format for storing a sequence of separate messages.)

On Sun, Oct 14, 2018 at 10:51 PM Steven Lutz <steeev...@gmail.com> wrote:

> Is there a tool that I can use to verify that I'm actually working with a
> file created with protobuf?
>
> On Sunday, October 14, 2018 at 10:04:26 PM UTC-7, Steven Lutz wrote:
>>
>> Yes, that is correct that I have a file that is encoded with protobuf. I
>> need to both read and write this file type.
>> I'll use the tools as you mentioned and see what I come up with.
>>
>> The code that I have doesn't have the generated comments, just user
>> comments. I don't know how to replicated the same class structure in the
>> proto file based on the code that I have.
>>
>> On Sunday, October 14, 2018 at 11:29:11 AM UTC-7, Adam Cozzette wrote:
>>>
>>> Do I understand right that you have a raw data file encoded in the
>>> protobuf binary format? Are you just trying to read that one file, or do
>>> you want to be able to read and write other files with that same message
>>> type?
>>>
>>> One quick thing you can do is pipe the raw data to protoc --decode_raw.
>>> That will give you an incomplete view of the data because protoc can't
>>> fully interpret it without knowing the schema, but it could at least give
>>> you a rough idea of what the data contains. If you want to recreate the
>>> .proto file from the pb.h and pb.cc files, that should be fairly easy to
>>> do--you can look in the generated pb.h file and just look at the comments
>>> next to the field accessors. That should tell you the type and field number
>>> associated with each field.
>>>
>>> On Sat, Oct 13, 2018 at 12:02 AM Steven Lutz <stee...@gmail.com> wrote:
>>>
>>>> I'm working with a file that was created using protocol buffers. the
>>>> application that writes these files was written in c++. I put in a request
>>>> to the 3rd party that created this software to get the file definition/spec
>>>> and I was given the c++ code/header file. (not the entire application)
>>>> I'm having some trouble understanding the structure defined in the code
>>>> (i'm c++ rusty) so I was thinking that if there was a way to recreate the
>>>> c++ code using a protofile I'd have the generated example code to go along
>>>> with it. The original author doesn't seem to know anything about a
>>>> protofile which makes me wonder how it was all created in the first place.
>>>>
>>>> I figure I can either:
>>>> Try to untangle this confusion without a protofile,
>>>> or
>>>> Figure out how to create the protofile from the code I was given.
>>>>
>>>> Can someone shed some advice on this?
>>>> Thank you
>>>>
>>>>
>>>> --
>>>> 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+u...@googlegroups.com.
>>>> To post to this group, send email to prot...@googlegroups.com.
>>>> Visit this group at https://groups.google.com/group/protobuf.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> --
> 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 https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to