1// qurl.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
23// Template definition for QUrlTwoFlags.
24template<E1, E2>
25class QUrlTwoFlags /PyQtFlagsEnums="E1 E2"/
26{
27    // These are handled by the %ConvertToTypeCode.
28    //QUrlTwoFlags(E1);
29    //QUrlTwoFlags(E2);
30    QUrlTwoFlags();
31
32    QUrlTwoFlags &operator&=(int mask);
33    //QUrlTwoFlags &operator&=(uint mask);
34    QUrlTwoFlags &operator|=(QUrlTwoFlags f);
35    //QUrlTwoFlags &operator|=(E1 f);
36    //QUrlTwoFlags &operator|=(E2 f);
37    QUrlTwoFlags &operator^=(QUrlTwoFlags f);
38    //QUrlTwoFlags &operator^=(E1 f);
39    //QUrlTwoFlags &operator^=(E2 f);
40
41    operator int() const;
42
43    QUrlTwoFlags operator|(QUrlTwoFlags f) const;
44    //QUrlTwoFlags operator|(E1 f) const;
45    //QUrlTwoFlags operator|(E2 f) const;
46    QUrlTwoFlags operator^(QUrlTwoFlags f) const;
47    //QUrlTwoFlags operator^(E1 f) const;
48    //QUrlTwoFlags operator^(E2 f) const;
49    QUrlTwoFlags operator&(int mask) const;
50    //QUrlTwoFlags operator&(uint mask) const;
51    //QUrlTwoFlags operator&(E1 f) const;
52    //QUrlTwoFlags operator&(E2 f) const;
53    QUrlTwoFlags operator~() const;
54
55    // These are necessary to prevent Python comparing object IDs.
56    bool operator==(const QUrlTwoFlags &f) const;
57%MethodCode
58        sipRes = (sipCpp->operator int() == a0->operator int());
59%End
60
61    bool operator!=(const QUrlTwoFlags &f) const;
62%MethodCode
63        sipRes = (sipCpp->operator int() != a0->operator int());
64%End
65
66    int __bool__() const;
67%MethodCode
68        sipRes = (sipCpp->operator int() != 0);
69%End
70
71%ConvertToTypeCode
72// Allow an instance of the base enums whenever a QUrlTwoFlags is expected.
73
74if (sipIsErr == NULL)
75    return (PyObject_TypeCheck(sipPy, sipTypeAsPyTypeObject(sipType_E1)) ||
76            PyObject_TypeCheck(sipPy, sipTypeAsPyTypeObject(sipType_E2)) ||
77            sipCanConvertToType(sipPy, sipType_QUrlTwoFlags, SIP_NO_CONVERTORS));
78
79if (PyObject_TypeCheck(sipPy, sipTypeAsPyTypeObject(sipType_E1)) ||
80     PyObject_TypeCheck(sipPy, sipTypeAsPyTypeObject(sipType_E2)))
81{
82    *sipCppPtr = new QUrlTwoFlags(int(SIPLong_AsLong(sipPy)));
83
84    return sipGetState(sipTransferObj);
85}
86
87*sipCppPtr = reinterpret_cast<QUrlTwoFlags *>(sipConvertToType(sipPy, sipType_QUrlTwoFlags, sipTransferObj, SIP_NO_CONVERTORS, 0, sipIsErr));
88
89return 0;
90%End
91};
92
93class QUrl
94{
95%TypeHeaderCode
96#include <qurl.h>
97%End
98
99%TypeCode
100#include <QHash>
101%End
102
103public:
104    enum ParsingMode
105    {
106        TolerantMode,
107        StrictMode,
108        DecodedMode,
109    };
110
111    QUrl();
112    QUrl(const QString &url, QUrl::ParsingMode mode = QUrl::TolerantMode);
113    QUrl(const QUrl &copy);
114    ~QUrl();
115    long __hash__() const;
116%MethodCode
117        sipRes = qHash(*sipCpp);
118%End
119
120    SIP_PYOBJECT __repr__() const /TypeHint="str"/;
121%MethodCode
122        PyObject *uni = qpycore_PyObject_FromQString(sipCpp->toString());
123
124        if (uni)
125        {
126        #if PY_MAJOR_VERSION >= 3
127            sipRes = PyUnicode_FromFormat("PyQt5.QtCore.QUrl(%R)", uni);
128        #else
129            sipRes = PyString_FromFormat("PyQt5.QtCore.QUrl(");
130            PyString_ConcatAndDel(&sipRes, PyObject_Repr(uni));
131            PyString_ConcatAndDel(&sipRes, PyString_FromString(")"));
132        #endif
133
134            Py_DECREF(uni);
135        }
136%End
137
138    enum UrlFormattingOption
139    {
140        None /PyName=None_/,
141        RemoveScheme,
142        RemovePassword,
143        RemoveUserInfo,
144        RemovePort,
145        RemoveAuthority,
146        RemovePath,
147        RemoveQuery,
148        RemoveFragment,
149        PreferLocalFile,
150        StripTrailingSlash,
151%If (Qt_5_2_0 -)
152        RemoveFilename,
153%End
154%If (Qt_5_2_0 -)
155        NormalizePathSegments,
156%End
157    };
158
159    typedef QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> FormattingOptions;
160
161    enum ComponentFormattingOption
162    {
163        PrettyDecoded,
164        EncodeSpaces,
165        EncodeUnicode,
166        EncodeDelimiters,
167        EncodeReserved,
168        DecodeReserved,
169        FullyEncoded,
170        FullyDecoded,
171    };
172
173    typedef QFlags<QUrl::ComponentFormattingOption> ComponentFormattingOptions;
174    QString url(QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> options = QUrl::PrettyDecoded) const;
175    void setUrl(const QString &url, QUrl::ParsingMode mode = QUrl::TolerantMode);
176    bool isValid() const;
177    bool isEmpty() const;
178    void clear();
179    void setScheme(const QString &scheme);
180    QString scheme() const;
181    void setAuthority(const QString &authority, QUrl::ParsingMode mode = QUrl::TolerantMode);
182    QString authority(QUrl::ComponentFormattingOptions options = QUrl::PrettyDecoded) const;
183    void setUserInfo(const QString &userInfo, QUrl::ParsingMode mode = QUrl::TolerantMode);
184    QString userInfo(QUrl::ComponentFormattingOptions options = QUrl::PrettyDecoded) const;
185%If (Qt_5_2_0 -)
186    void setUserName(const QString &userName, QUrl::ParsingMode mode = QUrl::DecodedMode);
187%End
188%If (- Qt_5_2_0)
189    void setUserName(const QString &userName, QUrl::ParsingMode mode = QUrl::TolerantMode);
190%End
191%If (Qt_5_2_0 -)
192    QString userName(QUrl::ComponentFormattingOptions options = QUrl::FullyDecoded) const;
193%End
194%If (- Qt_5_2_0)
195    QString userName(QFlags<QUrl::ComponentFormattingOption> options = QUrl::PrettyDecoded) const;
196%End
197%If (Qt_5_2_0 -)
198    void setPassword(const QString &password, QUrl::ParsingMode mode = QUrl::DecodedMode);
199%End
200%If (- Qt_5_2_0)
201    void setPassword(const QString &password, QUrl::ParsingMode mode = QUrl::TolerantMode);
202%End
203%If (Qt_5_2_0 -)
204    QString password(QUrl::ComponentFormattingOptions options = QUrl::FullyDecoded) const;
205%End
206%If (- Qt_5_2_0)
207    QString password(QFlags<QUrl::ComponentFormattingOption> options = QUrl::PrettyDecoded) const;
208%End
209%If (Qt_5_2_0 -)
210    void setHost(const QString &host, QUrl::ParsingMode mode = QUrl::DecodedMode);
211%End
212%If (- Qt_5_2_0)
213    void setHost(const QString &host, QUrl::ParsingMode mode = QUrl::TolerantMode);
214%End
215%If (Qt_5_2_0 -)
216    QString host(QUrl::ComponentFormattingOptions = QUrl::FullyDecoded) const;
217%End
218%If (- Qt_5_2_0)
219    QString host(QFlags<QUrl::ComponentFormattingOption> options = QUrl::PrettyDecoded) const;
220%End
221    void setPort(int port);
222    int port(int defaultPort = -1) const;
223%If (Qt_5_2_0 -)
224    void setPath(const QString &path, QUrl::ParsingMode mode = QUrl::DecodedMode);
225%End
226%If (- Qt_5_2_0)
227    void setPath(const QString &path, QUrl::ParsingMode mode = QUrl::TolerantMode);
228%End
229%If (Qt_5_2_0 -)
230    QString path(QUrl::ComponentFormattingOptions options = QUrl::FullyDecoded) const;
231%End
232%If (- Qt_5_2_0)
233    QString path(QFlags<QUrl::ComponentFormattingOption> options = QUrl::PrettyDecoded) const;
234%End
235    void setFragment(const QString &fragment, QUrl::ParsingMode mode = QUrl::TolerantMode);
236    QString fragment(QUrl::ComponentFormattingOptions options = QUrl::PrettyDecoded) const;
237    QUrl resolved(const QUrl &relative) const;
238    bool isRelative() const;
239    bool isParentOf(const QUrl &url) const;
240    static QUrl fromLocalFile(const QString &localfile);
241    QString toLocalFile() const;
242    QString toString(QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> options = QUrl::PrettyDecoded) const;
243    QByteArray toEncoded(QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> options = QUrl::FullyEncoded) const;
244    static QUrl fromEncoded(const QByteArray &u, QUrl::ParsingMode mode = QUrl::TolerantMode);
245    void detach();
246    bool isDetached() const;
247    bool operator<(const QUrl &url) const;
248    bool operator==(const QUrl &url) const;
249    bool operator!=(const QUrl &url) const;
250    static QString fromPercentEncoding(const QByteArray &);
251    static QByteArray toPercentEncoding(const QString &input, const QByteArray &exclude = QByteArray(), const QByteArray &include = QByteArray());
252    bool hasQuery() const;
253    bool hasFragment() const;
254    QString errorString() const;
255    static QString fromAce(const QByteArray &);
256    static QByteArray toAce(const QString &);
257    static QStringList idnWhitelist();
258    static void setIdnWhitelist(const QStringList &);
259    static QUrl fromUserInput(const QString &userInput);
260    void swap(QUrl &other /Constrained/);
261%If (Qt_5_2_0 -)
262    QString topLevelDomain(QUrl::ComponentFormattingOptions options = QUrl::FullyDecoded) const;
263%End
264%If (- Qt_5_2_0)
265    QString topLevelDomain(QFlags<QUrl::ComponentFormattingOption> options = QUrl::PrettyDecoded) const;
266%End
267    bool isLocalFile() const;
268    QString toDisplayString(QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> options = QUrl::PrettyDecoded) const;
269    void setQuery(const QString &query, QUrl::ParsingMode mode = QUrl::TolerantMode);
270    void setQuery(const QUrlQuery &query);
271    QString query(QUrl::ComponentFormattingOptions options = QUrl::PrettyDecoded) const;
272%If (Qt_5_1_0 -)
273    static QStringList toStringList(const QList<QUrl> &uris, QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> options = QUrl::PrettyDecoded);
274%End
275%If (Qt_5_1_0 -)
276    static QList<QUrl> fromStringList(const QStringList &uris, QUrl::ParsingMode mode = QUrl::TolerantMode);
277%End
278%If (Qt_5_2_0 -)
279    QUrl adjusted(QUrl::FormattingOptions options) const;
280%End
281%If (Qt_5_2_0 -)
282    QString fileName(QUrl::ComponentFormattingOptions options = QUrl::FullyDecoded) const;
283%End
284%If (Qt_5_2_0 -)
285    bool matches(const QUrl &url, QUrl::FormattingOptions options) const;
286%End
287%If (Qt_5_4_0 -)
288
289    enum UserInputResolutionOption
290    {
291        DefaultResolution,
292        AssumeLocalFile,
293    };
294
295%End
296%If (Qt_5_4_0 -)
297    typedef QFlags<QUrl::UserInputResolutionOption> UserInputResolutionOptions;
298%End
299%If (Qt_5_4_0 -)
300    static QUrl fromUserInput(const QString &userInput, const QString &workingDirectory, QUrl::UserInputResolutionOptions options = QUrl::DefaultResolution);
301%End
302};
303
304QFlags<QUrl::ComponentFormattingOption> operator|(QUrl::ComponentFormattingOption f1, QFlags<QUrl::ComponentFormattingOption> f2);
305QDataStream &operator<<(QDataStream &, const QUrl & /Constrained/) /ReleaseGIL/;
306QDataStream &operator>>(QDataStream &, QUrl & /Constrained/) /ReleaseGIL/;
307QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> operator|(QUrl::UrlFormattingOption f1, QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> f2);
308QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> operator|(QUrl::ComponentFormattingOption f, QUrlTwoFlags<QUrl::UrlFormattingOption, QUrl::ComponentFormattingOption> i);
309