1

Given a message that looks like this,

message Event {
    required int32 event_id = 1;

    oneof EventType {
        FooEvent foo_event = 2;
        BarEvent bar_event = 3;
        BazEvent baz_event = 4;
    }
}

I want to define another map which uses the EventType oneof as a type. Precisely, I want to define something like this

message Sample {
    map<string, Event.EventTypeCase> someMap = 1;
}

But, this is not working. I get the error that

PROTOC FAILED: "Event.EventTypeCase" is not defined.
Suhas .N
  • 21
  • 3
  • 1
    `oneof` is not supposed to be used as a "base class". Maybe [Any](https://developers.google.com/protocol-buffers/docs/proto3#any) fits your use case for the map. – CK. Jan 10 '19 at 19:32

1 Answers1

1

I want to define another map which uses the EventType oneof as a type.

It isn't a type in the DSL, so: you can't. It is a conceptual grouping of fields in a specific message. The existence of Event.EventTypeCase is an implementation detail, not something that is not even mentioned in the DSL specification as far as I know (although protoc may or may not detect conflicts if you define your own enum or message with the same name)

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • I wasn't able to find a way of doing this, so I was wondering if I had missed something out. Thanks for clarifying :) – Suhas .N Jan 16 '19 at 05:01