1// qvariant.sip generated by MetaSIP
2//
3// This file is part of the QtCore Python extension module.
4//
5// Copyright (c) 2021 Riverbank Computing Limited <info@riverbankcomputing.com>
6//
7// This file is part of PyQt5.
8//
9// This file may be used under the terms of the GNU General Public License
10// version 3.0 as published by the Free Software Foundation and appearing in
11// the file LICENSE included in the packaging of this file.  Please review the
12// following information to ensure the GNU General Public License version 3.0
13// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
14//
15// If you do not wish to use this file under the terms of the GPL version 3.0
16// then you may purchase a commercial license.  For more information contact
17// info@riverbankcomputing.com.
18//
19// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21
22
23class QVariant /AllowNone,TypeHint="Any",TypeHintValue="None"/
24{
25%TypeHeaderCode
26#include <qvariant.h>
27%End
28
29%ConvertToTypeCode
30if (sipIsErr == NULL)
31    // We can convert everything to a QVariant.
32    return 1;
33
34// If it is already a QVariant then just return it.
35if (Py_TYPE(sipPy) == sipTypeAsPyTypeObject(sipType_QVariant))
36{
37    *sipCppPtr = reinterpret_cast<QVariant *>(sipConvertToType(sipPy,
38            sipType_QVariant, sipTransferObj, SIP_NO_CONVERTORS, 0, sipIsErr));
39
40    return 0;
41}
42
43// Convert it to a QVariant.
44QVariant var = qpycore_PyObject_AsQVariant(sipPy, sipIsErr);
45
46if (*sipIsErr)
47    return 0;
48
49*sipCppPtr = new QVariant(var);
50
51return sipGetState(sipTransferObj);
52%End
53
54%ConvertFromTypeCode
55return qpycore_PyObject_FromQVariant(*sipCpp);
56%End
57
58public:
59    enum Type
60    {
61        Invalid,
62        Bool,
63        Int,
64        UInt,
65        LongLong,
66        ULongLong,
67        Double,
68        Char,
69        Map,
70        List,
71        String,
72        StringList,
73        ByteArray,
74        BitArray,
75        Date,
76        Time,
77        DateTime,
78        Url,
79        Locale,
80        Rect,
81        RectF,
82        Size,
83        SizeF,
84        Line,
85        LineF,
86        Point,
87        PointF,
88        RegExp,
89        Font,
90        Pixmap,
91        Brush,
92        Color,
93        Palette,
94        Icon,
95        Image,
96        Polygon,
97        Region,
98        Bitmap,
99        Cursor,
100        SizePolicy,
101        KeySequence,
102        Pen,
103        TextLength,
104        TextFormat,
105        Matrix,
106        Transform,
107        Hash,
108        Matrix4x4,
109        Vector2D,
110        Vector3D,
111        Vector4D,
112        Quaternion,
113        EasingCurve,
114        Uuid,
115        ModelIndex,
116        PolygonF,
117        RegularExpression,
118%If (Qt_5_5_0 -)
119        PersistentModelIndex,
120%End
121        UserType,
122    };
123
124    QVariant();
125    QVariant(QVariant::Type type /Constrained/);
126    QVariant(SIP_PYOBJECT obj);
127%MethodCode
128        int is_err = 0;
129        QVariant var = qpycore_PyObject_AsQVariant(a0, &is_err);
130
131        if (is_err)
132            sipCpp = 0;
133        else
134            sipCpp = new QVariant(var);
135%End
136
137    ~QVariant();
138    SIP_PYOBJECT value() const;
139%MethodCode
140        sipRes = qpycore_PyObject_FromQVariant(*sipCpp);
141%End
142
143    QVariant::Type type() const;
144    int userType() const;
145    const char *typeName() const;
146    bool canConvert(int targetTypeId) const;
147    bool convert(int targetTypeId);
148    bool isValid() const;
149    bool isNull() const;
150    void clear();
151    void load(QDataStream &ds) /ReleaseGIL/;
152    void save(QDataStream &ds) const /ReleaseGIL/;
153    static const char *typeToName(int typeId);
154    static QVariant::Type nameToType(const char *name);
155    bool operator==(const QVariant &v) const;
156    bool operator!=(const QVariant &v) const;
157    void swap(QVariant &other /Constrained/);
158%If (Qt_5_2_0 -)
159    bool operator<(const QVariant &v) const;
160%End
161%If (Qt_5_2_0 -)
162    bool operator<=(const QVariant &v) const;
163%End
164%If (Qt_5_2_0 -)
165    bool operator>(const QVariant &v) const;
166%End
167%If (Qt_5_2_0 -)
168    bool operator>=(const QVariant &v) const;
169%End
170};
171
172typedef QList<QVariant> QVariantList /TypeHint="List[QVariant]"/;
173typedef QHash<QString, QVariant> QVariantHash /TypeHint="Dict[QString, QVariant]"/;
174QDataStream &operator>>(QDataStream &s, QVariant &p /Constrained/) /ReleaseGIL/;
175QDataStream &operator<<(QDataStream &s, const QVariant &p /Constrained/) /ReleaseGIL/;
176QDataStream &operator>>(QDataStream &s, QVariant::Type &p /Constrained,In/) /ReleaseGIL/;
177QDataStream &operator<<(QDataStream &s, const QVariant::Type p /Constrained/) /ReleaseGIL/;
178