[C++-sig] How to converter std::string* in boost.python?
simon zhang
hapopen at gmail.com
Fri Dec 21 12:52:28 CET 2012
How to converter std::string* in boost.python?I have to handle some data of
c++ in python.The data may be big.So I return a pointer to python. But
there are some errors.
c++
#include <boost/python.hpp>#include <string>
class A {public:
A() {
data="342342fgsf";
ss=&data;
}
std::string *ss;
std::string data;};
BOOST_PYTHON_MODULE(ctopy){
using namespace boost::python;
class_<A> ("A",init<>())
.add_property(ss,&A::ss)
;}
python
import ctopy
t1=ctopy.A()
print t1.ss #error.TypeError:No to_python (by-value) converter
found for c++ type:std::string*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20121221/3a6956c7/attachment.html>
More information about the Cplusplus-sig
mailing list