Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qapplicationstatic.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// Copyright (C) 2021 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 QAPPLICATIONSTATIC_H
6#define QAPPLICATIONSTATIC_H
7
8#include <QtCore/QMutex>
9#include <QtCore/qcoreapplication.h>
10#include <QtCore/qglobalstatic.h>
11
12#include <new>
13
14#if 0
15#pragma qt_class(QApplicationStatic)
16#endif
17
18QT_BEGIN_NAMESPACE
19
20namespace QtGlobalStatic {
21template <typename QAS> struct ApplicationHolder
22{
23 using Type = typename QAS::QAS_Type;
25
26 Q_CONSTINIT static inline struct { alignas(Type) unsigned char data[sizeof(Type)]; } storage = {};
28 Q_CONSTINIT static inline QBasicMutex mutex {};
29
30 static constexpr bool MutexLockIsNoexcept = noexcept(mutex.lock());
31 static constexpr bool ConstructionIsNoexcept = noexcept(QAS::innerFunction(nullptr));
32
33 ApplicationHolder() = default;
36 {
38 // No mutex! Up to external code to ensure no race happens.
41 }
42 }
43
45 {
46 return std::launder(reinterpret_cast<PlainType *>(&storage));
47 }
48
49 // called from QGlobalStatic::instance()
51 {
53 return realPointer();
57 const auto *app = QCoreApplication::instance();
59 "The application static was used without a QCoreApplication instance");
62 }
63 return realPointer();
64 }
65
66 static void reset()
67 {
68 // we only synchronize using the mutex here, not the guard
72 }
73};
74} // namespace QtGlobalStatic
75
76#define Q_APPLICATION_STATIC(TYPE, NAME, ...)
77 namespace { struct Q_QAS_ ## NAME {
78 typedef TYPE QAS_Type;
79 static void innerFunction(void *pointer)
80 noexcept(noexcept(std::remove_cv_t<QAS_Type>(__VA_ARGS__)))
81 {
82 new (pointer) QAS_Type(__VA_ARGS__);
83 }
84 }; }
85 static QGlobalStatic<QtGlobalStatic::ApplicationHolder<Q_QAS_ ## NAME>> NAME;
86 /**/
87
88QT_END_NAMESPACE
89
90#endif // QAPPLICATIONSTATIC_H
The QDnsDomainNameRecord class stores information about a domain name record.
Definition qdnslookup.h:32
The QDnsHostAddressRecord class stores information about a host address record.
Definition qdnslookup.h:54
Q_OBJECT_BINDABLE_PROPERTY(QDnsLookupPrivate, QString, name, &QDnsLookupPrivate::nameChanged)
QDnsLookupRunnable * runnable
void nameserverProtocolChanged()
void nameserverPortChanged()
QDnsLookupReply reply
void setError(QDnsLookup::Error err, QString &&msg)
QList< QDnsMailExchangeRecord > mailExchangeRecords
void makeDnsRcodeError(quint8 rcode)
QList< QDnsServiceRecord > serviceRecords
void makeInvalidReplyError(QString &&msg=QString())
QList< QDnsDomainNameRecord > canonicalNameRecords
QList< QDnsDomainNameRecord > nameServerRecords
QList< QDnsDomainNameRecord > pointerRecords
QList< QDnsHostAddressRecord > hostAddressRecords
void makeResolverSystemError(int code=-1)
QList< QDnsTlsAssociationRecord > tlsAssociationRecords
QString errorString
void makeTimeoutError()
QList< QDnsTextRecord > textRecords
QDnsLookupRunnable(const QDnsLookupPrivate *d)
void run() override
Implement this pure virtual function in your subclass.
static constexpr qsizetype ReplyBufferSize
bool sendDnsOverTls(QDnsLookupReply *reply, QSpan< unsigned char > query, ReplyBuffer &response)
The QDnsLookup class represents a DNS lookup.
Definition qdnslookup.h:217
The QDnsMailExchangeRecord class stores information about a DNS MX record.
Definition qdnslookup.h:76
The QDnsServiceRecord class stores information about a DNS SRV record.
Definition qdnslookup.h:99
QList< QByteArray > values
The QDnsTextRecord class stores information about a DNS TXT record.
Definition qdnslookup.h:124
QDnsTlsAssociationRecord::CertificateUsage usage
QDnsTlsAssociationRecord::MatchingType matchType
QDnsTlsAssociationRecord::Selector selector
The QDnsTlsAssociationRecord class stores information about a DNS TLSA record.
Definition qdnslookup.h:146
void swap(QDnsTlsAssociationRecord &other) noexcept
Definition qdnslookup.h:200
QDnsTlsAssociationRecord(QDnsTlsAssociationRecord &&other) noexcept=default
Q_NETWORK_EXPORT ~QDnsTlsAssociationRecord()
Destroys this TLS Association record object.
QT_REQUIRE_CONFIG(animation)
#define Q_APPLICATION_STATIC(TYPE, NAME,...)
static void qt_qdnsmailexchangerecord_sort(QList< QDnsMailExchangeRecord > &records)
static void qt_qdnsservicerecord_sort(QList< QDnsServiceRecord > &records)
static bool qt_qdnsmailexchangerecord_less_than(const QDnsMailExchangeRecord &r1, const QDnsMailExchangeRecord &r2)
static bool qt_qdnsservicerecord_less_than(const QDnsServiceRecord &r1, const QDnsServiceRecord &r2)
static QDnsLookupRunnable::EncodedLabel encodeLabel(const QString &label)
QT_REQUIRE_CONFIG(dnslookup)
constexpr quint16 DnsPort
constexpr quint16 DnsOverTlsPort
QDebug operator<<(QDebug &, QDnsLookupRunnable *)
#define qCWarning(category,...)
#define Q_STATIC_LOGGING_CATEGORY(name,...)
static constexpr bool MutexLockIsNoexcept
static constexpr bool ConstructionIsNoexcept