/*
 * Interface wrapper code.
 *
 * Generated by SIP 6.7.0
 *
 * Copyright (c) 2022 Riverbank Computing Limited <info@riverbankcomputing.com>
 * 
 * This file is part of PyQt6-NetworkAuth.
 * 
 * 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 "sipAPIQtNetworkAuth.h"

#line 26 "/usr/lib/python3.10/site-packages/PyQt6/bindings/QtCore/qpycore_std_pair.sip"
#include <utility>
#line 29 "/build/pyqt6-networkauth/src/PyQt6_NetworkAuth-6.4.0/build/QtNetworkAuth/sipQtNetworkAuthstdpair0100QString0100QString.cpp"

#line 24 "/usr/lib/python3.10/site-packages/PyQt6/bindings/QtCore/qstring.sip"
#include <qstring.h>
#line 33 "/build/pyqt6-networkauth/src/PyQt6_NetworkAuth-6.4.0/build/QtNetworkAuth/sipQtNetworkAuthstdpair0100QString0100QString.cpp"


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


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


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


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



extern "C" {static int convertTo_std_pair_0100QString_0100QString(PyObject *, void **, int *, PyObject *, void **);}
static int convertTo_std_pair_0100QString_0100QString(PyObject *sipPy, void **sipCppPtrV, int *sipIsErr, PyObject *sipTransferObj, void **)
{
    std::pair< ::QString, ::QString> **sipCppPtr = reinterpret_cast<std::pair< ::QString, ::QString> **>(sipCppPtrV);

#line 47 "/usr/lib/python3.10/site-packages/PyQt6/bindings/QtCore/qpycore_std_pair.sip"
    if (!sipIsErr)
        return (PySequence_Check(sipPy) && !PyUnicode_Check(sipPy));

    Py_ssize_t len = PySequence_Size(sipPy);

    if (len != 2)
    {
        // A negative length should only be an internal error so let the
        // original exception stand.
        if (len >= 0)
            PyErr_Format(PyExc_TypeError,
                    "sequence has %zd elements but 2 elements are expected",
                    len);

        *sipIsErr = 1;

        return 0;
    }

    PyObject *firstobj = PySequence_GetItem(sipPy, 0);

    if (!firstobj)
    {
        *sipIsErr = 1;

        return 0;
    }

    int firststate;
    QString *first = reinterpret_cast<QString *>(
            sipForceConvertToType(firstobj, sipType_QString, sipTransferObj,
                    SIP_NOT_NONE, &firststate, sipIsErr));
 
    if (*sipIsErr)
    {
        PyErr_Format(PyExc_TypeError,
                "the first element has type '%s' but 'QString' is expected",
                sipPyTypeName(Py_TYPE(firstobj)));

        return 0;
    }

    PyObject *secondobj = PySequence_GetItem(sipPy, 1);

    if (!secondobj)
    {
        sipReleaseType(first, sipType_QString, firststate);
        Py_DECREF(firstobj);
        *sipIsErr = 1;

        return 0;
    }

    int secondstate;
    QString *second = reinterpret_cast<QString *>(
            sipForceConvertToType(secondobj, sipType_QString, sipTransferObj,
                    SIP_NOT_NONE, &secondstate, sipIsErr));
 
    if (*sipIsErr)
    {
        PyErr_Format(PyExc_TypeError,
                "the second element has type '%s' but 'QString' is expected",
                sipPyTypeName(Py_TYPE(secondobj)));

        Py_DECREF(secondobj);
        sipReleaseType(first, sipType_QString, firststate);
        Py_DECREF(firstobj);
        *sipIsErr = 1;

        return 0;
    }

    *sipCppPtr = new std::pair<QString, QString>(*first, *second);

    sipReleaseType(second, sipType_QString, secondstate);
    Py_DECREF(secondobj);
    sipReleaseType(first, sipType_QString, firststate);
    Py_DECREF(firstobj);
 
    return sipGetState(sipTransferObj);
#line 153 "/build/pyqt6-networkauth/src/PyQt6_NetworkAuth-6.4.0/build/QtNetworkAuth/sipQtNetworkAuthstdpair0100QString0100QString.cpp"
}


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

#line 30 "/usr/lib/python3.10/site-packages/PyQt6/bindings/QtCore/qpycore_std_pair.sip"
    QString *first = new QString(sipCpp->first);
    QString *second = new QString(sipCpp->second);
    PyObject *t = sipBuildResult(NULL, "(NN)", first, sipType_QString,
            sipTransferObj, second, sipType_QString, sipTransferObj);

    if (!t)
    {
        delete first;
        delete second;

        return 0;
    }

    return t;
#line 177 "/build/pyqt6-networkauth/src/PyQt6_NetworkAuth-6.4.0/build/QtNetworkAuth/sipQtNetworkAuthstdpair0100QString0100QString.cpp"
}


sipMappedTypeDef sipTypeDef_QtNetworkAuth_std_pair_0100QString_0100QString = {
    {
        SIP_NULLPTR,
        SIP_TYPE_MAPPED,
        sipNameNr_557,
        SIP_NULLPTR,
        SIP_NULLPTR
    },
    {
        -1,
        {0, 0, 1},
        0, 0,
        0, 0,
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
    },
    assign_std_pair_0100QString_0100QString,
    array_std_pair_0100QString_0100QString,
    copy_std_pair_0100QString_0100QString,
    release_std_pair_0100QString_0100QString,
    convertTo_std_pair_0100QString_0100QString,
    convertFrom_std_pair_0100QString_0100QString
};
