[PyQt] SIP, newbie question

Sébastien Petitdemange sebastien.petitdemange at esrf.fr
Wed Jul 6 14:30:12 BST 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Johan,

By default sip only manage basic C type (int,float...) but not std type.
So you have to do a manual mapping like this:

%MappedType std::string
{
%TypeHeaderCode
#include <string>
%End

%ConvertToTypeCode
if (sipIsErr == NULL)
    return PyString_Check(sipPy);

    *sipCppPtr = new std::string(PyString_AsString(sipPy),
PyString_Size(sipPy));

    return sipGetState(sipTransferObj);
%End

%ConvertFromTypeCode
return PyString_FromStringAndSize(sipCpp->data(),sipCpp->length());
%End

};

Regards,

SEB
On 07/06/2011 03:14 PM, Johan Råde wrote:
> When I run SIP on the following SIP specification file
> 
>   %Module Test 0
>   void f(const string&s);
> 
> I get the error message
> 
>   sip: string is undefined
> 
> How do I fix that?
> 
> 
> 
> 
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJOFGNkAAoJEEtktDVosZgU+hUIAJC/3bS9dmvJ1rrtiVPs+nSB
P2zhP+BrefcJxyoxxZDruw2LT/GO3FTYui1DNcTe4ZfVqOsZmQS3ZbixrGcQArDS
xN1WkWFWIWNdghgywIAlIhAjqmUCxvDmMTBspPzb3y6zEo5IZiMWdprm/29ERyJ1
ymyXIf8jd4C+tZfyYzDECqbOGL4sMfGPz79Dp6XoUfNGBWhh7vdQc1vxBGkTQU6t
tHz+8WVKc+qTIW36P6zl/JPAFmw10dSBO8UnYFiDz5izKCjY28FS5jEdqR8o9Ib0
sa9DxgKO8Gfhen9ad6APXKV1X0I0alC27/Awvq/JQcr5MWa+7rswTSQkEbhYFA8=
=PTsO
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sebastien_petitdemange.vcf
Type: text/x-vcard
Size: 210 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110706/bb7070f0/attachment.vcf>


More information about the PyQt mailing list