Note that there are some explanatory texts on larger screens.

plurals
  1. POBoost-Python raw pointers constructors
    primarykey
    data
    text
    <p>I am trying to expose a C++ library to python using boost-python. The library actually wraps an underlying C api, so uses raw pointers a lot. </p> <pre><code>// implementation of function that creates a Request object inline Request Service::createRequest(const char* operation) const { blpapi_Request_t *request; ExceptionUtil::throwOnError( blpapi_Service_createRequest(d_handle, &amp;request, operation) ); return Request(request); } // request.h class Request { blpapi_Request_t *d_handle; Element d_elements; Request&amp; operator=(const Request&amp; rhs); // not implemented public: explicit Request(blpapi_Request_t *handle); Request(RequestRef ref); Request(Request &amp;src); }; // request.cpp BOOST_PYTHON_MODULE(request) { class_&lt;blpapi_Request_t&gt;; class_&lt;Request, boost::noncopyable&gt;("Request", init&lt;blpapi_Request_t *&gt;()) .def(init&lt;Request&amp;&gt;()) ; } </code></pre> <p>Although request.cpp compiles successfully, when I try and use the object I get the following error:</p> <pre><code>// error output TypeError: No to_python (by-value) converter found for C++ type: class Request </code></pre> <p>In-order to call this the python code looks like:</p> <pre><code>from session import * from service import * from request import * so = SessionOptions() so.setServerHost('localhost') so.setServerPort(8194) session = Session(so) # start sesssion if not session.start(): print 'Failed to start session' raise Exception if not session.openService('//blp/refdata'): print 'Failed to open service //blp/refdata' raise Exception service = session.getService('//blp/refdata') request = service.createRequest('ReferenceDataRequest') </code></pre> <p>The other objects (SessionOptions, Session, Service) etc are also c++ objects that I have successfully created boost-python wrappers for.</p> <p>As I understand from the boost-python docs this has something to do with passing a raw pointer around, but I don't really understand what else I should do ...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload