[C++-sig] [boost.python] conversion between string and unsigned char *

Roman Yakovenko roman.yakovenko at gmail.com
Thu Aug 3 19:34:09 CEST 2006


On 8/3/06, Jan Langer <jan at langernetz.de> wrote:
> >>BOOST_PYTHON_MODULE(pyfdk){
> >>    bp::to_python_converter <StringT, StringT_converter> ();
> >
> > I think this line does not do what you expect. You are trying to
> > register custom
> > converter for C++ fundamental type. I could be wrong, but it seems to
> > me that boost.python
> > uses different approach ( type conversion ) when it comes to
> > fundamental C++ types.
>
> Actually, that was my intention, and I wanted to achieve it with the
> to_python_converter. But I probably did not understand the concept
> correctly.

No, I think that you understand it right, boost.python treats fundamental type
in special way and you can not change this.

> > If I right, than pyplusplus can help you.
> > 1. For every function, that uses StringT generate small wrapper,
> > replacing StringT with
> >    std::string or custom string class(
> > http://boost.org/libs/python/doc/v2/faq.html#custom_string )
>
> Okay, thank you, I will try to do that.
>
> > 2. Export those wrappers. Consider to run pyplusplus on generated
> > files, instead of
> >    adding code to the module builder.
>
> Can you please explain in more detail. Do you mean a two-stage
> generation process with pyplusplus?

Yes. First run you generate wrappers, second run you expose those wrappers.

> Regards,
> Jan

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/



More information about the Cplusplus-sig mailing list