[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyKDE] Interfacing to C++ standard library
From: Torsten Marek <shlomme () gmx ! net>
Date: 2002-12-11 21:23:38
[Download RAW message or body]
Jim Bublitz schrieb:
> On 11-Dec-02 Paul F. Kunz wrote:
>
>> To complete my SIP based Python extension module, I need to
>>convert from C++ to Python and vica versa an std::vector<double>
>>and std::vector<std::string>. I found some hints in this
>>mailing list's archive dated 13 Apr 2002. Is there a better
>>source of information on how to proceed?
>
>
> ...
> You'll might also need to use the same methods for std::string
> to convert to/from either a Python string or QString if it's used
> outside the mapped type/member code for std::vector<std::string>.
This is the mapping code for string:
%MappedType string
{
%HeaderCode
#include <string>
%End
%ConvertFromTypeCode
const char *s = sipCpp->c_str();
return PyString_FromString(s);
%End
%ConvertToTypeCode
// Allow a Python string whenever a string is expected.
if (sipIsErr == NULL)
return PyString_Check(sipPy);
if (sipPy == Py_None) {
*sipCppPtr = NULL;
return 0;
}
if (PyString_Check(sipPy)) {
*sipCppPtr = new string(PyString_AS_STRING(sipPy));
return 0;
}
*sipCppPtr = (string *)sipForceConvertTo_string(sipPy,sipIsErr);
return 1;
%End
};
It should just need string being replaced by std::string and
sipForceConvertTo_string(...) renamed to
sipForceConvertTo_std_string(...), but I'm not really sure about the
naming scheme, so please try yourself, before I post incorrect code.
Greetings
Torsten
_______________________________________________
PyKDE mailing list PyKDE@mats.gmd.de
http://mats.gmd.de/mailman/listinfo/pykde
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic