[C++-sig] mapping object pointers with boost
Monty Taylor
monty at inaugust.com
Tue Oct 10 21:54:38 CEST 2006
Hey all,
So all the examples in the docs just deal with standard arguments, as
far as I can tell, and I'm stuck trying to figure this out. I'm
guessing I could write a wrapper, but I'm hoping there is some simple
way I'm just not seeing...
Oh, and I'm interfacing code that can't change, so I'll have to wrap
it rather than fix it. :)
I've got a class with a constructor that looks like this:
Ndb::Ndb(Ndb_cluster_connection*, const char*, const char*);
I have an Ndb_cluster_connection already defined:
class_<Ndb_cluster_connection>("Ndb_cluster_connection")
.def("connect",&Ndb_cluster_connection::connect)
.def("wait_until_ready",&Ndb_cluster_connection::wait_until_ready)
;
and it works. So I tried doing this:
class_<Ndb>("Ndb")
.def(init<Ndb_cluster_connection,str,str>());
Which did not work. As you might expect, I get this error:
boost/python/object/value_holder.hpp:134: error: no matching function
for call to 'Ndb::Ndb()'
Ndb.hpp:1084: note: candidates are: Ndb::Ndb(Ndb_cluster_connection*,
const char*, const char*)
Ndb.hpp:1047: note: Ndb::Ndb(const Ndb&)
I'm not even trying to deal with the overloads at the moment, although
maybe I have to.
Any thoughts on a sensible way to deal with this? Am I looking at
wrapping this in some way? The usage from the python side should sort
of look like:
conn=Ndb_cluster_connection()
n=Ndb(conn,"foo","bar")
I suppose I could make an Ndb_cluster_connection::getNdb() which would
be easier to wrap in this case - but I would love to understand
general mechanism better so I can deal with things the 'right' way.
This will not be the only time I need to do something like that.
Pointers to the right place in the docs are appreciated, too.
Thanks!
Monty
More information about the Cplusplus-sig
mailing list