sol2 icon indicating copy to clipboard operation
sol2 copied to clipboard

Inheritance class, template class, how to bind

Open littleboss01 opened this issue 2 years ago • 0 comments

cpp code

template<class StringT>
class Request {
public:
	StringT method  ;
	StringT url;
};

template<class StringT>
struct Response {
	int statusCode = 0;
	StringT body;
};

template<class StringT>
class HttpClient
{
public:	
	virtual Response<StringT> Get(StringT url) = 0;

};

class QHttpClient : public HttpClient<QString>
{
public:
	QHttpClient();
	~QHttpClient();

	Response<QString> override;
}

lua code

local client=QHttpClient()
client:Get()

How to use the sol library to bind QHttpClient class to c++, note that it is an inherited abstract class,Request Response also needs to be bound

littleboss01 avatar Jul 19 '23 16:07 littleboss01