The easiest way to do that is to invoke protoc and pass
--descriptor_set_out=descriptors.out. That will cause protoc to parse the
file for you and output it as a serialized FileDescriptorSet
<https://github.com/protocolbuffers/protobuf/blob/36cd11a2bf3593427a54ccca3254351dd577be48/src/google/protobuf/descriptor.proto#L57>
proto. You can then parse the FileDescriptorSet and from there it's easy to
examine the structure of the .proto file.

On Tue, Jun 11, 2019 at 7:50 AM Brett Smith <[email protected]> wrote:

>
> I want to be able to parse just the normal .proto file (the one I attached
> in the original post).
> On Tuesday, June 11, 2019 at 10:46:48 AM UTC-4, Adam Cozzette wrote:
>>
>> Do you want to parse a .proto file or a file containing a serialized
>> protobuf message?
>>
>> On Tue, Jun 11, 2019 at 6:43 AM Brett Smith <[email protected]> wrote:
>>
>>> Hello all, I'm brand new to protobufs and I've been following the
>>> AddressBook example given by Google (
>>> https://developers.google.com/protocol-buffers/docs/cpptutorial). I've
>>> been able to read and write protobufs but I've been wondering if it is
>>> possible to parse a proto file without  compiling it beforehand and if you
>>> are still able to access the elements of that file. If it is possible,
>>> would someone be able to give me some assistance on how to do this? I have
>>> attached the proto file that I have been working with for reference.
>>>
>>> --
>>> 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 [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at https://groups.google.com/group/protobuf.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/protobuf/53bbda9d-3898-47f2-af46-89093fd7c788%40googlegroups.com
>>> <https://groups.google.com/d/msgid/protobuf/53bbda9d-3898-47f2-af46-89093fd7c788%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/protobuf.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/protobuf/ab4b719a-100d-46dd-b6ac-35f117ab002c%40googlegroups.com
> <https://groups.google.com/d/msgid/protobuf/ab4b719a-100d-46dd-b6ac-35f117ab002c%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CADqAXr6zvR-OVeyCYmwqvWd31ckU6CyfvkTAm%2BpZbX4%2Bz8_CRw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to