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
qhexstring_p.h
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
include
<
QtGui
/
private
/
qtguiglobal_p
.
h
>
6
#
include
<
QtCore
/
qpoint
.
h
>
7
#
include
<
QtCore
/
qstring
.
h
>
8
#
include
<
QtGui
/
qpolygon
.
h
>
9
#
include
<
QtCore
/
qstringbuilder
.
h
>
10
11
#
ifndef
QHEXSTRING_P_H
12
#
define
QHEXSTRING_P_H
13
14
//
15
// W A R N I N G
16
// -------------
17
//
18
// This file is not part of the Qt API. It exists purely as an
19
// implementation detail. This header file may change from version to
20
// version without notice, or even be removed.
21
//
22
// We mean it.
23
//
24
25
QT_BEGIN_NAMESPACE
26
27
// internal helper. Converts an integer value to a unique string token
28
template
<
typename
T>
29
struct
HexString
30
{
31
inline
HexString(
const
T t)
32
: val(t)
33
{}
34
35
inline
void
write(QChar *&dest)
const
36
{
37
const
char16_t
hexChars[] = {
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
};
38
const
char
*c =
reinterpret_cast
<
const
char
*>(&val);
39
for
(uint i = 0; i <
sizeof
(T); ++i) {
40
*dest++ = hexChars[*c & 0xf];
41
*dest++ = hexChars[(*c & 0xf0) >> 4];
42
++c;
43
}
44
}
45
const
T val;
46
};
47
48
// specialization to enable fast concatenating of our string tokens to a string
49
template
<
typename
T>
50
struct
QConcatenable
<
HexString
<
T
> >
51
{
52
typedef
HexString
<
T
>
type
;
53
enum
{
ExactSize
=
true
};
54
static
int
size
(
const
HexString<T> &) {
return
sizeof
(T) * 2; }
55
static
inline
void
appendTo
(
const
HexString<T> &str, QChar *&out) { str.write(out); }
56
typedef
QString
ConvertTo
;
57
};
58
59
QT_END_NAMESPACE
60
61
#
endif
// QHEXSTRING_P_H
QConcatenable< HexString< T > >::size
static int size(const HexString< T > &)
Definition
qhexstring_p.h:54
QConcatenable< HexString< T > >::type
HexString< T > type
Definition
qhexstring_p.h:52
QConcatenable< HexString< T > >::ConvertTo
QString ConvertTo
Definition
qhexstring_p.h:56
QConcatenable< HexString< T > >::ExactSize
@ ExactSize
Definition
qpaintengine_x11.cpp:312
QConcatenable< HexString< T > >::appendTo
static void appendTo(const HexString< T > &str, QChar *&out)
Definition
qhexstring_p.h:55
QConcatenable
Definition
qstringbuilder.h:35
qtbase
src
gui
util
qhexstring_p.h
Generated on
for Qt by
1.14.0