19#include <private/qglobal_p.h>
20#include <private/qtcore-config_p.h>
22#if QT_CONFIG(sharedmemory) || QT_CONFIG(systemsemaphore)
26# include <private/qcore_unix_p.h>
31class QNativeIpcKeyPrivate
34 QNativeIpcKey::Type
type = {};
36 friend bool operator==(
const QNativeIpcKeyPrivate &lhs,
const QNativeIpcKeyPrivate &rhs)
38 return lhs.type == rhs.type;
42inline QNativeIpcKeyPrivate *QNativeIpcKey::d_func()
45 return reinterpret_cast<QNativeIpcKeyPrivate *
>(
d & ~1);
48inline const QNativeIpcKeyPrivate *QNativeIpcKey::d_func()
const
51 return reinterpret_cast<QNativeIpcKeyPrivate *
>(
d & ~1);
54namespace QtIpcCommon {
60static constexpr bool isIpcSupported(IpcType ipcType, QNativeIpcKey::Type
type)
63 case QNativeIpcKey::Type::SystemV:
66 case QNativeIpcKey::Type::PosixRealtime:
67 if (ipcType == IpcType::SharedMemory)
71 case QNativeIpcKey::Type::Windows:
79 if (ipcType == IpcType::SharedMemory)
84template <
auto Member1,
auto...
Members>
class IpcStorageVariant
86 template <
typename T,
typename C>
static C extractClass(T C::*);
87 template <
typename T,
typename C>
static T extractObject(T C::*);
90 static constexpr bool IsEnabled =
decltype(extractObject(
M))::Enabled;
92 static_assert(std::is_member_object_pointer_v<
decltype(Member1)>);
93 using StorageType =
decltype(extractClass(Member1));
97 template <
typename Lambda>
static auto
98 visit_internal(StorageType &
storage, QNativeIpcKey::Type keyType,
const Lambda &lambda)
100 if constexpr ((IsEnabled<Member1> || ... || IsEnabled<Members>)) {
101 if constexpr (IsEnabled<Member1>) {
102 using MemberType1 =
decltype(extractObject(Member1));
103 if (MemberType1::supports(keyType))
104 return lambda(&(
storage.*Member1));
106 if constexpr ((... || IsEnabled<Members>))
107 return IpcStorageVariant<Members...>::visit_internal(
storage, keyType, lambda);
115 template <
typename Lambda>
auto visit(QNativeIpcKey::Type keyType,
const Lambda &lambda)
117 return visit_internal(
d, keyType, lambda);
120 template <
typename Lambda>
static auto
121 staticVisit(QNativeIpcKey::Type keyType,
const Lambda &lambda)
123 if constexpr ((IsEnabled<Member1> || ... || IsEnabled<Members>)) {
124 if constexpr (IsEnabled<Member1>) {
125 using MemberType1 =
decltype(extractObject(Member1));
126 if (MemberType1::supports(keyType))
127 return lambda(
static_cast<MemberType1 *
>(
nullptr));
129 if constexpr ((... || IsEnabled<Members>))
130 return IpcStorageVariant<Members...>::staticVisit(keyType, lambda);
140legacyPlatformSafeKey(
const QString &
key, IpcType ipcType,
141 QNativeIpcKey::Type
type = QNativeIpcKey::legacyDefaultTypeForOs());
\macro QT_RESTRICTED_CAST_FROM_ASCII
Combined button and popup list for selecting options.
std::conditional_t< sizeof(Layout1)<=sizeof(Layout2), Layout1, Layout2 > Members
static int qt_safe_open(const char *pathname, int flags, mode_t mode=0777)
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
#define Q_AUTOTEST_EXPORT
#define QT_CONFIG(feature)