Status: New
Owner: [email protected]
Labels: Type-Defect Priority-Medium
New issue 481 by [email protected]: Request - function to reset all defa
http://code.google.com/p/protobuf/issues/detail?id=481
In an effort to keep the message population code simple, I think it is
often useful to just write the message filler logic to dump all the state
to the message, without conditionally checking whether the values match the
default value or not. For this reason, I think it would be very beneficial
if the API provided a utility function one could call either after the
message is built, or perhaps alternate set variations(or a defaulted
parameter to the existing ones?), that provided a mechanism to only 'set'
those fields that differ from the default value for that field. This would
provide an easy way to trim the unneeded fields without having to manually
condition check every field before setting it on the message.
Message myMsg;
myMsg.set_somevar1( ... );
myMsg.set_somevar2( ... );
myMsg.clearDefaultFields();
There would of course be added expense of setting fields that may later be
unflagged, but in building complex or multi-level message structures, I
think the streamlining of the code not to include a bunch of manual
conditionals would often be worth that cost. Alternately, perhaps the
compiler can generate an alternate setter, such as
myMsg.set_somevar1_ifnotdefault( ... );
poor name, but you get the idea. this would have the benefit of being more
explicit at the field level, and be able to do the default check internally
and just not mark the field as being included right there, as opposed to
doing a 2nd pass through the entire message structure later.
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
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 http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.