Hello

I was wondering what was the best way to parse messages with
extensions in C++. In the documentation I found this sentence:
"Note that you can use the ListFields reflection method (in C++, Java,
and Python) to get a list of all fields present in the message,
including extensions. You might use this as part of a scheme for
registering handlers for diverse message types."

However no further information is given and I am a bit puzzled on how
to use this reflection interface. For now I just check every single
expected extension using the HasExtension but I'd like something more
generic and cleaner which does not explode whenever more message types
are added:

if(msg.HasExtension(RobotDataProtocol::acknowledge_ext)) {
...
} else if(msg.HasExtension(RobotDataProtocol::assistance_ext)) {
...
} else if(msg.HasExtension(RobotDataProtocol::dynamicWindow_ext)) {
... and so on

Should be something like (with parsers a map with a parser for each
known extension)
Parser p = parsers.get(msg.extensionType());
if(p != null)
 p.parse(msg);

Any other more generic solution are also highly appreciated!

Kind regards

Johan

-- 
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.

Reply via email to