I\'m new to both protocol buffers and C++, so this may be a basic question, but I haven\'t had any luck finding answers. Basically, I want the functionality of a dictionary
You could use custom options to associate a string with each enum member: https://developers.google.com/protocol-buffers/docs/proto#options
It would look like this in the .proto:
extend google.protobuf.FieldOptions {
optional string name = 12345;
}
enum UnitType {
KmPerHour = 1 [(name) = "km/h"];
MiPerHour = 2 [(name) = "mph"];
}
Beware, though, that some third-party protobuf libraries don't understand these options.