Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
quuid_p.h
Go to the documentation of this file.
1
// Copyright (C) 2020 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
QUUID_P_H
7
#
define
QUUID_P_H
8
9
//
10
// W A R N I N G
11
// -------------
12
//
13
// This file is not part of the Qt API. It exists for the convenience
14
// of the QLibrary class. This header file may change from
15
// version to version without notice, or even be removed.
16
//
17
// We mean it.
18
//
19
20
#
include
"quuid.h"
21
22
#
include
<
QtCore
/
qrandom
.
h
>
23
24
#
include
<
chrono
>
25
26
QT_BEGIN_NAMESPACE
27
28
#
ifndef
QT_BOOTSTRAPPED
29
static
inline
QUuid createUuidV7_internal(
30
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> tp)
31
{
32
QUuid result;
33
34
using
namespace
std::chrono;
35
const
nanoseconds nsecSinceEpoch = tp.time_since_epoch();
36
const
auto
msecSinceEpoch = floor<milliseconds>(nsecSinceEpoch);
37
const
quint64 frac = (nsecSinceEpoch - msecSinceEpoch).count();
38
// Lower 48 bits of the timestamp
39
const
quint64 msecs = quint64(msecSinceEpoch.count()) & 0xffffffffffff;
40
result.data1 = uint(msecs >> 16);
41
result.data2 = ushort(msecs);
42
// rand_a: use a 12-bit sub-millisecond timestamp for additional monotonicity
43
// https://datatracker.ietf.org/doc/html/rfc9562#monotonicity_counters (Method 3)
44
45
// "frac" is a number between 0 and 999,999, so the lowest 20 bits
46
// should be roughly random. Use the high 12 of those for additional
47
// monotonicity.
48
result.data3 = frac >> 8;
49
result.data3 &= 0x0FFF;
50
result.data3 |= ushort(7) << 12;
51
52
// rand_b: 62 bits of random data (64 - 2 bits for the variant)
53
const
quint64 random = QRandomGenerator::system()->generate64();
54
memcpy(result.data4, &random,
sizeof
(quint64));
55
result.data4[0] = (result.data4[0] & 0x3F) | 0x80;
// UV_DCE
56
return
result;
57
}
58
#
endif
59
60
QT_END_NAMESPACE
61
62
#
endif
// QUUID_P_H
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
operator>>
QDataStream & operator>>(QDataStream &s, QKeyCombination &combination)
Definition
qdatastream.h:699
operator<<
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
Definition
qfileinfo.cpp:1830
qHash
constexpr size_t qHash(const QSize &s, size_t seed=0) noexcept
Definition
qsize.h:192
_q_fromHex
bool _q_fromHex(const char *&src, Integral &value)
Definition
quuid.cpp:42
_q_uuidToHex
static char * _q_uuidToHex(const QUuid &uuid, char *dst, QUuid::StringFormat mode=QUuid::WithBraces)
Definition
quuid.cpp:58
_q_toHex
void _q_toHex(char *&dst, Integral value)
Definition
quuid.cpp:26
MaxStringUuidLength
@ MaxStringUuidLength
Definition
quuid.cpp:23
uuidFromString
static QUuid uuidFromString(QStringView text) noexcept
Definition
quuid.cpp:499
createFromName
static QUuid createFromName(QUuid ns, QByteArrayView baseData, QCryptographicHash::Algorithm algorithm, int version) noexcept
Definition
quuid.cpp:124
qtbase
src
corelib
plugin
quuid_p.h
Generated on
for Qt by
1.18.0