>> Adam, Could you please show simple example how to use tag number for
>> dispatch purpose.
>
> I believe he was referring to this sort of thing:
>
> http://code.google.com/apis/protocolbuffers/docs/techniques.html#union
Yes, exactly. In code, if you're using the enum-based technique:
switch (message.getType()) {
case FOO:
// use message.getFoo(), break
case BAR:
// use message.getBar(), break
case BAZ:
// use message.getBaz(), break
}
or if you're just using a set of optional fields:
if (message.hasFoo()) {
// use message.getFoo()
} else if (message.hasBar()) {
// use message.getBar()
} else if (message.hasBaz()) {
// use message.getBaz()
}
- Adam
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/protobuf?hl=en.