ee2 ee2 - 1 year ago 176
C++ Question

Set Enum values using reflection in Protocol buffers

I have an Enum

Update update
in a .proto file . I want to store it using reflections in a message.

refl->SetEnum (msg, fd , ??? );

???? - should be EnumValueDescriptor * (I do not know how to get it)

How can I do this?

I have tried
for many different possibilities of s like:


Answer Source

All you need in the third argument is EnumValueDescriptor*.

Also as you can see you have passed FieldDescriptor in the second argument. So just use FieldDesciptor::enum_type() to get EnumDescriptor* and then use EnumDescriptor::Value() to get EnumValueDescriptor.

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