wow.  I will try that.  Yes, I am trying to set a complete 'foo'
message.

Is there documentation anywhere on this? I am coming up empty with web
searches...

On Sep 23, 8:25 am, Henner Zeller <h.zel...@acm.org> wrote:
> Hi,
>
> On Wed, Sep 23, 2009 at 08:13, jayt0...@gmail.com <jayt0...@gmail.com> wrote:
>
> > I am having trouble accessing many members of my .proto file.  It
> > seems that compound members are not accessible with set_() method
> > calls.  I saw in your example code the use of mutable_() calls. What
> > does this apply to and is there documentation on it? could this be the
> > solution to my problem?
>
> You should describe your problem more closely, it is not quite clear
> what you mean.
>
> If you have a message Bar, that contains a message Foo, say:
>
> message Foo {
>    optional int32 value = 1;
>
> }
>
> message Bar {
>    optional Foo foo = 1;
>
> }
>
> you would access 'foo' to set a value with
>    Bar message;
>    message.mutable_foo()->set_value(42);
> If there is no 'foo', it will implicitly be created (so has_bar() will
> return 'true' afterwards').
>
> .. while accessing can be const
>    if (message.has_foo())
>       printf("%d", message.bar().value());
>
> But it sounds like you would like to 'set' a complete Foo message. So
> if you want to 'set' a complete Foo, you would use CopyFrom()
>   Foo foo_message;
>   foo_message.set_value(42);
>
>   Bar bar_message;
>   bar_message.mutable_bar()->CopyFrom(foo_message);
>
> -h
--~--~---------~--~----~------------~-------~--~----~
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