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

#line 26 "/build/pyqt6/src/PyQt6-6.4.0/sip/QtCore/qanystringview.sip"
#include <qanystringview.h>
#line 29 "/build/pyqt6/src/PyQt6-6.4.0/build/QtCore/sipQtCoreQAnyStringView.cpp"

#line 30 "/build/pyqt6/src/PyQt6-6.4.0/sip/QtCore/qanystringview.sip"
struct PyQtAnyStringState
{
    const sipTypeDef *instance_type;    // The instance's generated type.
    void *instance;                     // Either the QByteArray or QString.
    int instance_state;                 // The state of the instance conversion.
};
#line 38 "/build/pyqt6/src/PyQt6-6.4.0/build/QtCore/sipQtCoreQAnyStringView.cpp"


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


extern "C" {static void *array_QAnyStringView(Py_ssize_t);}
static void *array_QAnyStringView(Py_ssize_t sipNrElem)
{
    return new  ::QAnyStringView[sipNrElem];
}


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


/* Call the mapped type's destructor. */
extern "C" {static void release_QAnyStringView(void *, int, void *);}
static void release_QAnyStringView(void *sipCppV, int, void *sipUserState)
{
     ::QAnyStringView *sipCpp = reinterpret_cast< ::QAnyStringView *>(sipCppV);
#line 82 "/build/pyqt6/src/PyQt6-6.4.0/sip/QtCore/qanystringview.sip"
delete sipCpp;

PyQtAnyStringState *state = reinterpret_cast<PyQtAnyStringState *>(sipUserState);

sipReleaseType(state->instance, state->instance_type, state->instance_state);

delete state;
#line 75 "/build/pyqt6/src/PyQt6-6.4.0/build/QtCore/sipQtCoreQAnyStringView.cpp"
}



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

#line 39 "/build/pyqt6/src/PyQt6-6.4.0/sip/QtCore/qanystringview.sip"
if (sipIsErr == NULL)
    return sipCanConvertToType(sipPy, sipType_QString, 0) ||
           sipCanConvertToType(sipPy, sipType_QByteArray, SIP_NOT_NONE);

PyQtAnyStringState *state = new PyQtAnyStringState;

if (sipCanConvertToType(sipPy, sipType_QString, 0))
{
    QString *qs = reinterpret_cast<QString *>(
            sipConvertToType(sipPy, sipType_QString, sipTransferObj, 0,
                    &state->instance_state, sipIsErr));

    if (*sipIsErr)
        return 0;

    *sipCppPtr = new QAnyStringView(*qs);
    state->instance_type = sipType_QString;
    state->instance = qs;
}
else
{
    QByteArray *qba = reinterpret_cast<QByteArray *>(
            sipConvertToType(sipPy, sipType_QByteArray, sipTransferObj,
                    SIP_NOT_NONE, &state->instance_state, sipIsErr));

    if (*sipIsErr)
        return 0;

    *sipCppPtr = new QAnyStringView(*qba);
    state->instance_type = sipType_QByteArray;
    state->instance = qba;
}

*sipUserStatePtr = state;

return sipGetState(sipTransferObj);
#line 122 "/build/pyqt6/src/PyQt6-6.4.0/build/QtCore/sipQtCoreQAnyStringView.cpp"
}


extern "C" {static PyObject *convertFrom_QAnyStringView(void *, PyObject *);}
static PyObject *convertFrom_QAnyStringView(void *sipCppV, PyObject *)
{
    ::QAnyStringView *sipCpp = reinterpret_cast< ::QAnyStringView *>(sipCppV);

#line 78 "/build/pyqt6/src/PyQt6-6.4.0/sip/QtCore/qanystringview.sip"
    return qpycore_PyObject_FromQString(sipCpp->toString());
#line 133 "/build/pyqt6/src/PyQt6-6.4.0/build/QtCore/sipQtCoreQAnyStringView.cpp"
}


sipMappedTypeDef sipTypeDef_QtCore_QAnyStringView = {
    {
        SIP_NULLPTR,
        SIP_TYPE_ALLOW_NONE|SIP_TYPE_USER_STATE|SIP_TYPE_MAPPED,
        sipNameNr_QAnyStringView,
        SIP_NULLPTR,
        SIP_NULLPTR
    },
    {
        -1,
        {0, 0, 1},
        0, 0,
        0, 0,
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
    },
    assign_QAnyStringView,
    array_QAnyStringView,
    copy_QAnyStringView,
    release_QAnyStringView,
    convertTo_QAnyStringView,
    convertFrom_QAnyStringView
};
