You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Zhiqiu Kong <br...@gmail.com> on 2011/06/14 01:42:05 UTC

Why do we need both args & prags when generating cpp codes?

Hi,

I am a beginner on Thrift and am learning it from the tutorial. I generated
cpp codes and tried to find out how the codes are generated. But I am
confused about the co-existence of args & pargs classes. For example, Thrift
generated both Calculator_add_pargs and Calculator_add_args for the function
add().

As far as I found out, _pargs version is used by the client and is much
simpler than _args version. For example, the former lacks __is_set struct,
has only write() function. It makes sense because the client does not need
to process request thus it is unnecessary for it to read arguments. Also,
_pargs version has pointers to the arguments as its members, which is
different from _args version. I guess this is what "p" stands for
(pointers)?

I also checked the source code, which is t_cpp_generator.cc, and found
_pargs is used when generating a service client definition and _args is used
for process function. So generally the client will use _pargs, while the
server will use _args, if I understand correctly.

But my question is, why do we need the _pargs version? It seems that it is
the subset of _args, except for its pointer type members. I understand it
does not hurt to have two versions and it should work well. But I cannot
help to figure out the reason why we need to do this. It will be a great
help if you woud like to give me some insights or guidance on this.

Thanks,

Zhiqiu Kong

Re: Why do we need both args & prags when generating cpp codes?

Posted by Zhiqiu Kong <zk...@duke.edu>.
Hi Rich,

Thank you so much for your reply. But I am still confused about the
"overload". As far as I understand, the functionalities provided by pargs
class seems to be the subset of the ones provided by args class. So why
cannot we let the client use args class to write the arguments? And I think
it can also use args class to overload functions.

Thanks,

Zhiqiu


On Tue, Jun 14, 2011 at 7:01 AM, Richard Salz <rs...@us.ibm.com> wrote:

> Your "isset" provides one clue.
>
> On the client you can overload functions to handle optional input/request
> parameters.  How can you do that on the server, which has to fill in
> results by putting values in pointers?
>
>        /r$
>
> --
> STSM, WebSphere Appliance Architect
> https://www.ibm.com/developerworks/mydeveloperworks/blogs/soma/
>
>

Re: Why do we need both args & prags when generating cpp codes?

Posted by Richard Salz <rs...@us.ibm.com>.
Your "isset" provides one clue.

On the client you can overload functions to handle optional input/request 
parameters.  How can you do that on the server, which has to fill in 
results by putting values in pointers?

        /r$

--
STSM, WebSphere Appliance Architect
https://www.ibm.com/developerworks/mydeveloperworks/blogs/soma/