[C++-sig] converters
Ralf W. Grosse-Kunstleve
rwgk at yahoo.com
Mon Jun 9 19:27:24 CEST 2003
--- "Jacques A. Vidrine" <nectar at celabo.org> wrote:
> I'm having some difficulty due to the fact that conversions between
> the Python string type and std::string have NUL-terminated string
> semantics rather than the expected `opaque byte sequence' semantics.
What version of boost are you using? I thought this was fixed in 1.30.0.
> For my immediate needs, I thought I could simply substitute
> vector<char> and my own converters instead. (Indeed, the API I'm
> wrapping uses vector<char> rather than std::string.) I found that
> this was quite easy to do for returning values to Python:
>
> struct voc_to_str {
> static PyObject *convert(const vector<char> v) {
> return PyString_FromStringAndSize(&v[0], v.size());
> }
> };
>
> to_python_converter<vector<char>, voc_to_str>();
>
> but I don't quite see how one arranges for the opposite transformation
> (vector<char> -> python::str).
I am confused by "vector<char> -> python::str". Anyway, maybe this is useful:
http://mail.python.org/pipermail/c++-sig/2003-May/004133.html
A bit tedious but very powerful. See also the Boost.Python FAQ (I believe
question 2).
Ralf
__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com
More information about the Cplusplus-sig
mailing list