This is a common pattern. Currently the only solution is to declare a bunch of optional fields.
On Mon, Oct 12, 2009 at 12:48 PM, dukeFan <mark.geib...@gmail.com> wrote: > > I would like to define a message that include a couple of fields and > then a message, which comes from a list of available messages, like. > > message Command { > required int id = 1; > optional string description = 2; > one_of { > c0001, > c0002, > c0003 > } > } > > message c0001 { > required string operation = 1; > required int data = 2; > } > > message c0002 { > required string operation =1; > required float data = 2; > } > > I have resorted to this > > message Command { > required int id = 1; > optional string description = 2; > optional C0001 c0001 = 3; > optional C0002 c0002 = 4; > optional C0003 c0003 = 5; > } > > But there is no easy way to enforce what I want, that is just one of > the possible Cxxxx messages. > > Thanks, > Mark. > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~----------~----~----~----~------~----~------~--~---