/*
 * Interface wrapper code.
 *
 * Generated by SIP 4.19.6
 */

#include "sipAPIKWidgetsAddons.h"

#include <qlist.h>

#include <qtimezone.h>


extern "C" {static void assign_QList_0100QTimeZone(void *, SIP_SSIZE_T, void *);}
static void assign_QList_0100QTimeZone(void *sipDst, SIP_SSIZE_T sipDstIdx, void *sipSrc)
{
    reinterpret_cast<QList< ::QTimeZone> *>(sipDst)[sipDstIdx] = *reinterpret_cast<QList< ::QTimeZone> *>(sipSrc);
}


extern "C" {static void *array_QList_0100QTimeZone(SIP_SSIZE_T);}
static void *array_QList_0100QTimeZone(SIP_SSIZE_T sipNrElem)
{
    return new QList< ::QTimeZone>[sipNrElem];
}


extern "C" {static void *copy_QList_0100QTimeZone(const void *, SIP_SSIZE_T);}
static void *copy_QList_0100QTimeZone(const void *sipSrc, SIP_SSIZE_T sipSrcIdx)
{
    return new QList< ::QTimeZone>(reinterpret_cast<const QList< ::QTimeZone> *>(sipSrc)[sipSrcIdx]);
}


/* Call the mapped type's destructor. */
extern "C" {static void release_QList_0100QTimeZone(void *, int);}
static void release_QList_0100QTimeZone(void *ptr, int)
{
    delete reinterpret_cast<QList< ::QTimeZone> *>(ptr);
}



extern "C" {static int convertTo_QList_0100QTimeZone(PyObject *, void **, int *, PyObject *);}
static int convertTo_QList_0100QTimeZone(PyObject *sipPy,void **sipCppPtrV,int *sipIsErr,PyObject *sipTransferObj)
{
    QList< ::QTimeZone> **sipCppPtr = reinterpret_cast<QList< ::QTimeZone> **>(sipCppPtrV);

    PyObject *iter = PyObject_GetIter(sipPy);

    if (!sipIsErr)
    {
        PyErr_Clear();
        Py_XDECREF(iter);

        return (iter
#if PY_MAJOR_VERSION < 3
                && !PyString_Check(sipPy)
#endif
                && !PyUnicode_Check(sipPy));
    }

    if (!iter)
    {
        *sipIsErr = 1;

        return 0;
    }

    QList<QTimeZone> *ql = new QList<QTimeZone>;
 
    for (Py_ssize_t i = 0; ; ++i)
    {
        PyErr_Clear();
        PyObject *itm = PyIter_Next(iter);

        if (!itm)
        {
            if (PyErr_Occurred())
            {
                delete ql;
                Py_DECREF(iter);
                *sipIsErr = 1;

                return 0;
            }

            break;
        }

        int state;
        QTimeZone *t = reinterpret_cast<QTimeZone *>(
                sipForceConvertToType(itm, sipType_QTimeZone, sipTransferObj,
                        SIP_NOT_NONE, &state, sipIsErr));

        if (*sipIsErr)
        {
            PyErr_Format(PyExc_TypeError,
                    "index %zd has type '%s' but 'QTimeZone' is expected", i,
                    sipPyTypeName(Py_TYPE(itm)));

            Py_DECREF(itm);
            delete ql;
            Py_DECREF(iter);

            return 0;
        }

        ql->append(*t);

        sipReleaseType(t, sipType_QTimeZone, state);
        Py_DECREF(itm);
    }
 
    Py_DECREF(iter);

    *sipCppPtr = ql;
 
    return sipGetState(sipTransferObj);
}


extern "C" {static PyObject *convertFrom_QList_0100QTimeZone(void *, PyObject *);}
static PyObject *convertFrom_QList_0100QTimeZone(void *sipCppV, PyObject *sipTransferObj)
{
   QList< ::QTimeZone> *sipCpp = reinterpret_cast<QList< ::QTimeZone> *>(sipCppV);

    PyObject *l = PyList_New(sipCpp->size());

    if (!l)
        return 0;

    for (int i = 0; i < sipCpp->size(); ++i)
    {
        QTimeZone *t = new QTimeZone(sipCpp->at(i));
        PyObject *tobj = sipConvertFromNewType(t, sipType_QTimeZone,
                sipTransferObj);

        if (!tobj)
        {
            delete t;
            Py_DECREF(l);

            return 0;
        }

        PyList_SetItem(l, i, tobj);
    }

    return l;
}


sipMappedTypeDef sipTypeDef_KWidgetsAddons_QList_0100QTimeZone = {
    {
        -1,
        0,
        0,
        SIP_TYPE_MAPPED,
        sipNameNr_4674,     /* QList<QTimeZone> */
        {0},
        0
    },
    {
        -1,
        {0, 0, 1},
        0, 0,
        0, 0,
        0, 0,
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
    },
    assign_QList_0100QTimeZone,
    array_QList_0100QTimeZone,
    copy_QList_0100QTimeZone,
    release_QList_0100QTimeZone,
    convertTo_QList_0100QTimeZone,
    convertFrom_QList_0100QTimeZone
};
