Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qurlquery.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// Copyright (C) 2016 Intel Corporation.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QURLQUERY_H
6#define QURLQUERY_H
7
8#include <QtCore/qcompare.h>
9#include <QtCore/qshareddata.h>
10#include <QtCore/qurl.h>
11
12#include <initializer_list>
13
15
16Q_CORE_EXPORT size_t qHash(const QUrlQuery &key, size_t seed = 0) noexcept;
17
19class Q_CORE_EXPORT QUrlQuery
20{
21public:
22 QUrlQuery();
23 explicit QUrlQuery(const QUrl &url);
24 explicit QUrlQuery(const QString &queryString);
25 QUrlQuery(std::initializer_list<std::pair<QString, QString>> list)
26 : QUrlQuery()
27 {
28 for (const std::pair<QString, QString> &item : list)
29 addQueryItem(item.first, item.second);
30 }
31
33 QUrlQuery(QUrlQuery &&other) noexcept;
34 QUrlQuery &operator=(const QUrlQuery &other);
35 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QUrlQuery)
36 ~QUrlQuery();
37
38#if QT_CORE_REMOVED_SINCE(6, 8)
39 bool operator==(const QUrlQuery &other) const;
40 bool operator!=(const QUrlQuery &other) const
41 { return !operator==(other); }
42#endif
43
44 void swap(QUrlQuery &other) noexcept { d.swap(other.d); }
45
46 bool isEmpty() const;
47 bool isDetached() const;
48 void clear();
49
50 QString query(QUrl::ComponentFormattingOptions encoding = QUrl::PrettyDecoded) const;
51 void setQuery(const QString &queryString);
52 QString toString(QUrl::ComponentFormattingOptions encoding = QUrl::PrettyDecoded) const
53 { return query(encoding); }
54
55 void setQueryDelimiters(QChar valueDelimiter, QChar pairDelimiter);
56 QChar queryValueDelimiter() const;
57 QChar queryPairDelimiter() const;
58
59 void setQueryItems(const QList<std::pair<QString, QString> > &query);
60 QList<std::pair<QString, QString> > queryItems(QUrl::ComponentFormattingOptions encoding = QUrl::PrettyDecoded) const;
61
62 bool hasQueryItem(const QString &key) const;
63 void addQueryItem(const QString &key, const QString &value);
64 void removeQueryItem(const QString &key);
65 QString queryItemValue(const QString &key, QUrl::ComponentFormattingOptions encoding = QUrl::PrettyDecoded) const;
66 QStringList allQueryItemValues(const QString &key, QUrl::ComponentFormattingOptions encoding = QUrl::PrettyDecoded) const;
67 void removeAllQueryItems(const QString &key);
68
69 static constexpr char16_t defaultQueryValueDelimiter() noexcept { return u'='; }
70 static constexpr char16_t defaultQueryPairDelimiter() noexcept { return u'&'; }
71
72private:
73 friend Q_CORE_EXPORT bool comparesEqual(const QUrlQuery &lhs, const QUrlQuery &rhs);
75 friend class QUrl;
76 friend Q_CORE_EXPORT size_t qHash(const QUrlQuery &key, size_t seed) noexcept;
78
79public:
81 inline DataPtr &data_ptr() { return d; }
82};
83
84Q_DECLARE_SHARED(QUrlQuery)
85
87
88#endif // QURLQUERY_H
\inmodule QtCore
Definition qlist.h:75
\inmodule QtCore
Definition qshareddata.h:35
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurlquery.h:20
QString toString(QUrl::ComponentFormattingOptions encoding=QUrl::PrettyDecoded) const
Returns this QUrlQuery as a QString.
Definition qurlquery.h:52
void swap(QUrlQuery &other) noexcept
Swaps this URL query instance with other.
Definition qurlquery.h:44
static constexpr char16_t defaultQueryPairDelimiter() noexcept
Returns the default character for separating keys-value pairs from each other, an ampersand ("&").
Definition qurlquery.h:70
static constexpr char16_t defaultQueryValueDelimiter() noexcept
Returns the default character for separating keys from values in the query, an equal sign ("=").
Definition qurlquery.h:69
QUrlQuery(std::initializer_list< std::pair< QString, QString > > list)
Definition qurlquery.h:25
\inmodule QtCore
Definition qurl.h:94
@ PrettyDecoded
Definition qurl.h:121
b clear()
Combined button and popup list for selecting options.
#define Q_DECLARE_EQUALITY_COMPARABLE(...)
constexpr bool operator!=(const timespec &t1, const timespec &t2)
bool comparesEqual(const QDir &lhs, const QDir &rhs)
Definition qdir.cpp:1819
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLuint64 key
GLenum query
const void * data_ptr(const QTransform &t)
Definition qpainter_p.h:48
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1220
QT_BEGIN_NAMESPACE Q_CORE_EXPORT size_t qHash(const QUrlQuery &key, size_t seed=0) noexcept
QList< int > list
[14]
QUrl url("example.com")
[constructor-url-reference]
qDebug()<< QUrl("file copy setQuery(copy.query(QUrl::FullyDecoded), QUrl::DecodedMode)
QSharedPointer< T > other(t)
[5]
QGraphicsItem * item