oneof is a property of the message that the fields are in; it's not really
a type of its own. Instead, you could do something like

message Event {
  required int32 event_id = 1;
  optional EventSpecifics specifics = 2;
}

message EventSpecifics {
  oneof EventType {
     optional FooEvent foo_event = 1;
     optional BarEvent bar_event = 2;
  }
}



On Thu, Jan 10, 2019 at 9:16 AM Suhas N <[email protected]> wrote:

> 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.
>
> How can I use the oneof as a type?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to