Dear All,
is it possible to write a .thrift file so that c++ generared getter
methods are const?
Example:
myservice.thrift
service MyService {
string getName(1: i32 id),
MyService.h
class MyServiceClient : virtual public MyServiceIf {
void getName(std::string& _return, const int32_t id) const;
Regards,
Gianni
Hi Jens,
thanks for the explanation.
Of course I didn't want to say that my getName should be automatically
detected as a getter. I was just asking if there was a way to declare it
manually as const method (getter methods should always be const in c++).
On the other hand, if there are language-specific annotations, it seems
there is an improvement that could be done on c++ code generation.
Cheers,
Gianni
On 11/02/2020 00:19, Jens Geyer wrote:
> Hi,
>
> first, your example shows a method whoe name starts with "get". That does
> not imply that this is a getter, it's just a method like any other method.
>
> There is no option in the IDL syntax, since it is language agnostic.
> Available options special to c++ are these
>
> cpp (C++):
> cob_style: Generate "Continuation OBject"-style classes.
> no_client_completion: Omit calls to completion__() in CobClient class.
> no_default_operators: Omits generation of default operators ==, != and <
> templates: Generate templatized reader/writer methods.
> pure_enums: Generate pure enums instead of wrapper classes.
> include_prefix: Use full include paths in generated files.
> moveable_types: Generate move constructors and assignment operators.
> no_ostream_operators: Omit generation of ostream definitions.
> no_skeleton: Omits generation of skeleton.
>
> In addition, there's the possibility to specify annotations in the IDL:
>
> - cpp.customostream ... prevents emitting implementations for operator <<
> - cpp.type ..... override C++ type name
> - final ...... adds noexcept to DTORs
>
>
> So I would say no, not possible. You will have to patch the compiler
> yourself to achive that.
>
>
> -----Ursprüngliche Nachricht-----
> From: Gianni Ambrosio
> Sent: Monday, February 10, 2020 4:23 PM
> To: user@thrift.apache.org
> Subject: const method
>
> Dear All,
> is it possible to write a .thrift file so that c++ generared getter
> methods are const?
>
> Example:
>
> myservice.thrift
>
> service MyService {
> string getName(1: i32 id),
>
> MyService.h
>
> class MyServiceClient : virtual public MyServiceIf {
> void getName(std::string& _return, const int32_t id) const;
>
>
> Regards,
> Gianni
>
Hi,
first, your example shows a method whoe name starts with "get". That does
not imply that this is a getter, it's just a method like any other method.
There is no option in the IDL syntax, since it is language agnostic.
Available options special to c++ are these
cpp (C++):
cob_style: Generate "Continuation OBject"-style classes.
no_client_completion: Omit calls to completion__() in CobClient class.
no_default_operators: Omits generation of default operators ==, != and <
templates: Generate templatized reader/writer methods.
pure_enums: Generate pure enums instead of wrapper classes.
include_prefix: Use full include paths in generated files.
moveable_types: Generate move constructors and assignment operators.
no_ostream_operators: Omit generation of ostream definitions.
no_skeleton: Omits generation of skeleton.
In addition, there's the possibility to specify annotations in the IDL:
- cpp.customostream ... prevents emitting implementations for operator <<
- cpp.type ..... override C++ type name
- final ...... adds noexcept to DTORs
So I would say no, not possible. You will have to patch the compiler
yourself to achive that.
-----Ursprüngliche Nachricht-----
From: Gianni Ambrosio
Sent: Monday, February 10, 2020 4:23 PM
To: user@thrift.apache.org
Subject: const method
Dear All,
is it possible to write a .thrift file so that c++ generared getter
methods are const?
Example:
myservice.thrift
service MyService {
string getName(1: i32 id),
MyService.h
class MyServiceClient : virtual public MyServiceIf {
void getName(std::string& _return, const int32_t id) const;
Regards,
Gianni