12#if defined(Q_OS_DARWIN)
13# include "private/qcore_mac_p.h"
14# if !defined(SHM_NAME_MAX)
19# define SHM_NAME_MAX 30
23#if QT_CONFIG(sharedmemory) || QT_CONFIG(systemsemaphore)
32 case QNativeIpcKey::Type::SystemV:
34 case QNativeIpcKey::Type::PosixRealtime:
36 case QNativeIpcKey::Type::Windows:
42static QString typeToString(QNativeIpcKey::Type
type)
46 case QNativeIpcKey::Type::SystemV:
47 case QNativeIpcKey::Type::PosixRealtime:
48 case QNativeIpcKey::Type::Windows:
55 typeString = staticTypeToString(QNativeIpcKey::Type::SystemV);
62static QNativeIpcKey::Type stringToType(
QStringView typeString)
64 if (typeString == staticTypeToString(QNativeIpcKey::Type::PosixRealtime))
65 return QNativeIpcKey::Type::PosixRealtime;
66 if (typeString == staticTypeToString(QNativeIpcKey::Type::Windows))
67 return QNativeIpcKey::Type::Windows;
72 if (!
ok || n < low || n > high)
73 return QNativeIpcKey::Type{};
74 return QNativeIpcKey::Type(
n);
77 QStringView sysv = staticTypeToString(QNativeIpcKey::Type::SystemV);
79 if (typeString.
size() == sysv.
size())
80 return QNativeIpcKey::Type::SystemV;
81 return fromNumber(typeString.
sliced(sysv.
size()), 1, 0xff);
85 return QNativeIpcKey::Type{};
99QString QtIpcCommon::legacyPlatformSafeKey(
const QString &
key, QtIpcCommon::IpcType ipcType,
100 QNativeIpcKey::Type
type)
107 if (
type == QNativeIpcKey::Type::PosixRealtime) {
108#if defined(Q_OS_DARWIN)
125 result.reserve(1 + 18 +
key.size() + 40);
127 case IpcType::SharedMemory:
128 result +=
"qipc_sharedmemory_"_L1;
130 case IpcType::SystemSemaphore:
131 result +=
"qipc_systemsem_"_L1;
136 if ((
ch >= u
'a' &&
ch <= u
'z') ||
137 (
ch >= u
'A' &&
ch <= u
'Z'))
143 case QNativeIpcKey::Type::Windows:
144 if (!isIpcSupported(ipcType, QNativeIpcKey::Type::Windows))
147 case QNativeIpcKey::Type::PosixRealtime:
148 if (!isIpcSupported(ipcType, QNativeIpcKey::Type::PosixRealtime))
150 return result.prepend(u
'/');
151 case QNativeIpcKey::Type::SystemV:
154 if (!isIpcSupported(ipcType, QNativeIpcKey::Type::SystemV))
159QString QtIpcCommon::platformSafeKey(
const QString &
key, QtIpcCommon::IpcType ipcType,
160 QNativeIpcKey::Type
type)
166 case QNativeIpcKey::Type::PosixRealtime:
167 if (!isIpcSupported(ipcType, QNativeIpcKey::Type::PosixRealtime))
177 case QNativeIpcKey::Type::Windows:
178 if (isIpcSupported(ipcType, QNativeIpcKey::Type::Windows)) {
182 for (
QStringView candidate : { u
"Local\\", u
"Global\\" }) {
183 if (!
key.startsWith(candidate))
192 case IpcType::SharedMemory: mid = u
"shm_";
break;
193 case IpcType::SystemSemaphore: mid = u
"sem_";
break;
204 case QNativeIpcKey::Type::SystemV:
209 if (!isIpcSupported(ipcType, QNativeIpcKey::Type::SystemV))
211 if (
key.startsWith(u
'/'))
215 return baseDir + u
'/' +
key;
337#if defined(Q_OS_DARWIN)
338QNativeIpcKey::Type QNativeIpcKey::defaultTypeForOs_internal() noexcept
341 return Type::PosixRealtime;
342 return Type::SystemV;
362void QNativeIpcKey::copy_internal(
const QNativeIpcKey &
other)
364 auto copy =
new QNativeIpcKeyPrivate(*
other.d_func());
368void QNativeIpcKey::move_internal(QNativeIpcKey &&) noexcept
373QNativeIpcKey &QNativeIpcKey::assign_internal(
const QNativeIpcKey &
other)
375 QNativeIpcKeyPrivate *us = (
d & 1) ? d_func() :
nullptr;
376 const QNativeIpcKeyPrivate *them = (
other.d & 1) ?
other.d_func() :
nullptr;
380 typeAndFlags.type = us->type;
387 us =
new QNativeIpcKeyPrivate(*them);
398void QNativeIpcKey::destroy_internal() noexcept
447QNativeIpcKey::Type QNativeIpcKey::type_internal() const noexcept
449 Q_D(
const QNativeIpcKey);
460void QNativeIpcKey::setType_internal(
Type type)
481void QNativeIpcKey::setNativeKey_internal(
const QString &)
491int QNativeIpcKey::compare_internal(
const QNativeIpcKey &lhs,
const QNativeIpcKey &rhs)
noexcept
493 return *lhs.d_func() == *rhs.d_func() ? 0 : 1;
506QString QNativeIpcKey::toString()
const
515 copy.replace(u
'%',
"%25"_L1);
516 if (
copy.startsWith(
"//"_L1))
517 copy.replace(0, 2, u
"/%2F"_s);
535QNativeIpcKey QNativeIpcKey::fromString(
const QString &
text)
538 Type invalidType = {};
542 return QNativeIpcKey(invalidType);
546 return QNativeIpcKey(invalidType);
555#include "moc_qtipccommon.cpp"
QByteArray toHex(char separator='\0') const
Returns a hex encoded copy of the byte array.
static QByteArray hash(QByteArrayView data, Algorithm method)
Returns the hash of data using method.
constexpr QLatin1StringView left(qsizetype n) const
static QString writableLocation(StandardLocation type)
constexpr void truncate(qsizetype n) noexcept
Truncates this string view to length length.
bool startsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr qsizetype size() const noexcept
Returns the size of this string view, in UTF-16 code units (that is, surrogate pairs count as two for...
constexpr QStringView left(qsizetype n) const noexcept
constexpr QStringView sliced(qsizetype pos) const noexcept
const_pointer constData() const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isNull() const
Returns true if this string is null; otherwise returns false.
static QString fromRawData(const QChar *, qsizetype size)
Constructs a QString that uses the first size Unicode characters in the array unicode.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString userInfo(ComponentFormattingOptions options=PrettyDecoded) const
Returns the user info of the URL, or an empty string if the user info is undefined.
bool isValid() const
Returns true if the URL is non-empty and valid; otherwise returns false.
QString host(ComponentFormattingOptions=FullyDecoded) const
Returns the host of the URL if it is defined; otherwise an empty string is returned.
QString scheme() const
Returns the scheme of the URL.
void setScheme(const QString &scheme)
Sets the scheme of the URL to scheme.
int port(int defaultPort=-1) const
void setPath(const QString &path, ParsingMode mode=DecodedMode)
Sets the path of the URL to path.
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
QString path(ComponentFormattingOptions options=FullyDecoded) const
Returns the path of the URL.
Combined button and popup list for selecting options.
static jboolean copy(JNIEnv *, jobject)
bool qt_apple_isSandboxed()
EGLOutputLayerEXT EGLint EGLAttrib value
[5]