GobySoft / dccl

Dynamic Compact Control Language
Other
17 stars 13 forks source link

Added feature to omit ID from dccl message if desired #130

Closed tsaubergine closed 10 months ago

tsaubergine commented 10 months ago

This is useful for when we want to send the DCCL message wrapped in some other message such that the Protobuf type is known already and don't want to spend the 1-2 bytes to store the ID in the message.

Fixes #92.

Use by setting

option (dccl.msg).omit_id = true;

rather than including a (dccl.msg).id. Any of the decode methods that take a google::protobuf::Message* as an argument can be used where the correct fully instantiated Protobuf class is passed, providing the correct Descriptor to use to decode.

Also updated the normal case (omit_id: false) to check the descriptor ID against the received ID in the case where these decode methods are used. If they don't match, an exception is thrown.