I've tried changing the default of the field to -1.
Without rebuilding the Messages, re-reading them with the new
definitions simply gives me the following:
has_uploadlimit = false; uploadlimit= -1.

Since this is the case, I assume that the field in the Message itself
isn't initialized, and that the problem isn't in the C++ porting, but
rather in the way protobuf-net serializes the data (I'm using a C#
application to do that).
When the field isn't initialized, the has_ method in c++ returns
false, but the Python implementation provides the default value, and
so does the C# implementation.

Does that sound like a realistic explanation?

Jon

On Aug 11, 7:36 pm, Peter Keen <peter.k...@bugsplat.info> wrote:
> If I understand the docs correctly has_* will return false if the
> value is the same as the default, which in the case of numbers
> defaults to 0.
>
> --Pete
>
>
>
> On Tuesday, August 11, 2009, multijon <multi...@gmail.com> wrote:
>
> > Hi,
>
> > I'm seeing a strange behaviour of the protobuf library in the
> > following situation:
>
> > I have a message which contains an optional field uint32
> > 'uploadLimit'.
> > I have created and serialized a message containing the value 0 in this
> > field.
>
> > When reading this message in Python and C#, I have the value 0 stored
> > in the field, as expected.
>
> > When reading this message in C++, however, has_uploadlimit() returns
> > 0, instead of 1. uploadlimit() itself returns also 0, but I'm not sure
> > whether I can count on it, since it is not set.
>
> > Is this really unexpected? Have I misunderstood the usage of the has_
> > method?
>
> > Jon
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to