Reputation: 11532
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 ?
Upvotes: 4
Views: 2136
Reputation: 9515
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;
};
Upvotes: 2