I have three different format of messages in code and I made all three .proto files and compiled. I already have another, to say regular,class with lots of enums and I need to use that enums in all three classes. Is there any way to use enums from external-regular class and not to define in proto in all three files same enums ?
Asked
Active
Viewed 1,613 times
1 Answers
2
I'm not quite sure what you mean by an external-regular class...?
If you want to define the enum in C++, and then put it in a Protobuf, just put an int field in the proto.
But if you want a common enum used by multiple protos, you can use imports:
common.proto:
package foo_common;
enum Color {
red = 1;
black = 2;
}
tree.proto:
package foo_tree;
import "common.proto";
message Node {
optional foo_common.Color color = 1;
};

poolie
- 9,289
- 1
- 47
- 74