On Fri, Oct 2, 2009 at 1:07 PM, Tuppy Hamper <hamp...@gmail.com> wrote:

>
> and how would this change if the message contained fields that were
> repeatable or single messages which contained their own ENUMS. I know
> I would have to have a branch to the IF statement that if type ==
> MESSAGE, then recurse, but would I have to handle single and repeatble
> message fields differently?
>

field->is_repeated() returns true or false.  There's nothing else different
about the descriptors (though the resulting messages are obviously pretty
different).


> Thanks
>
> On Oct 2, 1:59 pm, Kenton Varda <ken...@google.com> wrote:
> > using google::protobuf::Descriptor;
> > using google::protobuf::FieldDescriptor;
> > using google::protobuf::EnumDescriptor;
> > using google::protobuf::EnumValueDescriptor;
> >
> > const Descriptor* descriptor = message.GetDescriptor();for (int i = 0; i
> <
> > descriptor->field_count(); i++) {
> >   const FieldDescriptor* field = descriptor->field(i);
> >   if (field->type() == FieldDescriptor::TYPE_ENUM) {
> >     // this is an enum field.
> >     const EnumDescriptor* type = field->enum_type();
> >     for (int j = 0; j < type->value_count(); j++) {
> >       const EnumValueDescriptor* value = type->value(i);
> >       // value->name() and value->number() describe this value.
> >     }
> >   }
> >
> >
> >
> > }
> > On Fri, Oct 2, 2009 at 8:23 AM, Tuppy Hamper <hamp...@gmail.com> wrote:
> >
> > > is it possible to dynmically get allthe enum fields associated with a
> > > protocol buffer message and all the valid values defined in that enum
> > > fields?- Hide quoted text -
> >
> > - Show quoted text -
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to