>From any Message you can call GetReflection(). >From the Reflection call ListFields().
FieldDescriptor has a variety of “name” attributes that are available as strings against which to compare. FieldDescriptor also has FieldOptions. I have not used FieldOptions for numeric_range but the documentation suggests that FieldOptions supports the options enclosed in []. https://protobuf.dev/reference/cpp/api-docs/google.protobuf.descriptor/#FieldDescriptor.options.details On Tuesday, July 11, 2023 at 7:51:18 PM UTC+12 Shahab Nassiri wrote: > Hi > > I want to set numeric_range on protobuf field and read the defined > numeric_range in runtime. I use the file descriptor and field descriptor > for this goal. > > But i have a problem. I don't want to hard code the name of class variable. > > I express one example about this. I define a day field in proto file and > set numeric_range on it as following. > > message Person{ > int32 day = 1; [range_min = 5; range_max = 10] > } > > now, I want to read the defined numeric_range in runtime. > > for this goal, i must determine the variable name as hard code. > > is there any way for determining the variable as string? > > > 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/32716470-8158-4508-94d8-56887a53ded8n%40googlegroups.com.
