/*
 * Interface wrapper code.
 *
 * Generated by SIP 6.14.0
 *
 * Copyright (c) 2024 Riverbank Computing Limited <info@riverbankcomputing.com>
 * 
 * This file is part of PyQt5.
 * 
 * This file may be used under the terms of the GNU General Public License
 * version 3.0 as published by the Free Software Foundation and appearing in
 * the file LICENSE included in the packaging of this file.  Please review the
 * following information to ensure the GNU General Public License version 3.0
 * requirements will be met: http://www.gnu.org/copyleft/gpl.html.
 * 
 * If you do not wish to use this file under the terms of the GPL version 3.0
 * then you may purchase a commercial license.  For more information contact
 * info@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.
 */

#include "sipAPIQtWebKitWidgets.h"

#line 259 "/build/pyqt5/src/PyQt5-5.15.11/sip/QtCore/qpycore_qmap.sip"
#include <qmap.h>
#line 29 "/build/pyqt5/src/PyQt5-5.15.11/build/QtWebKitWidgets/sipQtWebKitWidgetsQMultiMap0100QString0100QString.cpp"

#line 27 "/build/pyqt5/src/PyQt5-5.15.11/sip/QtCore/qstring.sip"
#include <qstring.h>
#line 33 "/build/pyqt5/src/PyQt5-5.15.11/build/QtWebKitWidgets/sipQtWebKitWidgetsQMultiMap0100QString0100QString.cpp"


extern "C" {static void assign_QMultiMap_0100QString_0100QString(void *, Py_ssize_t, void *);}
static void assign_QMultiMap_0100QString_0100QString(void *sipDst, Py_ssize_t sipDstIdx, void *sipSrc)
{
    reinterpret_cast<QMultiMap< ::QString, ::QString> *>(sipDst)[sipDstIdx] = *reinterpret_cast<QMultiMap< ::QString, ::QString> *>(sipSrc);
}


extern "C" {static void *array_QMultiMap_0100QString_0100QString(Py_ssize_t);}
static void *array_QMultiMap_0100QString_0100QString(Py_ssize_t sipNrElem)
{
    return new QMultiMap< ::QString, ::QString>[sipNrElem];
}


extern "C" {static void *copy_QMultiMap_0100QString_0100QString(const void *, Py_ssize_t);}
static void *copy_QMultiMap_0100QString_0100QString(const void *sipSrc, Py_ssize_t sipSrcIdx)
{
    return new QMultiMap< ::QString, ::QString>(reinterpret_cast<const QMultiMap< ::QString, ::QString> *>(sipSrc)[sipSrcIdx]);
}


/* Call the mapped type's destructor. */
extern "C" {static void release_QMultiMap_0100QString_0100QString(void *, int);}
static void release_QMultiMap_0100QString_0100QString(void *sipCppV, int)
{
    QMultiMap< ::QString, ::QString> *sipCpp = reinterpret_cast<QMultiMap< ::QString, ::QString> *>(sipCppV);
    delete sipCpp;
}



extern "C" {static int convertTo_QMultiMap_0100QString_0100QString(PyObject *, void **, int *, PyObject *);}
static int convertTo_QMultiMap_0100QString_0100QString(PyObject *sipPy, void **, int *sipIsErr, PyObject *)
{
#line 341 "/build/pyqt5/src/PyQt5-5.15.11/sip/QtCore/qpycore_qmap.sip"
    if (!sipIsErr)
        return PyDict_Check(sipPy);

    // Note that PyQt v5.1 contains an unused implementation that can be
    // restored if needed (although it will need updating to accept an iterable
    // rather than just a list of values).
    PyErr_SetString(PyExc_NotImplementedError,
            "converting to QMultiMap<QString, QString> is unsupported");

    *sipIsErr = 1;

    return 0;
#line 83 "/build/pyqt5/src/PyQt5-5.15.11/build/QtWebKitWidgets/sipQtWebKitWidgetsQMultiMap0100QString0100QString.cpp"
}


extern "C" {static PyObject *convertFrom_QMultiMap_0100QString_0100QString(void *, PyObject *);}
static PyObject *convertFrom_QMultiMap_0100QString_0100QString(void *sipCppV, PyObject *sipTransferObj)
{
    QMultiMap< ::QString, ::QString> *sipCpp = reinterpret_cast<QMultiMap< ::QString, ::QString> *>(sipCppV);

#line 263 "/build/pyqt5/src/PyQt5-5.15.11/sip/QtCore/qpycore_qmap.sip"
    PyObject *d = PyDict_New();

    if (!d)
        return 0;

    QList<QString> keys = sipCpp->keys();
    QList<QString>::const_iterator kit = keys.constBegin();
    QList<QString>::const_iterator kit_end = keys.constEnd();

    while (kit != kit_end)
    {
        QString *k = new QString(*kit);
        PyObject *kobj = sipConvertFromNewType(k, sipType_QString,
                sipTransferObj);

        if (!kobj)
        {
            delete k;
            Py_DECREF(d);

            return 0;
        }

        // Create a Python list as the dictionary value.
        QList<QString> values = sipCpp->values(*kit);
        PyObject *vobj = PyList_New(values.count());

        if (!vobj)
        {
            Py_DECREF(kobj);
            Py_DECREF(d);

            return 0;
        }

        QList<QString>::const_iterator vit = values.constBegin();
        QList<QString>::const_iterator vit_end = values.constEnd();

        for (int i = 0; vit != vit_end; ++i)
        {
            QString *sv = new QString(*vit);
            PyObject *svobj = sipConvertFromNewType(sv, sipType_QString,
                    sipTransferObj);

            if (!svobj)
            {
                delete sv;
                Py_DECREF(vobj);
                Py_DECREF(kobj);
                Py_DECREF(d);

                return 0;
            }

            PyList_SetItem(vobj, i, svobj);

            ++vit;
        }

        int rc = PyDict_SetItem(d, kobj, vobj);

        Py_DECREF(vobj);
        Py_DECREF(kobj);

        if (rc < 0)
        {
            Py_DECREF(d);

            return 0;
        }

        ++kit;
    }

    return d;
#line 168 "/build/pyqt5/src/PyQt5-5.15.11/build/QtWebKitWidgets/sipQtWebKitWidgetsQMultiMap0100QString0100QString.cpp"
}


sipMappedTypeDef sipTypeDef_QtWebKitWidgets_QMultiMap_0100QString_0100QString = {
    {
        -1,
        SIP_NULLPTR,
        SIP_NULLPTR,
        SIP_TYPE_MAPPED,
        sipNameNr_735,
        SIP_NULLPTR,
        SIP_NULLPTR,
    },
    {
        -1,
        {0, 0, 1},
        0, SIP_NULLPTR,
        0, SIP_NULLPTR,
        0, SIP_NULLPTR,
        {SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR}
    },
    assign_QMultiMap_0100QString_0100QString,
    array_QMultiMap_0100QString_0100QString,
    copy_QMultiMap_0100QString_0100QString,
    release_QMultiMap_0100QString_0100QString,
    convertTo_QMultiMap_0100QString_0100QString,
    convertFrom_QMultiMap_0100QString_0100QString
};
