| 1 | // Copyright (C) 2022 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 | // Qt-Security score:significant reason:default |
| 4 | |
| 5 | #ifndef QHTTP1CONFIGURATION_H |
| 6 | #define QHTTP1CONFIGURATION_H |
| 7 | |
| 8 | #include <QtNetwork/qtnetworkglobal.h> |
| 9 | |
| 10 | #include <QtCore/qtclasshelpermacros.h> |
| 11 | #include <QtCore/qtypes.h> |
| 12 | #include <QtCore/qtypeinfo.h> |
| 13 | |
| 14 | #include <utility> |
| 15 | #include <cstdint> |
| 16 | |
| 17 | QT_REQUIRE_CONFIG(http); |
| 18 | |
| 19 | QT_BEGIN_NAMESPACE |
| 20 | |
| 21 | class QHttp1ConfigurationPrivate; |
| 22 | class QHttp1Configuration |
| 23 | { |
| 24 | public: |
| 25 | Q_NETWORK_EXPORT QHttp1Configuration(); |
| 26 | Q_NETWORK_EXPORT QHttp1Configuration(const QHttp1Configuration &other); |
| 27 | QHttp1Configuration(QHttp1Configuration &&other) noexcept |
| 28 | : u{other.u} { other.u.d = nullptr; } |
| 29 | |
| 30 | Q_NETWORK_EXPORT QHttp1Configuration &operator=(const QHttp1Configuration &other); |
| 31 | QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QHttp1Configuration) |
| 32 | |
| 33 | Q_NETWORK_EXPORT ~QHttp1Configuration(); |
| 34 | |
| 35 | Q_NETWORK_EXPORT void setNumberOfConnectionsPerHost(qsizetype amount); |
| 36 | Q_NETWORK_EXPORT qsizetype numberOfConnectionsPerHost() const; |
| 37 | |
| 38 | void swap(QHttp1Configuration &other) noexcept |
| 39 | { std::swap(a&: u, b&: other.u); } |
| 40 | |
| 41 | private: |
| 42 | struct ShortData { |
| 43 | std::uint8_t numConnectionsPerHost; |
| 44 | char reserved[sizeof(void*) - sizeof(numConnectionsPerHost)]; |
| 45 | }; |
| 46 | union U { |
| 47 | U(ShortData _data) : data(_data) {} |
| 48 | QHttp1ConfigurationPrivate *d; |
| 49 | ShortData data; |
| 50 | } u; |
| 51 | |
| 52 | Q_NETWORK_EXPORT bool equals(const QHttp1Configuration &other) const noexcept; |
| 53 | Q_NETWORK_EXPORT size_t hash(size_t seed) const noexcept; |
| 54 | |
| 55 | friend bool operator==(const QHttp1Configuration &lhs, const QHttp1Configuration &rhs) noexcept |
| 56 | { return lhs.equals(other: rhs); } |
| 57 | friend bool operator!=(const QHttp1Configuration &lhs, const QHttp1Configuration &rhs) noexcept |
| 58 | { return !lhs.equals(other: rhs); } |
| 59 | |
| 60 | friend size_t qHash(const QHttp1Configuration &key, size_t seed = 0) noexcept { return key.hash(seed); } |
| 61 | }; |
| 62 | |
| 63 | Q_DECLARE_SHARED(QHttp1Configuration) |
| 64 | |
| 65 | QT_END_NAMESPACE |
| 66 | |
| 67 | #endif // QHTTP1CONFIGURATION_H |
| 68 |
