I have just the solution for you...
I'll start by warning you that I use PB mainly in Java, so things may
look slightly different in C++ - but this method should still work.
You're going to want to define an extension to
"google.protobuf.EnumValueOptions"
in your ".proto" file you will need to add an import for
descriptor.proto
import "descriptor.proto";
then you will need to extent EnumValueOptions
extend google.protobuf.EnumValueOptions {
optional string friendly_name = 5000;
}
you will now have defined an EnumValueOption for your friendly
name... you can use it by adding...
enum my_enum {
FOO = 1 [(<
my.package.name.>name)="Foo"];;
BAR = 2 [(<
my.package.name.>name)="Bar"];;
}
Note that if you have a package defined - you will need to use it when
referencing your extension.. If not, just use [(friendly_name)="XXXX"]
The () are important as this tells PB that you are referencing an
Extension.
In Java you can access these by calling (probably similar in C++)
enumValueDescriptor.getOptions().getExtension(MyProtobufOuterClass.friendly_name);
You will now have successfully defined a fixed string for each enum
value you want one for - you can do the same to associate the ordinals
of an existing enumeration with one you're using in protobuf by
defining an "ordinal" extension of type uint32.
-Benjamin Wright