// qset.sip generated by MetaSIP on Fri Feb 10 10:37:52 2012 // // This file is part of the QtCore Python extension module. // // Copyright (c) 2011 Riverbank Computing Limited // // This file is part of PyQt. // // This file may be used under the terms of the GNU General Public // License versions 2.0 or 3.0 as published by the Free Software // Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3 // included in the packaging of this file. Alternatively you may (at // your option) use any later version of the GNU General Public // License if such license has been publicly approved by Riverbank // Computing Limited (or its successors, if any) and the KDE Free Qt // Foundation. In addition, as a special exception, Riverbank gives you // certain additional rights. These rights are described in the Riverbank // GPL Exception version 1.1, which can be found in the file // GPL_EXCEPTION.txt in this package. // // If you are unsure which license is appropriate for your use, please // contact the sales department at sales@riverbankcomputing.com. // // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. %If (Py_v3) // QSet is implemented as a Python set in Python v3. %MappedType QSet /DocType="set-of-int"/ { %TypeHeaderCode #include %End %ConvertFromTypeCode // Create the set. PyObject *s; if ((s = PySet_New(NULL)) == NULL) return NULL; // Set the set elements. QSet::const_iterator it = sipCpp->constBegin(); QSet::const_iterator end = sipCpp->constEnd(); while (it != end) { PyObject *el_obj; if ((el_obj = SIPLong_FromLong(*it)) == NULL) { Py_DECREF(s); return NULL; } PySet_Add(s, el_obj); ++it; } return s; %End %ConvertToTypeCode PyObject *it = PyObject_GetIter(sipPy), *itm; // Check the type if that is all that is required. if (sipIsErr == NULL) { if (it == NULL) return 0; Py_DECREF(it); return 1; } if (it == NULL) { *sipIsErr = 1; return 0; } QSet *qs = new QSet; while ((itm = PyIter_Next(it)) != NULL) { qs->insert(SIPLong_AsLong(itm)); Py_DECREF(itm); } Py_DECREF(it); *sipCppPtr = qs; return sipGetState(sipTransferObj); %End }; %End %If (!Py_v3) // QSet is implemented as a Python list in Python v2. %MappedType QSet /DocType="list-of-int"/ { %TypeHeaderCode #include %End %ConvertFromTypeCode // Create the list. PyObject *l; if ((l = PyList_New(sipCpp->size())) == NULL) return NULL; // Set the list elements. QSet::const_iterator it = sipCpp->constBegin(); for (int i = 0; i < sipCpp->size(); ++i) { PyObject *el_obj; if ((el_obj = SIPLong_FromLong(*it)) == NULL) { Py_DECREF(l); return NULL; } PyList_SET_ITEM(l, i, el_obj); ++it; } return l; %End %ConvertToTypeCode PyObject *it = PyObject_GetIter(sipPy), *itm; // Check the type if that is all that is required. if (sipIsErr == NULL) { if (it == NULL) return 0; Py_DECREF(it); return 1; } if (it == NULL) { *sipIsErr = 1; return 0; } QSet *qs = new QSet; while ((itm = PyIter_Next(it)) != NULL) { qs->insert(SIPLong_AsLong(itm)); Py_DECREF(itm); } Py_DECREF(it); *sipCppPtr = qs; return sipGetState(sipTransferObj); %End }; %End %If (Py_v3) // QSet is implemented as a Python set in Python v3. %MappedType QSet /DocType="set-of-int"/ { %TypeHeaderCode #include %End %ConvertFromTypeCode // Create the set. PyObject *s; if ((s = PySet_New(NULL)) == NULL) return NULL; // Set the set elements. QSet::const_iterator it = sipCpp->constBegin(); QSet::const_iterator end = sipCpp->constEnd(); while (it != end) { PyObject *el_obj; if ((el_obj = PyLong_FromUnsignedLong(*it)) == NULL) { Py_DECREF(s); return NULL; } PySet_Add(s, el_obj); ++it; } return s; %End %ConvertToTypeCode PyObject *it = PyObject_GetIter(sipPy), *itm; // Check the type if that is all that is required. if (sipIsErr == NULL) { if (it == NULL) return 0; Py_DECREF(it); return 1; } if (it == NULL) { *sipIsErr = 1; return 0; } QSet *qs = new QSet; while ((itm = PyIter_Next(it)) != NULL) { qs->insert(PyLong_AsUnsignedLong(itm)); Py_DECREF(itm); } Py_DECREF(it); *sipCppPtr = qs; return sipGetState(sipTransferObj); %End }; %End %If (!Py_v3) // QSet is implemented as a Python list in Python v2. %MappedType QSet /DocType="list-of-int"/ { %TypeHeaderCode #include %End %ConvertFromTypeCode // Create the list. PyObject *l; if ((l = PyList_New(sipCpp->size())) == NULL) return NULL; // Set the list elements. QSet::const_iterator it = sipCpp->constBegin(); for (int i = 0; i < sipCpp->size(); ++i) { PyObject *el_obj; if ((el_obj = PyLong_FromUnsignedLong(*it)) == NULL) { Py_DECREF(l); return NULL; } PyList_SET_ITEM(l, i, el_obj); ++it; } return l; %End %ConvertToTypeCode PyObject *it = PyObject_GetIter(sipPy), *itm; // Check the type if that is all that is required. if (sipIsErr == NULL) { if (it == NULL) return 0; Py_DECREF(it); return 1; } if (it == NULL) { *sipIsErr = 1; return 0; } QSet *qs = new QSet; while ((itm = PyIter_Next(it)) != NULL) { qs->insert(PyLong_AsUnsignedLong(itm)); Py_DECREF(itm); } Py_DECREF(it); *sipCppPtr = qs; return sipGetState(sipTransferObj); %End }; %End %If (Py_v3) // QSet is implemented as a Python set in Python v3. template %MappedType QSet /DocType="set-of-TYPE"/ { %TypeHeaderCode #include %End %ConvertFromTypeCode // Create the set. PyObject *s; if ((s = PySet_New(NULL)) == NULL) return NULL; // Set the set elements. QSet::const_iterator it = sipCpp->constBegin(); QSet::const_iterator end = sipCpp->constEnd(); while (it != end) { PyObject *tobj; // The explicit (void *) cast allows TYPE to be const. if ((tobj = sipConvertFromType((void *)*it, sipType_TYPE, sipTransferObj)) == NULL) { Py_DECREF(s); return NULL; } PySet_Add(s, tobj); ++it; } return s; %End %ConvertToTypeCode PyObject *it = PyObject_GetIter(sipPy), *itm; // Check the type if that is all that is required. if (sipIsErr == NULL) { if (it == NULL) return 0; while ((itm = PyIter_Next(it)) != NULL) { int ok = sipCanConvertToType(itm, sipType_TYPE, 0); Py_DECREF(itm); if (!ok) { Py_DECREF(it); return 0; } } Py_DECREF(it); return 1; } if (it == NULL) { *sipIsErr = 1; return 0; } QSet *qs = new QSet; while ((itm = PyIter_Next(it)) != NULL) { TYPE *t = reinterpret_cast(sipConvertToType(itm, sipType_TYPE, sipTransferObj, 0, 0, sipIsErr)); Py_DECREF(itm); if (*sipIsErr) { delete qs; Py_DECREF(it); return 0; } qs->insert(t); } Py_DECREF(it); *sipCppPtr = qs; return sipGetState(sipTransferObj); %End }; %End %If (!Py_v3) // QSet is implemented as a Python list in Python v2. template %MappedType QSet /DocType="list-of-TYPE"/ { %TypeHeaderCode #include %End %ConvertFromTypeCode // Create the list. PyObject *l; if ((l = PyList_New(sipCpp->size())) == NULL) return NULL; // Set the list elements. QSet::const_iterator it = sipCpp->constBegin(); for (int i = 0; i < sipCpp->size(); ++i) { PyObject *tobj; // The explicit (void *) cast allows TYPE to be const. if ((tobj = sipConvertFromType((void *)*it, sipType_TYPE, sipTransferObj)) == NULL) { Py_DECREF(l); return NULL; } PyList_SET_ITEM(l, i, tobj); ++it; } return l; %End %ConvertToTypeCode PyObject *it = PyObject_GetIter(sipPy), *itm; // Check the type if that is all that is required. if (sipIsErr == NULL) { if (it == NULL) return 0; while ((itm = PyIter_Next(it)) != NULL) { int ok = sipCanConvertToType(itm, sipType_TYPE, 0); Py_DECREF(itm); if (!ok) { Py_DECREF(it); return 0; } } Py_DECREF(it); return 1; } if (it == NULL) { *sipIsErr = 1; return 0; } QSet *qs = new QSet; while ((itm = PyIter_Next(it)) != NULL) { TYPE *t = reinterpret_cast(sipConvertToType(itm, sipType_TYPE, sipTransferObj, 0, 0, sipIsErr)); Py_DECREF(itm); if (*sipIsErr) { delete qs; Py_DECREF(it); return 0; } qs->insert(t); } Py_DECREF(it); *sipCppPtr = qs; return sipGetState(sipTransferObj); %End }; %End %If (Py_v3) // QSet is implemented as a Python set in Python v3. template %MappedType QSet /DocType="set-of-TYPE"/ { %TypeHeaderCode #include %End %ConvertFromTypeCode // Create the set. PyObject *s; if ((s = PySet_New(NULL)) == NULL) return NULL; // Set the set elements. QSet::const_iterator it = sipCpp->constBegin(); QSet::const_iterator end = sipCpp->constEnd(); while (it != end) { TYPE *t = new TYPE(*it); PyObject *tobj; if ((tobj = sipConvertFromNewType(t, sipType_TYPE, sipTransferObj)) == NULL) { Py_DECREF(s); delete t; return NULL; } PySet_Add(s, tobj); ++it; } return s; %End %ConvertToTypeCode PyObject *it = PyObject_GetIter(sipPy), *itm; // Check the type if that is all that is required. if (sipIsErr == NULL) { if (it == NULL) return 0; while ((itm = PyIter_Next(it)) != NULL) { int ok = sipCanConvertToType(itm, sipType_TYPE, SIP_NOT_NONE); Py_DECREF(itm); if (!ok) { Py_DECREF(it); return 0; } } Py_DECREF(it); return 1; } if (it == NULL) { *sipIsErr = 1; return 0; } QSet *qs = new QSet; while ((itm = PyIter_Next(it)) != NULL) { int state; TYPE *t = reinterpret_cast(sipConvertToType(itm, sipType_TYPE, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr)); Py_DECREF(itm); if (*sipIsErr) { sipReleaseType(t, sipType_TYPE, state); delete qs; Py_DECREF(it); return 0; } qs->insert(*t); sipReleaseType(t, sipType_TYPE, state); } Py_DECREF(it); *sipCppPtr = qs; return sipGetState(sipTransferObj); %End }; %End %If (!Py_v3) // QSet is implemented as a Python list in Python v2. template %MappedType QSet /DocType="list-of-TYPE"/ { %TypeHeaderCode #include %End %ConvertFromTypeCode // Create the list. PyObject *l; if ((l = PyList_New(sipCpp->size())) == NULL) return NULL; // Set the list elements. QSet::const_iterator it = sipCpp->constBegin(); for (int i = 0; i < sipCpp->size(); ++i) { TYPE *t = new TYPE(*it); PyObject *tobj; if ((tobj = sipConvertFromNewType(t, sipType_TYPE, sipTransferObj)) == NULL) { Py_DECREF(l); delete t; return NULL; } PyList_SET_ITEM(l, i, tobj); ++it; } return l; %End %ConvertToTypeCode PyObject *it = PyObject_GetIter(sipPy), *itm; // Check the type if that is all that is required. if (sipIsErr == NULL) { if (it == NULL) return 0; while ((itm = PyIter_Next(it)) != NULL) { int ok = sipCanConvertToType(itm, sipType_TYPE, SIP_NOT_NONE); Py_DECREF(itm); if (!ok) { Py_DECREF(it); return 0; } } Py_DECREF(it); return 1; } if (it == NULL) { *sipIsErr = 1; return 0; } QSet *qs = new QSet; while ((itm = PyIter_Next(it)) != NULL) { int state; TYPE *t = reinterpret_cast(sipConvertToType(itm, sipType_TYPE, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr)); Py_DECREF(itm); if (*sipIsErr) { sipReleaseType(t, sipType_TYPE, state); delete qs; Py_DECREF(it); return 0; } qs->insert(*t); sipReleaseType(t, sipType_TYPE, state); } Py_DECREF(it); *sipCppPtr = qs; return sipGetState(sipTransferObj); %End }; %End