On Friday, 17 July 2015 02:34:21 UTC+1, Wu XIANG wrote:
>
>
>   Is it true that has methods for optional fields in proto3 are removed 
> from generated message ?
>

For primitive types, yes.
 

>   If so, how can I decide if this field has been set or not ?
>

You can't. An int32 field that's been set to 0 is exactly the same as an 
int32 field that hasn't been set at all.

(For oneofs, you could still tell that it was the int32 field that was set, 
so that's slightly difference.)

>From the documentation:

> Note that for scalar message fields, once a message is parsed there's no 
way of telling whether a field was explicitly set to the default value (for 
example whether a boolean was set to false) or just not set at all: you 
should bear this in mind when defining your message types.

If you need a field which is "an int32 value, or not set" you can use the 
google.protobuf.Int32Value message type.

Jon

-- 
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 protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to