ee2 ee2 - 6 months ago 90
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?


You can get enum_descriptor from FieldDescriptor.

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

Hope it helps !!