12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 | // 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 QURLQUERY_H#define QURLQUERY_H#include <QtCore/qcompare.h>#include <QtCore/qshareddata.h>#include <QtCore/qurl.h>#include <initializer_list> QT_BEGIN_NAMESPACE Q_CORE_EXPORT size_tqHash(const QUrlQuery &key,size_t seed =0) noexcept;class QUrlQueryPrivate;class Q_CORE_EXPORT QUrlQuery {public:QUrlQuery();explicitQUrlQuery(const QUrl &url);explicitQUrlQuery(const QString &queryString);QUrlQuery(std::initializer_list<std::pair<QString, QString>> list):QUrlQuery(){for(conststd::pair<QString, QString> &item : list)addQueryItem(item.first, item.second);}QUrlQuery(const QUrlQuery &other);QUrlQuery(QUrlQuery &&other) noexcept; QUrlQuery &operator=(const QUrlQuery &other);QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QUrlQuery)~QUrlQuery();#if QT_CORE_REMOVED_SINCE(6, 8)booloperator==(const QUrlQuery &other)const;booloperator!=(const QUrlQuery &other)const{return!operator==(other); }#endifvoidswap(QUrlQuery &other) noexcept { d.swap(other.d); }boolisEmpty()const;boolisDetached()const;voidclear(); QString query(QUrl::ComponentFormattingOptions encoding =QUrl::PrettyDecoded)const;voidsetQuery(const QString &queryString); QString toString(QUrl::ComponentFormattingOptions encoding =QUrl::PrettyDecoded)const{returnquery(encoding); }voidsetQueryDelimiters(QChar valueDelimiter, QChar pairDelimiter); QChar queryValueDelimiter()const; QChar queryPairDelimiter()const;voidsetQueryItems(const QList<std::pair<QString, QString> > &query); QList<std::pair<QString, QString> >queryItems(QUrl::ComponentFormattingOptions encoding =QUrl::PrettyDecoded)const;boolhasQueryItem(const QString &key)const;voidaddQueryItem(const QString &key,const QString &value);voidremoveQueryItem(const QString &key); QString queryItemValue(const QString &key,QUrl::ComponentFormattingOptions encoding =QUrl::PrettyDecoded)const; QStringList allQueryItemValues(const QString &key,QUrl::ComponentFormattingOptions encoding =QUrl::PrettyDecoded)const;voidremoveAllQueryItems(const QString &key);staticconstexpr char16_t defaultQueryValueDelimiter() noexcept {return u'='; }staticconstexpr char16_t defaultQueryPairDelimiter() noexcept {return u'&'; }private:friend Q_CORE_EXPORT boolcomparesEqual(const QUrlQuery &lhs,const QUrlQuery &rhs);Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QUrlQuery)friend class QUrl;friend Q_CORE_EXPORT size_tqHash(const QUrlQuery &key,size_t seed) noexcept; QSharedDataPointer<QUrlQueryPrivate> d;public:typedef QSharedDataPointer<QUrlQueryPrivate> DataPtr;inline DataPtr &data_ptr() {return d; }};Q_DECLARE_SHARED(QUrlQuery) QT_END_NAMESPACE #endif// QURLQUERY_H
|