@@ -1834,6 +1834,110 @@ template <TYPE>
18341834%End
18351835};
18361836
1837+ // QList<QgsField> is implemented as a Python list of QgsField.
1838+ %MappedType QList<QgsField> /DocType=" list-of-qgsfield" /
1839+ {
1840+ %TypeHeaderCode
1841+ #include < qgsfield.h>
1842+ %End
1843+
1844+ %ConvertFromTypeCode
1845+ PyObject *l = PyList_New (sipCpp->size ());
1846+
1847+ if (!l)
1848+ return 0 ;
1849+
1850+ for (int i = 0 ; i < sipCpp->size (); ++i)
1851+ {
1852+ QgsField *t = new QgsField (sipCpp->at (i));
1853+ PyObject *tobj = sipConvertFromNewType (t, sipType_QgsField, sipTransferObj);
1854+
1855+ if (!tobj)
1856+ {
1857+ delete t;
1858+ Py_DECREF (l);
1859+
1860+ return 0 ;
1861+ }
1862+
1863+ PyList_SET_ITEM (l, i, tobj);
1864+ }
1865+
1866+ return l;
1867+ %End
1868+
1869+ %ConvertToTypeCode
1870+ PyObject *iter = PyObject_GetIter (sipPy);
1871+
1872+ if (!sipIsErr)
1873+ {
1874+ Py_XDECREF (iter);
1875+
1876+ return (iter
1877+ #if PY_MAJOR_VERSION < 3
1878+ && !PyString_Check (sipPy)
1879+ #endif
1880+ && !PyUnicode_Check (sipPy));
1881+ }
1882+
1883+ if (!iter)
1884+ {
1885+ *sipIsErr = 1 ;
1886+
1887+ return 0 ;
1888+ }
1889+
1890+ QList<QgsField> *ql = new QList<QgsField>;
1891+
1892+ for (SIP_SSIZE_T i = 0 ; ; ++i)
1893+ {
1894+ PyErr_Clear ();
1895+ PyObject *itm = PyIter_Next (iter);
1896+
1897+ if (!itm)
1898+ {
1899+ if (PyErr_Occurred ())
1900+ {
1901+ delete ql;
1902+ Py_DECREF (iter);
1903+ *sipIsErr = 1 ;
1904+
1905+ return 0 ;
1906+ }
1907+
1908+ break ;
1909+ }
1910+
1911+ int state;
1912+ QgsField *t = reinterpret_cast <QgsField *>( sipForceConvertToType (itm, sipType_QgsField, sipTransferObj, SIP_NOT_NONE , &state, sipIsErr));
1913+
1914+ if (*sipIsErr)
1915+ {
1916+ PyErr_Format (PyExc_TypeError,
1917+ " index %ld has type '%s' but 'QgsField' is expected" ,
1918+ (long ) i, Py_TYPE (itm)->tp_name );
1919+
1920+ Py_DECREF (itm);
1921+ delete ql;
1922+ Py_DECREF (iter);
1923+
1924+ return 0 ;
1925+ }
1926+
1927+ ql->append (*t);
1928+
1929+ sipReleaseType (t, sipType_QgsField, state);
1930+ Py_DECREF (itm);
1931+ }
1932+
1933+ Py_DECREF (iter);
1934+
1935+ *sipCppPtr = ql;
1936+
1937+ return sipGetState (sipTransferObj);
1938+ %End
1939+ };
1940+
18371941%If (QVECTORINT_CONVERSION )
18381942// QVector<int> is implemented as a Python list of integers.
18391943%MappedType QVector<int > /DocType=" list-of-int" /
0 commit comments