Re: [protobuf] Accesing message inside message

197 views
Skip to first unread message

Jason Hsueh

unread,
Nov 7, 2012, 5:29:04 PM11/7/12
to Javier Blesa Martínez, Protocol Buffers
Use mutable_repomessage()->set_nodeid... - see the C++ tutorial an intro to the generated accessors. https://developers.google.com/protocol-buffers/docs/cpptutorial


On Mon, Nov 5, 2012 at 1:59 AM, Javier Blesa Martínez <hea...@gmail.com> wrote:
Hi,

I have a protobuf definition:

message CBMessage {
  
  required int32 type = 1; //defines the kind of message that we send
  optional RepoMessage repomessage = 2;

  message RepoMessage { 
    optional int32 nodeid = 1;
}

And I would like to change the nodeid inside the RepoMessage:

CBTxMessages::CBMessage* cbmsg;
cbmsg = new CBTxMessages::CBMessage;

this->cbmsg->repomessage().set_nodeid(message[0]);

 but I have an error when compile:

error: pasar ‘const CBTxMessages::CBMessage_RepoMessage’ como el argumento ‘this’ de ‘void CBTxMessages::CBMessage_RepoMessage::set_nodeid(google::protobuf::int32)’ descarta a los calificadores [-fpermissive]

I understand that the function repomessage() is const, and the problem is related with that, but how can I solved?

Someone can help me, please?

Best regards,

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/protobuf/-/BL2qdZLLfpcJ.
To post to this group, send email to prot...@googlegroups.com.
To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.

Javier Blesa Martínez

unread,
Nov 8, 2012, 7:45:17 AM11/8/12
to prot...@googlegroups.com, Javier Blesa Martínez
Thank you!

It is solved.
Reply all
Reply to author
Forward
0 new messages