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// Qt-Security score:significant reason:default
5
6#ifndef QAPPLICATIONSTATIC_H
7#define QAPPLICATIONSTATIC_H
8
9#include <QtCore/QMutex>
10#include <QtCore/qcoreapplication.h>
11#include <QtCore/qglobalstatic.h>
12
13#include <new>
14
15#if 0
16#pragma qt_class(QApplicationStatic)
17#endif
18
19QT_BEGIN_NAMESPACE
20
21namespace QtGlobalStatic {
22template <typename QAS> struct ApplicationHolder
23{
24 using Type = typename QAS::QAS_Type;
26
27 Q_CONSTINIT static inline struct { alignas(Type) unsigned char data[sizeof(Type)]; } storage = {};
29 Q_CONSTINIT static inline QBasicMutex mutex {};
30
31 static constexpr bool MutexLockIsNoexcept = noexcept(mutex.lock());
32 static constexpr bool ConstructionIsNoexcept = noexcept(QAS::innerFunction(nullptr));
33
34 ApplicationHolder() = default;
37 {
39 // No mutex! Up to external code to ensure no race happens.
42 }
43 }
44
46 {
47 return std::launder(reinterpret_cast<PlainType *>(&storage));
48 }
49
50 // called from QGlobalStatic::instance()
52 {
54 return realPointer();
58 const auto *app = QCoreApplication::instance();
60 "The application static was used without a QCoreApplication instance");
63 }
64 return realPointer();
65 }
66
67 static void reset()
68 {
69 // we only synchronize using the mutex here, not the guard
73 }
74};
75} // namespace QtGlobalStatic
76
77#define Q_APPLICATION_STATIC(TYPE, NAME, ...)
78 namespace { struct Q_QAS_ ## NAME {
79 typedef TYPE QAS_Type;
80 static void innerFunction(void *pointer)
81 noexcept(noexcept(std::remove_cv_t<QAS_Type>(__VA_ARGS__)))
82 {
83 new (pointer) QAS_Type(__VA_ARGS__);
84 }
85 }; }
86 static QGlobalStatic<QtGlobalStatic::ApplicationHolder<Q_QAS_ ## NAME>> NAME;
87 /**/
88
89QT_END_NAMESPACE
90
91#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.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:177
Combined button and popup list for selecting options.
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