aboutsummaryrefslogtreecommitdiffstats
path: root/PySide/QtCore/qbytearray_conversions.h
blob: daa16099f7819244d4d8bb1c7041673143a794e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
namespace Shiboken {

inline bool Converter<QByteArray>::checkType(PyObject* pyObj)
{
    return ValueTypeConverter<QByteArray>::checkType(pyObj);
}

inline bool Converter<QByteArray>::isConvertible(PyObject* pyObj)
{
    if (ValueTypeConverter<QByteArray>::isConvertible(pyObj))
        return true;
    SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType< ::QByteArray >());
    return Shiboken::Converter<const char *>::checkType(pyObj)
        || (ObjectType::isExternalConvertible(shiboType, pyObj));
}

inline QByteArray Converter<QByteArray>::toCpp(PyObject* pyObj)
{
    if (pyObj == Py_None)
        return 0;
    else if (PyObject_TypeCheck(pyObj, SbkType<QByteArray>()))
        return *Converter<QByteArray*>::toCpp(pyObj);
    else if (PyString_Check(pyObj))
        return QByteArray(PyString_AS_STRING(pyObj), PyString_GET_SIZE(pyObj));
    else
        return ValueTypeConverter<QByteArray>::toCpp(pyObj);
}

inline PyObject* Converter<QByteArray>::toPython(const ::QByteArray& cppObj)
{
    return ValueTypeConverter<QByteArray>::toPython(cppObj);
}

}