FieldOptions is just a proto message defined in descriptor.proto:
https://github.com/protocolbuffers/protobuf/blob/2220670ed97fb5d52868a0316054748e6354b6aa/src/google/protobuf/descriptor.proto#L509

On Fri, Dec 6, 2019 at 5:33 AM LakshmiKanth Gupta <[email protected]>
wrote:

> Finally I have figured out whether a field has options or not.
>
> Unfortunately every field in message is associated with FieldOptions. By
> default, each field has DefaultOptions .So I could make pointer comparision
> and say whether a field has Custom field options or not.
>
>
> Final question remains: How do I know the attributes of FieldOptions.
>
>
>
> On Friday, December 6, 2019 at 5:01:49 AM UTC+1, LakshmiKanth Gupta wrote:
>>
>> Yes.I am developing protoc plugin using c++.But I didn't find any
>> function to do that. Could somebody help me with that. Also couldn't find
>> the information of the options.
>>
>> I am using following code:
>>
>> FieldOptions l_options= m_record->field(i)->options();
>>
>> From here I couldn't figure out how I can look at these options.
>>
>>
>>
>>
>> On Thursday, December 5, 2019 at 11:43:37 PM UTC+1, Adam Cozzette wrote:
>>>
>>> I assume your converter is set up as a protoc plugin? In that case you
>>> can examine the descriptor for each field to see if it has a custom option
>>> defined or not. The details depend on the language you are using, though.
>>>
>>> On Thu, Dec 5, 2019 at 12:26 PM LakshmiKanth Gupta <[email protected]>
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> Currently I am writing a convertor from proto format to ttcn3 format.
>>>>
>>>> Messages which I have defined has some custom Field options. How can I
>>>> check whether a field has custom options or not.
>>>>
>>>>
>>>> syntax="proto3";
>>>> import "google/protobuf/descriptor.proto"
>>>> extend google.protobuf.FieldOptions{
>>>>    bool presence=50001;
>>>> }
>>>>
>>>> message Mymessage
>>>> {
>>>>     int32 foo=1[(presence)=true];
>>>>     string bar=2;
>>>> }
>>>>
>>>> This is my file. I would like to know when my convertor is invoked
>>>> using protoc whether a field has options defined or not.
>>>>
>>>> Thanks in advance,
>>>>
>>>> with best regards,
>>>>   Gupta
>>>>
>>>> --
>>>> 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 view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/protobuf/87e492fa-3535-4ee3-b391-f1bb6362f9ad%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/protobuf/87e492fa-3535-4ee3-b391-f1bb6362f9ad%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/protobuf/ead37db8-2237-4de5-9cfb-625af0a394d6%40googlegroups.com
> <https://groups.google.com/d/msgid/protobuf/ead37db8-2237-4de5-9cfb-625af0a394d6%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CADqAXr57Eofka0-qr%3Dn4CkhqsY%2B6Qf8-Kvuugp5r4%2BE8TBGeXw%40mail.gmail.com.

Reply via email to