I'm trying to create a SWIG Python interface for a C++ library, to add Python wrappers for some functions, and I would greatly appreciate some help from someone experienced with SWIG.
For now I have such sources:
test.h
namespace Test {
class CodeResponseEvent {
public:
CodeResponseEvent(std::string activation_code);
std::string getActivationCode() const;
private:
const std::string activation_code_;
};
class CodeRequestEvent {
public:
CodeRequestEvent(std::string user_id);
std::shared_ptr<CodeResponseEvent> execute();
private:
const std::string user_id_;
};
}
test.i
%module test
%include std_string.i
%include <std_shared_ptr.i>
%{#include "test.h"%}
%include "test.h"
%shared_ptr(Test::CodeResponseEvent);
Python code looks like:
codeResponse = test.CodeRequestEvent("user").execute()
As result I get value
<Swig Object of type 'std::shared_ptr< Test::CodeResponseEvent> *'>
So the question is how to unwrap this SwigPyobject to invoke getActivationCode() method?