协议缓冲区获取EnumDescriptor *

时间:2016-10-20 05:53:10

标签: c++ c++11 enums protocol-buffers

我的协议缓冲区消息中有一个UpdateType枚举

我想使用反射修改它,因为我需要EnumDescriptor。

Google protocol buffers Documentation

#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.

我如何获得EnumDescriptor? TypeName_descriptor()函数在哪里?

1 个答案:

答案 0 :(得分:1)

您可以从FieldDescriptor获取enum_descriptor。

只需使用FiledDescriptor :: enum_type()来获取EnumDescriptor *

希望它有所帮助!!