Not happening for me.

-- message.proto --
enum Value {
        V1 = 0;
        V2 = 1;
        V3 = 2;
}

message Message {
        required Value value = 1;
        required int32 integer = 2;
        required string text = 3;
}
-- test.cpp --
#include "message.pb.h"
#include <iostream>
#include <string>

int main() {
        std::string buffer;
        {
                Message m;
                m.set_value(V1);
                m.set_integer(27);
                m.set_text("Hello World");
                m.SerializeToString(&buffer);
        }

        {
                Message m;
                m.ParseFromString(buffer);
                std::cout << "value = " << m.value() << '\n';
                std::cout << "integer = " << m.integer() << '\n';
                std::cout << "text = " << m.text() << '\n';
        }

        return 0;
}
-- console output --
value = 0
integer = 27
text = Hello World
-- end of copy --

Can you narrow it down a bit more from this?

Chris

On Mon, 24 Oct 2011 06:53:07 -0700 (PDT)
jsia <jsi...@gmail.com> wrote:

> Did you have any resolution on this?  Im having the same issue,  it
> does not happen with int data types, this problem happens on boolean
> data types and enum data types
> 
> On Sep 20, 2:51 pm, Michael Videlgauz <mich...@videlgauz.com> wrote:
> > I forgot to mention in my previous post that there are int32 fields
> > in my messages and I do send messages with 0 value in them. If my
> > problem was null character then all those messages also were
> > corrupted I guess?...(and no, those 0-valued int32 fields are not
> > last in the message)
> >
> > On Sep 13, 9:48 pm, Jason Hsueh <jas...@google.com> wrote:
> >
> > > What's your code snippet for serializing and parsing? The 0 enum
> > > value ends up getting encoded as the null character: assuming
> > > this is in C++, I'd guess that you're using some c-style string
> > > routines that are prematurely terminating the string at the null
> > > character.
> >
> > > On Tue, Sep 13, 2011 at 1:39 AM, Michael Videlgauz
> > > <mich...@videlgauz.com>wrote:
> >
> > > > I have a message definition with enum type and field in it.
> > > > When my application sets this field to value that is equal to 0
> > > > the ENTIRE message arrives to receiver (after serialization and
> > > > de-serialization) with ALL fields reset (all integers are 0-s
> > > > and strings are empty)
> >
> > > > Is it a bug in serialization/deserialization or zero is not
> > > > allowed as numeric enum value? The documentation
> > > > (http://code.google.com/apis/
> > > > protocolbuffers/docs/proto.html#enum) shows example where 0 is
> > > > used as numeric value inside enum (UNIVERSAL):
> >
> > > >  enum Corpus {
> > > >    UNIVERSAL = 0;
> > > >    WEB = 1;
> > > >    IMAGES = 2;
> > > >    LOCAL = 3;
> > > >    NEWS = 4;
> > > >    PRODUCTS = 5;
> > > >    VIDEO = 6;
> > > >  }
> >
> > > > --
> > > > 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.
> 

-- 
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