/*
 * 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 "sipAPIQtGui.h"

#line 28 "/build/pyqt5/src/PyQt5-5.15.11/sip/QtCore/qpycore_qvector.sip"
#include <qvector.h>
#line 29 "/build/pyqt5/src/PyQt5-5.15.11/build/QtGui/sipQtGuiQVector0100QTextLayoutFormatRange.cpp"

#line 48 "/build/pyqt5/src/PyQt5-5.15.11/sip/QtGui/qtextlayout.sip"
#include <qtextlayout.h>
#line 70 "/build/pyqt5/src/PyQt5-5.15.11/sip/QtGui/qtextlayout.sip"
#include <qtextlayout.h>
#line 35 "/build/pyqt5/src/PyQt5-5.15.11/build/QtGui/sipQtGuiQVector0100QTextLayoutFormatRange.cpp"


extern "C" {static void assign_QVector_0100QTextLayout_FormatRange(void *, Py_ssize_t, void *);}
static void assign_QVector_0100QTextLayout_FormatRange(void *sipDst, Py_ssize_t sipDstIdx, void *sipSrc)
{
    reinterpret_cast<QVector< ::QTextLayout::FormatRange> *>(sipDst)[sipDstIdx] = *reinterpret_cast<QVector< ::QTextLayout::FormatRange> *>(sipSrc);
}


extern "C" {static void *array_QVector_0100QTextLayout_FormatRange(Py_ssize_t);}
static void *array_QVector_0100QTextLayout_FormatRange(Py_ssize_t sipNrElem)
{
    return new QVector< ::QTextLayout::FormatRange>[sipNrElem];
}


extern "C" {static void *copy_QVector_0100QTextLayout_FormatRange(const void *, Py_ssize_t);}
static void *copy_QVector_0100QTextLayout_FormatRange(const void *sipSrc, Py_ssize_t sipSrcIdx)
{
    return new QVector< ::QTextLayout::FormatRange>(reinterpret_cast<const QVector< ::QTextLayout::FormatRange> *>(sipSrc)[sipSrcIdx]);
}


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



extern "C" {static int convertTo_QVector_0100QTextLayout_FormatRange(PyObject *, void **, int *, PyObject *);}
static int convertTo_QVector_0100QTextLayout_FormatRange(PyObject *sipPy, void **sipCppPtrV, int *sipIsErr, PyObject *sipTransferObj)
{
    QVector< ::QTextLayout::FormatRange> **sipCppPtr = reinterpret_cast<QVector< ::QTextLayout::FormatRange> **>(sipCppPtrV);

#line 58 "/build/pyqt5/src/PyQt5-5.15.11/sip/QtCore/qpycore_qvector.sip"
    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;
    }

    QVector<QTextLayout::FormatRange> *qv = new QVector<QTextLayout::FormatRange>;
 
    for (Py_ssize_t i = 0; ; ++i)
    {
        PyErr_Clear();
        PyObject *itm = PyIter_Next(iter);

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

                return 0;
            }

            break;
        }

        int state;
        QTextLayout::FormatRange *t = reinterpret_cast<QTextLayout::FormatRange *>(
                sipForceConvertToType(itm, sipType_QTextLayout_FormatRange, sipTransferObj,
                        SIP_NOT_NONE, &state, sipIsErr));

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

            Py_DECREF(itm);
            delete qv;
            Py_DECREF(iter);

            return 0;
        }

        qv->append(*t);

        sipReleaseType(t, sipType_QTextLayout_FormatRange, state);
        Py_DECREF(itm);
    }

    Py_DECREF(iter);
 
    *sipCppPtr = qv;
 
    return sipGetState(sipTransferObj);
#line 146 "/build/pyqt5/src/PyQt5-5.15.11/build/QtGui/sipQtGuiQVector0100QTextLayoutFormatRange.cpp"
}


extern "C" {static PyObject *convertFrom_QVector_0100QTextLayout_FormatRange(void *, PyObject *);}
static PyObject *convertFrom_QVector_0100QTextLayout_FormatRange(void *sipCppV, PyObject *sipTransferObj)
{
    QVector< ::QTextLayout::FormatRange> *sipCpp = reinterpret_cast<QVector< ::QTextLayout::FormatRange> *>(sipCppV);

#line 32 "/build/pyqt5/src/PyQt5-5.15.11/sip/QtCore/qpycore_qvector.sip"
    PyObject *l = PyList_New(sipCpp->size());

    if (!l)
        return 0;

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

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

            return 0;
        }

        PyList_SetItem(l, i, tobj);
    }

    return l;
#line 179 "/build/pyqt5/src/PyQt5-5.15.11/build/QtGui/sipQtGuiQVector0100QTextLayoutFormatRange.cpp"
}


sipMappedTypeDef sipTypeDef_QtGui_QVector_0100QTextLayout_FormatRange = {
    {
        -1,
        SIP_NULLPTR,
        SIP_NULLPTR,
        SIP_TYPE_MAPPED,
        sipNameNr_1139,
        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_QVector_0100QTextLayout_FormatRange,
    array_QVector_0100QTextLayout_FormatRange,
    copy_QVector_0100QTextLayout_FormatRange,
    release_QVector_0100QTextLayout_FormatRange,
    convertTo_QVector_0100QTextLayout_FormatRange,
    convertFrom_QVector_0100QTextLayout_FormatRange
};
