Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default values missing #5

Open
Ni42 opened this issue Aug 28, 2016 · 0 comments
Open

Default values missing #5

Ni42 opened this issue Aug 28, 2016 · 0 comments

Comments

@Ni42
Copy link

Ni42 commented Aug 28, 2016

Per this documentation: https://developers.google.com/protocol-buffers/docs/proto3#default fields are supposed to return their default value even if the parsed proto doesn't contain that value. Right now, I have to manually check for hasField() and implement the default value myself.

For example, check out FortType in this proto:
https://github.com/AeonLucid/POGOProtos/blob/master/src/POGOProtos/Map/Fort/FortData.proto
For FortType::GYM (0), my FortData proto doesn't contain any value on type, so getType() will return null, instead it should return FortType::GYM() (the first defined enum value).

Same thing for "owned_by_team": if it's 0, my proto doesn't contain data, and I have to manually check for hasOwnedbyTeam() and then assume 0 if it's missing, instead of just doing getOwnedByTeam()->value().

I shouldn't have to do this work myself judging from the specs.
Same thing applies to proto2: https://developers.google.com/protocol-buffers/docs/proto#optional

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants