6#include <QtCore/qstring.h>
7#include <QtCore/qurl.h>
8#include <QtCore/qdatetime.h>
9#include <QtCore/quuid.h>
10#include <QtCore/qbytearray.h>
11#include <QtCore/qrect.h>
13#if QT_CONFIG(timezone) && !defined(QT_NO_SYSTEMLOCALE)
14#include <QtCore/qtimezone.h>
15#include <QtCore/private/qtimezoneprivate_p.h>
16#include <QtCore/private/qcore_mac_p.h>
19#import <CoreFoundation/CoreFoundation.h>
20#import <Foundation/Foundation.h>
22#if defined(QT_PLATFORM_UIKIT)
23#import <CoreGraphics/CoreGraphics.h>
41 return QByteArray(
reinterpret_cast<const char *
>(CFDataGetBytePtr(
data)), CFDataGetLength(
data));
75CFDataRef QByteArray::toCFData()
const
77 return CFDataCreate(kCFAllocatorDefault,
reinterpret_cast<const UInt8 *
>(
data()),
length());
93CFDataRef QByteArray::toRawCFData()
const
95 return CFDataCreateWithBytesNoCopy(kCFAllocatorDefault,
reinterpret_cast<const UInt8 *
>(
data()),
96 length(), kCFAllocatorNull);
144NSData *QByteArray::toNSData()
const
165 return [NSData dataWithBytesNoCopy:
const_cast<char *
>(
constData())
length:
size() freeWhenDone:NO];
178QString QString::fromCFString(CFStringRef
string)
182 CFIndex
length = CFStringGetLength(
string);
186 const UniChar *chars = CFStringGetCharactersPtr(
string);
191 CFStringGetCharacters(
string, CFRangeMake(0,
length),
reinterpret_cast<UniChar *
>(
ret.data()));
205CFStringRef QString::toCFString()
const
220CFStringRef QStringView::toCFString()
const
222 return CFStringCreateWithCharacters(0,
reinterpret_cast<const UniChar *
>(
data()),
size());
233QString QString::fromNSString(
const NSString *
string)
253NSString *QString::toNSString()
const
268NSString *QStringView::toNSString()
const
270 return [NSString stringWithCharacters:
reinterpret_cast<const UniChar*
>(
data())
length:
size()];
283QUuid QUuid::fromCFUUID(CFUUIDRef uuid)
287 const CFUUIDBytes bytes = CFUUIDGetUUIDBytes(uuid);
301CFUUIDRef QUuid::toCFUUID()
const
304 return CFUUIDCreateFromUUIDBytes(0, *
reinterpret_cast<const CFUUIDBytes *
>(bytes.
constData()));
315QUuid QUuid::fromNSUUID(
const NSUUID *uuid)
320 [uuid getUUIDBytes:bytes];
334NSUUID *QUuid::toNSUUID()
const
337 return [[[NSUUID alloc] initWithUUIDBytes:*
reinterpret_cast<const uuid_t *
>(bytes.
constData())] autorelease];
349QUrl QUrl::fromCFURL(CFURLRef
url)
353 return QUrl(QString::fromCFString(CFURLGetString(
url)));
364CFURLRef QUrl::toCFURL()
const
367 CFStringRef
str =
toString(FullyEncoded).toCFString();
369 url = CFURLCreateWithString(0,
str, 0);
381QUrl QUrl::fromNSURL(
const NSURL *
url)
385 return QUrl(QString::fromNSString([
url absoluteString]));
396NSURL *QUrl::toNSURL()
const
398 return [NSURL URLWithString:
toString(FullyEncoded).toNSString()];
416 CFAbsoluteTime sSinceEpoch = kCFAbsoluteTimeIntervalSince1970 + CFDateGetAbsoluteTime(
date);
430CFDateRef QDateTime::toCFDate()
const
432 return CFDateCreate(kCFAllocatorDefault, (
static_cast<CFAbsoluteTime
>(toMSecsSinceEpoch())
433 / 1000) - kCFAbsoluteTimeIntervalSince1970);
461NSDate *QDateTime::toNSDate()
const
464 dateWithTimeIntervalSince1970:
static_cast<NSTimeInterval
>(toMSecsSinceEpoch()) / 1000];
469#if QT_CONFIG(timezone) && !defined(QT_NO_SYSTEMLOCALE)
478QTimeZone QTimeZone::fromCFTimeZone(CFTimeZoneRef timeZone)
482 return QTimeZone(QString::fromCFString(CFTimeZoneGetName(timeZone)).toLatin1());
495CFTimeZoneRef QTimeZone::toCFTimeZone()
const
497#ifndef QT_NO_DYNAMIC_CAST
498 Q_ASSERT(
dynamic_cast<const QMacTimeZonePrivate *
>(d.
d));
500 const QMacTimeZonePrivate *
p =
static_cast<const QMacTimeZonePrivate *
>(d.
d);
501 return reinterpret_cast<CFTimeZoneRef
>([
p->nsTimeZone()
copy]);
512QTimeZone QTimeZone::fromNSTimeZone(
const NSTimeZone *timeZone)
516 return QTimeZone(QString::fromNSString(timeZone.name).toLatin1());
529NSTimeZone *QTimeZone::toNSTimeZone()
const
531 return [
static_cast<NSTimeZone *
>(toCFTimeZone()) autorelease];
545CGRect QRect::toCGRect() const noexcept
558CGRect QRectF::toCGRect() const noexcept
571QRectF QRectF::fromCGRect(CGRect
rect)
noexcept
586CGPoint QPoint::toCGPoint() const noexcept
588 return CGPointMake(
x(),
y());
599CGPoint QPointF::toCGPoint() const noexcept
601 return CGPointMake(
x(),
y());
612QPointF QPointF::fromCGPoint(CGPoint point)
noexcept
614 return QPointF(point.x, point.y);
627CGSize QSize::toCGSize() const noexcept
640CGSize QSizeF::toCGSize() const noexcept
653QSizeF QSizeF::fromCGSize(CGSize
size)
noexcept
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
qsizetype length() const noexcept
Same as size().
constexpr QByteArray() noexcept
Constructs an empty byte array.
static QByteArray fromRawData(const char *data, qsizetype size)
Constructs a QByteArray that uses the first size bytes of the data array.
\inmodule QtCore\reentrant
static QDateTime fromMSecsSinceEpoch(qint64 msecs, const QTimeZone &timeZone)
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QUuid fromRfc4122(QByteArrayView) noexcept
Creates a QUuid object from the binary representation of the UUID, as specified by RFC 4122 section 4...
Combined button and popup list for selecting options.
constexpr Initialization Uninitialized
static jboolean copy(JNIEnv *, jobject)
qint64 qRound64(qfloat16 d) noexcept
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei length
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei const GLchar *const * string
[0]
QUrl url("example.com")
[constructor-url-reference]
char * toString(const MyType &t)
[31]