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

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