/*
 * Module code.
 *
 * Generated by SIP 4.19.25
 */
#line 134 "/build/arcus/src/libArcus-4.13.1/python/Types.sip"
#include "Types.h"
#line 9 "/build/arcus/src/libArcus-4.13.1/build/python/sipArcuspart4.cpp"

#include "sipAPIArcus.h"

#line 23 "/build/arcus/src/libArcus-4.13.1/python/Types.sip"
#include <string>
#line 15 "/build/arcus/src/libArcus-4.13.1/build/python/sipArcuspart4.cpp"



extern "C" {static void assign_std_string(void *, SIP_SSIZE_T, void *);}
static void assign_std_string(void *sipDst, SIP_SSIZE_T sipDstIdx, void *sipSrc)
{
    reinterpret_cast< ::std::string *>(sipDst)[sipDstIdx] = *reinterpret_cast< ::std::string *>(sipSrc);
}


extern "C" {static void *array_std_string(SIP_SSIZE_T);}
static void *array_std_string(SIP_SSIZE_T sipNrElem)
{
    return new  ::std::string[sipNrElem];
}


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


/* Call the mapped type's destructor. */
extern "C" {static void release_std_string(void *, int);}
static void release_std_string(void *ptr, int)
{
    Py_BEGIN_ALLOW_THREADS
    delete reinterpret_cast< ::std::string *>(ptr);
    Py_END_ALLOW_THREADS
}



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

#line 38 "/build/arcus/src/libArcus-4.13.1/python/Types.sip"
    // Allow a Python string (or a unicode string) whenever a string is
    // expected.
    // If argument is a Unicode string, just decode it to UTF-8
    // If argument is a Python string, assume it's UTF-8
    if (sipIsErr == NULL)
        return (PyBytes_Check(sipPy) || PyUnicode_Check(sipPy));

    if (sipPy == Py_None)
    {
        *sipCppPtr = new std::string;
        return 1;
    }

    if (PyUnicode_Check(sipPy))
    {
        PyObject* s = PyUnicode_AsEncodedString(sipPy, "UTF-8", "");
        *sipCppPtr = new std::string(PyBytes_AS_STRING(s));
        Py_DECREF(s);
        return 1;
    }

    if (PyBytes_Check(sipPy))
    {
        *sipCppPtr = new std::string(PyBytes_AS_STRING(sipPy));
        return 1;
    }
    return 0;
#line 84 "/build/arcus/src/libArcus-4.13.1/build/python/sipArcuspart4.cpp"
}


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

#line 27 "/build/arcus/src/libArcus-4.13.1/python/Types.sip"
    // convert an std::string to a Python (unicode) string
    PyObject* newstring;
    newstring = PyUnicode_DecodeUTF8(sipCpp->c_str(), sipCpp->length(), NULL);
    if(newstring == NULL) {
        PyErr_Clear();
        newstring = PyBytes_FromString(sipCpp->c_str());
    }
    return newstring;
#line 102 "/build/arcus/src/libArcus-4.13.1/build/python/sipArcuspart4.cpp"
}


sipMappedTypeDef sipTypeDef_Arcus_std_string = {
    {
        -1,
        SIP_NULLPTR,
        0,
        SIP_TYPE_MAPPED,
        sipNameNr_std__string,     /* std::string */
        {0},
        0
    },
    {
        -1,
        {0, 0, 1},
        0, 0,
        0, 0,
        0, 0,
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
    },
    assign_std_string,
    array_std_string,
    copy_std_string,
    release_std_string,
    convertTo_std_string,
    convertFrom_std_string
};
