ee2 ee2 - 1 year ago 168
C++ Question

protocol buffers get EnumDescriptor *

I have an UpdateType enum in my protocol buffers message

I want to modify it using reflections, for that I need EnumDescriptor.

Google protocol buffers Documentation says

#include <google/protobuf/descriptor.h>
namespace google::protobuf

Describes an enum type defined in a .proto file.

To get the EnumDescriptor for a generated enum type, call TypeName_descriptor(). Use DescriptorPool to construct your own descriptors.

How can I get EnumDescriptor? where is TypeName_descriptor() func?

Answer Source

You can get enum_descriptor from FieldDescriptor.

Just use FiledDescriptor::enum_type() to get EnumDescriptor*

Hope it helps !!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download