On Sat, Feb 16, 2013 at 11:44 PM, Nishar Nalakathu <nishar...@gmail.com>wrote:

>
> I uses the following proto and code snippet to access the field options
> form a descriptor which is created by Importer.
>
> import "descriptor.proto";
> extend google.protobuf.FieldOptions {
>   optional string index = 10000;
> }
> message order {
>     optional string user = 1 [(index) = "hash"];
> }
>
>         namespace pb = ::google::protobuf;
>         const google::protobuf::FileDescriptor *
> fd=i->Import("order.proto");
>         google::protobuf::DynamicMessageFactory factory;
>         const google::protobuf::Descriptor * md=
> gfd::getfd()->FindMessageTypeByName("order");
>         const pb::FieldDescriptor *fd = md->field(0);
>         const pb::FieldOptions & fo = fd->options();
>         const pb::Descriptor *fd_from_option = fo.GetDescriptor();
>
Use fo.GetReflection()->ListFields(fo, ...) to get a list of all fields
including extensions.


>         for (int i = 0; i < fd_from_option->field_count(); ++i)
>         {
>                 const pb::FieldDescriptor *fd = fd_from_option->field(i);
>                 cout<<"["<<fd->full_name()<<"]"<<endl;
>         }
>
> But Iam getting only the following standard option, So is there any way I
> can get all the options including which I defined (index)?
> Actually, I want to provide some static attributes to some fields and get
> those attributes at the runtime.
>
> [google.protobuf.FieldOptions.ctype]
> [google.protobuf.FieldOptions.packed]
> [google.protobuf.FieldOptions.lazy]
> [google.protobuf.FieldOptions.deprecated]
> [google.protobuf.FieldOptions.experimental_map_key]
> [google.protobuf.FieldOptions.weak]
> [google.protobuf.FieldOptions.uninterpreted_option]
>
> Thank,
> Nishar
>
>  --
> 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 http://groups.google.com/group/protobuf?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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 http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to