You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by "Fournier, Jean-Pierre (JP)" <jp...@avaya.com> on 2010/11/22 00:06:04 UTC

no c++ accessor methods?


Hi,

I just completed a little c++ based thrift 0.5.0 prototype and I was a bit surprised that there were no setter methods for fields.  

This is the kind of code i ended up writing:

myContact.firstname = string(parsedValue);             
myContact.__isset.firstname = true;

I'm curious why there are no accessor methods generated for c++. 

(I'm a c++ newbie so I wouldn't be surprised to hear that I am doing something stupid)


Any thoughts or pointers appreciated.

jp


Re: no c++ accessor methods?

Posted by David Reiss <dr...@facebook.com>.
> (I believe C++ only omits writing fields explicitly marked as optional in the IDL).
This is correct.

--David

On 11/22/2010 01:42 PM, Mark Slee wrote:
> This certainly seems like a reasonable thing to add. I'm not sure if there is a reason we have omitted these. 
> 
> I'm guessing that most people are just using C++ for server endpoints, which mainly receive data structures and use the implicit field semantics whereby fields are always written in responses (I believe C++ only omits writing fields explicitly marked as optional in the IDL).
> 
> I expect a patch which adds formal setters would be met with little opposition. Definitely feel free to dive in and add this.
> 
> Cheers,
> mcslee
> 
> -----Original Message-----
> From: Fournier, Jean-Pierre (JP) [mailto:jpfourn@avaya.com] 
> Sent: Sunday, November 21, 2010 3:06 PM
> To: user@thrift.apache.org
> Subject: no c++ accessor methods?
> 
> 
> 
> Hi,
> 
> I just completed a little c++ based thrift 0.5.0 prototype and I was a bit surprised that there were no setter methods for fields.  
> 
> This is the kind of code i ended up writing:
> 
> myContact.firstname = string(parsedValue);             
> myContact.__isset.firstname = true;
> 
> I'm curious why there are no accessor methods generated for c++. 
> 
> (I'm a c++ newbie so I wouldn't be surprised to hear that I am doing something stupid)
> 
> 
> Any thoughts or pointers appreciated.
> 
> jp
> 

RE: no c++ accessor methods?

Posted by Mark Slee <ms...@fb.com>.
This certainly seems like a reasonable thing to add. I'm not sure if there is a reason we have omitted these. 

I'm guessing that most people are just using C++ for server endpoints, which mainly receive data structures and use the implicit field semantics whereby fields are always written in responses (I believe C++ only omits writing fields explicitly marked as optional in the IDL).

I expect a patch which adds formal setters would be met with little opposition. Definitely feel free to dive in and add this.

Cheers,
mcslee

-----Original Message-----
From: Fournier, Jean-Pierre (JP) [mailto:jpfourn@avaya.com] 
Sent: Sunday, November 21, 2010 3:06 PM
To: user@thrift.apache.org
Subject: no c++ accessor methods?



Hi,

I just completed a little c++ based thrift 0.5.0 prototype and I was a bit surprised that there were no setter methods for fields.  

This is the kind of code i ended up writing:

myContact.firstname = string(parsedValue);             
myContact.__isset.firstname = true;

I'm curious why there are no accessor methods generated for c++. 

(I'm a c++ newbie so I wouldn't be surprised to hear that I am doing something stupid)


Any thoughts or pointers appreciated.

jp