Re: [protobuf] How to avoid error C2662 on nested messages

2013-05-14 Thread Barzo
Thanks a lot Chris!
Daniele.

Il giorno martedì 14 maggio 2013 00:49:50 UTC+2, Christopher Head ha 
scritto:
>
> -BEGIN PGP SIGNED MESSAGE- 
> Hash: SHA256 
>
> Use the mutable_header() function instead. This creates the contained 
> object if it does not already exist, and returns a pointer instead of a 
> reference. 
>
> Chris 
>
> On Mon, 13 May 2013 02:34:49 -0700 (PDT) 
> Barzo > wrote: 
>
> > Hi, 
> > I have messages defined as: 
> > 
> > message MsgHeader 
> > { 
> >   required EMessages  opCode= 1; 
> >   required int32  sessionRef= 2; 
> >   optional int32  transactionId = 3 [default = 0]; 
> >   optional int32  status= 4 [default = 0]; 
> > } 
> > 
> > message MSG_EVENT_METHOD_STATUS 
> > { 
> >   optional EMessagesopCode  = 1 [default = 
> > E_MSG_EVENT_METHOD_STATUS]; 
> >   required EMessagesopCodeSent  = 2; 
> >   required MsgHeaderheader  = 3; 
> > } 
> > 
> > In my code, when I wanna set the header params, I get the compiler 
> > error C2662 because the header() method is const. 
> > So I cannot do something like: 
> > 
> > MSG_EVENT_METHOD_STATUS msg; 
> > msg.header().set_status(0); 
> > 
> > Is there a way to avoid this or I have to make a const_cast on the 
> > header()? 
> > 
> > BR, 
> > Daniele. 
> > 
>
> -BEGIN PGP SIGNATURE- 
> Version: GnuPG v2.0.19 (GNU/Linux) 
>
> iF4EAREIAAYFAlGRbhEACgkQMcVpqLZH/3xiVgD+Pzl+ZIwViRBGC2Czv/+y8Q+s 
> yjE1BncDwQI7RyJNOfMA+gP9O1FCTa9HIcKu4GM50o615D4h+NCzpkv+Koo/HTVj 
> =/e9k 
> -END PGP SIGNATURE- 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [protobuf] How to avoid error C2662 on nested messages

2013-05-13 Thread Christopher Head
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Use the mutable_header() function instead. This creates the contained
object if it does not already exist, and returns a pointer instead of a
reference.

Chris

On Mon, 13 May 2013 02:34:49 -0700 (PDT)
Barzo  wrote:

> Hi,
> I have messages defined as:
> 
> message MsgHeader
> {
>   required EMessages  opCode= 1;
>   required int32  sessionRef= 2;
>   optional int32  transactionId = 3 [default = 0];
>   optional int32  status= 4 [default = 0];
> }
> 
> message MSG_EVENT_METHOD_STATUS
> {
>   optional EMessagesopCode  = 1 [default = 
> E_MSG_EVENT_METHOD_STATUS];
>   required EMessagesopCodeSent  = 2;
>   required MsgHeaderheader  = 3;
> }
> 
> In my code, when I wanna set the header params, I get the compiler
> error C2662 because the header() method is const.
> So I cannot do something like:
> 
> MSG_EVENT_METHOD_STATUS msg;
> msg.header().set_status(0);
> 
> Is there a way to avoid this or I have to make a const_cast on the
> header()?
> 
> BR,
> Daniele.
> 

-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.19 (GNU/Linux)

iF4EAREIAAYFAlGRbhEACgkQMcVpqLZH/3xiVgD+Pzl+ZIwViRBGC2Czv/+y8Q+s
yjE1BncDwQI7RyJNOfMA+gP9O1FCTa9HIcKu4GM50o615D4h+NCzpkv+Koo/HTVj
=/e9k
-END PGP SIGNATURE-

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.