ee2 ee2 - 8 months ago 56
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:



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.