On Tuesday, 24 November 2015 19:36:11 UTC, Teddy Zhang wrote:
>
> How do I store a HashSet<EnumType> with protobuf?
>

Have a repeated field of the enum type, so that you get a collection - and 
then make sure you transform it into a set in your code. proto doesn't have 
the notion of a set as such.
 

> Regarding the proto2 implementation, if I defined my enum as 1, 2, 4 etc, 
> and I set the enum to value 3 (combination of 1 & 2), it serialize the 
> fields correctly. But when deserialize, I get value 0 back (as 3 is not in 
> enum).
>

Yes, because that's the defined behaviour in proto2 for an undefined value. 
You're trying to use proto enums in a way that they weren't designed for, 
which is never going to be a pleasant experience. It's not about being a 
"combination" of values - proto doesn't have any such concept. It's just a 
value which isn't defined.

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

Reply via email to