Hello, I would like to wrap a class that looks like below (taken from an example I found on another site)
#include <boost/python.hpp> #include <boost/python/suite/indexing/vector_indexing_suite.hpp> #include <boost/python/suite/indexing/map_indexing_suite.hpp> typedef std::vector<std::string> MyList; class MyClass { public: MyList myFuncGet() { return MyList(); } void myFuncSet(MyList& list) { list.push_back("Hello"); } // stuff }; BOOST_PYTHON_MODULE(MyModule) { class_<MyList>("MyList") .def(vector_indexing_suite<MyList>() ); class_<MyClass>("MyClass") .def("myFuncGet", &MyClass::myFuncGet) .def("myFuncSet", &MyClass::myFuncSet) ; } However, this is what I get when I try to use it from python: Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from MyModule import * >>> mc = MyClass() >>> p = [] >>> mc.myFuncSet(p) Traceback (most recent call last): File "<stdin>", line 1, in <module> Boost.Python.ArgumentError: Python argument types in MyClass.myFuncSet(MyClass, list) did not match C++ signature: myFuncSet(MyClass {lvalue}, std::vector<std::string, std::allocator<std::string> > {lvalue}) >>> I know I'm missing a converter function, but I'm new to boost and I don't know what the converter should look like in this case. I've found lots of working examples of how to return a vector, but I want to be able to pass the vector into the function by reference and modify it. I would really appreciate it if someone could complete the example by adding the necessary converter code. Thanks in advance. --Mike
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig