1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QHSTSPOLICY_H
5#define QHSTSPOLICY_H
6
7#include <QtNetwork/qtnetworkglobal.h>
8
9#include <QtCore/qshareddata.h>
10#include <QtCore/qflags.h>
11#include <QtCore/qurl.h>
12
13QT_BEGIN_NAMESPACE
14
15class QHstsPolicyPrivate;
16class QDateTime;
17class QString;
18class Q_NETWORK_EXPORT QHstsPolicy
19{
20public:
21 enum PolicyFlag
22 {
23 IncludeSubDomains = 1
24 };
25 Q_DECLARE_FLAGS(PolicyFlags, PolicyFlag)
26
27 QHstsPolicy();
28 QHstsPolicy(const QDateTime &expiry, PolicyFlags flags, const QString &host,
29 QUrl::ParsingMode mode = QUrl::DecodedMode);
30 QHstsPolicy(const QHstsPolicy &rhs);
31 QHstsPolicy &operator=(const QHstsPolicy &rhs);
32 QHstsPolicy &operator=(QHstsPolicy &&other) noexcept { swap(other); return *this; }
33 ~QHstsPolicy();
34
35 void swap(QHstsPolicy &other) noexcept { d.swap(other&: other.d); }
36
37 void setHost(const QString &host, QUrl::ParsingMode mode = QUrl::DecodedMode);
38 QString host(QUrl::ComponentFormattingOptions options = QUrl::FullyDecoded) const;
39 void setExpiry(const QDateTime &expiry);
40 QDateTime expiry() const;
41 void setIncludesSubDomains(bool include);
42 bool includesSubDomains() const;
43
44 bool isExpired() const;
45
46private:
47 QSharedDataPointer<QHstsPolicyPrivate> d;
48
49 bool isEqual(const QHstsPolicy &other) const;
50 friend bool operator==(const QHstsPolicy &lhs, const QHstsPolicy &rhs)
51 { return lhs.isEqual(other: rhs); }
52 friend bool operator!=(const QHstsPolicy &lhs, const QHstsPolicy &rhs)
53 { return !lhs.isEqual(other: rhs); }
54};
55
56Q_DECLARE_SHARED(QHstsPolicy)
57Q_DECLARE_OPERATORS_FOR_FLAGS(QHstsPolicy::PolicyFlags)
58
59
60
61QT_END_NAMESPACE
62
63#endif // QHSTSPOLICY_H
64

source code of qtbase/src/network/access/qhstspolicy.h