summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qurl.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io/qurl.h')
-rw-r--r--src/corelib/io/qurl.h112
1 files changed, 51 insertions, 61 deletions
diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h
index 3646bf52fb..d6779cf485 100644
--- a/src/corelib/io/qurl.h
+++ b/src/corelib/io/qurl.h
@@ -1,51 +1,15 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// Copyright (C) 2016 Intel Corporation.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QURL_H
#define QURL_H
#include <QtCore/qbytearray.h>
+#include <QtCore/qcompare.h>
#include <QtCore/qobjectdefs.h>
#include <QtCore/qstring.h>
#include <QtCore/qlist.h>
-#include <QtCore/qpair.h>
#include <QtCore/qglobal.h>
#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
@@ -64,23 +28,28 @@ template <typename E1, typename E2>
class QUrlTwoFlags
{
int i;
- typedef int QUrlTwoFlags:: *Zero;
public:
+ constexpr inline QUrlTwoFlags() : i(0) {}
constexpr inline QUrlTwoFlags(E1 f) : i(f) {}
constexpr inline QUrlTwoFlags(E2 f) : i(f) {}
constexpr inline QUrlTwoFlags(QFlag f) : i(f) {}
constexpr inline QUrlTwoFlags(QFlags<E1> f) : i(f.operator typename QFlags<E1>::Int()) {}
constexpr inline QUrlTwoFlags(QFlags<E2> f) : i(f.operator typename QFlags<E2>::Int()) {}
- constexpr inline QUrlTwoFlags(Zero = 0) : i(0) {}
inline QUrlTwoFlags &operator&=(int mask) { i &= mask; return *this; }
inline QUrlTwoFlags &operator&=(uint mask) { i &= mask; return *this; }
+ inline QUrlTwoFlags &operator&=(QFlags<E1> mask) { i &= mask.toInt(); return *this; }
+ inline QUrlTwoFlags &operator&=(QFlags<E2> mask) { i &= mask.toInt(); return *this; }
inline QUrlTwoFlags &operator|=(QUrlTwoFlags f) { i |= f.i; return *this; }
inline QUrlTwoFlags &operator|=(E1 f) { i |= f; return *this; }
inline QUrlTwoFlags &operator|=(E2 f) { i |= f; return *this; }
+ inline QUrlTwoFlags &operator|=(QFlags<E1> mask) { i |= mask.toInt(); return *this; }
+ inline QUrlTwoFlags &operator|=(QFlags<E2> mask) { i |= mask.toInt(); return *this; }
inline QUrlTwoFlags &operator^=(QUrlTwoFlags f) { i ^= f.i; return *this; }
inline QUrlTwoFlags &operator^=(E1 f) { i ^= f; return *this; }
inline QUrlTwoFlags &operator^=(E2 f) { i ^= f; return *this; }
+ inline QUrlTwoFlags &operator^=(QFlags<E1> mask) { i ^= mask.toInt(); return *this; }
+ inline QUrlTwoFlags &operator^=(QFlags<E2> mask) { i ^= mask.toInt(); return *this; }
constexpr inline operator QFlags<E1>() const { return QFlag(i); }
constexpr inline operator QFlags<E2>() const { return QFlag(i); }
@@ -131,7 +100,7 @@ public:
};
// encoding / toString values
- enum UrlFormattingOption {
+ enum UrlFormattingOption : unsigned int {
None = 0x0,
RemoveScheme = 0x1,
RemovePassword = 0x2,
@@ -148,7 +117,7 @@ public:
NormalizePathSegments = 0x1000
};
- enum ComponentFormattingOption {
+ enum ComponentFormattingOption : unsigned int {
PrettyDecoded = 0x000000,
EncodeSpaces = 0x100000,
EncodeUnicode = 0x200000,
@@ -164,7 +133,7 @@ public:
#ifdef Q_QDOC
private:
// We need to let qdoc think that FormattingOptions is a normal QFlags, but
- // it needs to be a QUrlTwoFlags for compiling default arguments of somme functions.
+ // it needs to be a QUrlTwoFlags for compiling default arguments of some functions.
template<typename T> struct QFlags : QUrlTwoFlags<T, ComponentFormattingOption>
{ using QUrlTwoFlags<T, ComponentFormattingOption>::QUrlTwoFlags; };
public:
@@ -174,8 +143,8 @@ public:
#endif
QUrl();
- QUrl(const QUrl &copy);
- QUrl &operator =(const QUrl &copy);
+ QUrl(const QUrl &copy) noexcept;
+ QUrl &operator =(const QUrl &copy) noexcept;
#ifdef QT_NO_URL_CAST_FROM_STRING
explicit QUrl(const QString &url, ParsingMode mode = TolerantMode);
#else
@@ -184,20 +153,22 @@ public:
#endif
QUrl(QUrl &&other) noexcept : d(other.d)
{ other.d = nullptr; }
- inline QUrl &operator=(QUrl &&other) noexcept
- { qSwap(d, other.d); return *this; }
+ QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QUrl)
~QUrl();
- inline void swap(QUrl &other) noexcept { qSwap(d, other.d); }
+ void swap(QUrl &other) noexcept { qt_ptr_swap(d, other.d); }
void setUrl(const QString &url, ParsingMode mode = TolerantMode);
QString url(FormattingOptions options = FormattingOptions(PrettyDecoded)) const;
QString toString(FormattingOptions options = FormattingOptions(PrettyDecoded)) const;
QString toDisplayString(FormattingOptions options = FormattingOptions(PrettyDecoded)) const;
- Q_REQUIRED_RESULT QUrl adjusted(FormattingOptions options) const;
+ [[nodiscard]] QUrl adjusted(FormattingOptions options) const;
QByteArray toEncoded(FormattingOptions options = FullyEncoded) const;
+#if QT_CORE_REMOVED_SINCE(6, 7)
static QUrl fromEncoded(const QByteArray &url, ParsingMode mode = TolerantMode);
+#endif
+ static QUrl fromEncoded(QByteArrayView input, ParsingMode mode = TolerantMode);
enum UserInputResolutionOption {
DefaultResolution,
@@ -248,7 +219,7 @@ public:
QString fragment(ComponentFormattingOptions options = PrettyDecoded) const;
void setFragment(const QString &fragment, ParsingMode mode = TolerantMode);
- Q_REQUIRED_RESULT QUrl resolved(const QUrl &relative) const;
+ [[nodiscard]] QUrl resolved(const QUrl &relative) const;
bool isRelative() const;
bool isParentOf(const QUrl &url) const;
@@ -260,9 +231,11 @@ public:
void detach();
bool isDetached() const;
+#if QT_CORE_REMOVED_SINCE(6, 8)
bool operator <(const QUrl &url) const;
bool operator ==(const QUrl &url) const;
bool operator !=(const QUrl &url) const;
+#endif
bool matches(const QUrl &url, FormattingOptions options) const;
@@ -277,8 +250,19 @@ public:
NSURL *toNSURL() const Q_DECL_NS_RETURNS_AUTORELEASED;
#endif
+ enum AceProcessingOption : unsigned int {
+ IgnoreIDNWhitelist = 0x1,
+ AceTransitionalProcessing = 0x2,
+ };
+ Q_DECLARE_FLAGS(AceProcessingOptions, AceProcessingOption)
+
+#if QT_CORE_REMOVED_SINCE(6, 3)
static QString fromAce(const QByteArray &);
static QByteArray toAce(const QString &);
+#endif
+ static QString fromAce(const QByteArray &domain, AceProcessingOptions options = {});
+ static QByteArray toAce(const QString &domain, AceProcessingOptions options = {});
+
static QStringList idnWhitelist();
static QStringList toStringList(const QList<QUrl> &uris, FormattingOptions options = FormattingOptions(PrettyDecoded));
static QList<QUrl> fromStringList(const QStringList &uris, ParsingMode mode = TolerantMode);
@@ -287,6 +271,11 @@ public:
friend Q_CORE_EXPORT size_t qHash(const QUrl &url, size_t seed) noexcept;
private:
+ friend Q_CORE_EXPORT bool comparesEqual(const QUrl &lhs, const QUrl &rhs);
+ friend Q_CORE_EXPORT Qt::weak_ordering
+ compareThreeWay(const QUrl &lhs, const QUrl &rhs);
+ Q_DECLARE_WEAKLY_ORDERED(QUrl)
+
QUrlPrivate *d;
friend class QUrlQuery;
@@ -298,6 +287,7 @@ public:
Q_DECLARE_SHARED(QUrl)
Q_DECLARE_OPERATORS_FOR_FLAGS(QUrl::ComponentFormattingOptions)
//Q_DECLARE_OPERATORS_FOR_FLAGS(QUrl::FormattingOptions)
+Q_DECLARE_OPERATORS_FOR_FLAGS(QUrl::AceProcessingOptions)
#ifndef Q_QDOC
constexpr inline QUrl::FormattingOptions operator|(QUrl::UrlFormattingOption f1, QUrl::UrlFormattingOption f2)
@@ -305,25 +295,25 @@ constexpr inline QUrl::FormattingOptions operator|(QUrl::UrlFormattingOption f1,
constexpr inline QUrl::FormattingOptions operator|(QUrl::UrlFormattingOption f1, QUrl::FormattingOptions f2)
{ return f2 | f1; }
constexpr inline QIncompatibleFlag operator|(QUrl::UrlFormattingOption f1, int f2)
-{ return QIncompatibleFlag(int(f1) | f2); }
+{ return QIncompatibleFlag(uint(f1) | f2); }
// add operators for OR'ing the two types of flags
inline QUrl::FormattingOptions &operator|=(QUrl::FormattingOptions &i, QUrl::ComponentFormattingOptions f)
-{ i |= QUrl::UrlFormattingOption(int(f)); return i; }
+{ i |= QUrl::UrlFormattingOption(f.toInt()); return i; }
constexpr inline QUrl::FormattingOptions operator|(QUrl::UrlFormattingOption i, QUrl::ComponentFormattingOption f)
-{ return i | QUrl::UrlFormattingOption(int(f)); }
+{ return i | QUrl::UrlFormattingOption(qToUnderlying(f)); }
constexpr inline QUrl::FormattingOptions operator|(QUrl::UrlFormattingOption i, QUrl::ComponentFormattingOptions f)
-{ return i | QUrl::UrlFormattingOption(int(f)); }
+{ return i | QUrl::UrlFormattingOption(f.toInt()); }
constexpr inline QUrl::FormattingOptions operator|(QUrl::ComponentFormattingOption f, QUrl::UrlFormattingOption i)
-{ return i | QUrl::UrlFormattingOption(int(f)); }
+{ return i | QUrl::UrlFormattingOption(qToUnderlying(f)); }
constexpr inline QUrl::FormattingOptions operator|(QUrl::ComponentFormattingOptions f, QUrl::UrlFormattingOption i)
-{ return i | QUrl::UrlFormattingOption(int(f)); }
+{ return i | QUrl::UrlFormattingOption(f.toInt()); }
constexpr inline QUrl::FormattingOptions operator|(QUrl::FormattingOptions i, QUrl::ComponentFormattingOptions f)
-{ return i | QUrl::UrlFormattingOption(int(f)); }
+{ return i | QUrl::UrlFormattingOption(f.toInt()); }
constexpr inline QUrl::FormattingOptions operator|(QUrl::ComponentFormattingOption f, QUrl::FormattingOptions i)
-{ return i | QUrl::UrlFormattingOption(int(f)); }
+{ return i | QUrl::UrlFormattingOption(qToUnderlying(f)); }
constexpr inline QUrl::FormattingOptions operator|(QUrl::ComponentFormattingOptions f, QUrl::FormattingOptions i)
-{ return i | QUrl::UrlFormattingOption(int(f)); }
+{ return i | QUrl::UrlFormattingOption(f.toInt()); }
//inline QUrl::UrlFormattingOption &operator=(const QUrl::UrlFormattingOption &i, QUrl::ComponentFormattingOptions f)
//{ i = int(f); f; }