Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qtools_p.h
Go to the documentation of this file.
1// Copyright (C) 2019 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
4#ifndef QTOOLS_P_H
5#define QTOOLS_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "QtCore/private/qglobal_p.h"
19
20#include <chrono>
21#include <limits.h>
22#include <time.h>
23
25
26namespace QtMiscUtils {
27constexpr inline char toHexUpper(char32_t value) noexcept
28{
29 return "0123456789ABCDEF"[value & 0xF];
30}
31
32constexpr inline char toHexLower(char32_t value) noexcept
33{
34 return "0123456789abcdef"[value & 0xF];
35}
36
37[[nodiscard]] constexpr inline bool isHexDigit(char32_t c) noexcept
38{
39 return (c >= '0' && c <= '9')
40 || (c >= 'A' && c <= 'F')
41 || (c >= 'a' && c <= 'f');
42}
43
44constexpr inline int fromHex(char32_t c) noexcept
45{
46 return ((c >= '0') && (c <= '9')) ? int(c - '0') :
47 ((c >= 'A') && (c <= 'F')) ? int(c - 'A' + 10) :
48 ((c >= 'a') && (c <= 'f')) ? int(c - 'a' + 10) :
49 /* otherwise */ -1;
50}
51
52constexpr inline char toOct(char32_t value) noexcept
53{
54 return char('0' + (value & 0x7));
55}
56
57[[nodiscard]] constexpr inline bool isOctalDigit(char32_t c) noexcept
58{
59 return c >= '0' && c <= '7';
60}
61
62constexpr inline int fromOct(char32_t c) noexcept
63{
64 return isOctalDigit(c) ? int(c - '0') : -1;
65}
66
67[[nodiscard]] constexpr inline bool isAsciiDigit(char32_t c) noexcept
68{
69 return c >= '0' && c <= '9';
70}
71
72constexpr inline bool isAsciiUpper(char32_t c) noexcept
73{
74 return c >= 'A' && c <= 'Z';
75}
76
77constexpr inline bool isAsciiLower(char32_t c) noexcept
78{
79 return c >= 'a' && c <= 'z';
80}
81
82constexpr inline bool isAsciiLetterOrNumber(char32_t c) noexcept
83{
84 return isAsciiDigit(c) || isAsciiLower(c) || isAsciiUpper(c);
85}
86
87constexpr inline char toAsciiLower(char ch) noexcept
88{
89 return isAsciiUpper(ch) ? ch - 'A' + 'a' : ch;
90}
91
92constexpr inline char toAsciiUpper(char ch) noexcept
93{
94 return isAsciiLower(ch) ? ch - 'a' + 'A' : ch;
95}
96
97constexpr inline int caseCompareAscii(char lhs, char rhs) noexcept
98{
99 const char lhsLower = QtMiscUtils::toAsciiLower(lhs);
100 const char rhsLower = QtMiscUtils::toAsciiLower(rhs);
101 return int(uchar(lhsLower)) - int(uchar(rhsLower));
102}
103
104constexpr inline int isAsciiPrintable(char32_t ch) noexcept
105{
106 return ch >= ' ' && ch < 0x7f;
107}
108
109constexpr inline int qt_lencmp(qsizetype lhs, qsizetype rhs) noexcept
110{
111 return lhs == rhs ? 0 :
112 lhs > rhs ? 1 :
113 /* else */ -1 ;
114}
115
116} // namespace QtMiscUtils
117
123
124// Implemented in qarraydata.cpp:
126qCalculateBlockSize(qsizetype elementCount, qsizetype elementSize, qsizetype headerSize = 0) noexcept;
128qCalculateGrowingBlockSize(qsizetype elementCount, qsizetype elementSize, qsizetype headerSize = 0) noexcept ;
129
131
132#endif // QTOOLS_P_H
Combined button and popup list for selecting options.
constexpr char toOct(char32_t value) noexcept
Definition qtools_p.h:52
constexpr bool isAsciiDigit(char32_t c) noexcept
Definition qtools_p.h:67
constexpr int fromOct(char32_t c) noexcept
Definition qtools_p.h:62
constexpr int caseCompareAscii(char lhs, char rhs) noexcept
Definition qtools_p.h:97
constexpr bool isAsciiLower(char32_t c) noexcept
Definition qtools_p.h:77
constexpr bool isAsciiLetterOrNumber(char32_t c) noexcept
Definition qtools_p.h:82
constexpr bool isAsciiUpper(char32_t c) noexcept
Definition qtools_p.h:72
constexpr int isAsciiPrintable(char32_t ch) noexcept
Definition qtools_p.h:104
constexpr char toHexUpper(char32_t value) noexcept
Definition qtools_p.h:27
constexpr int qt_lencmp(qsizetype lhs, qsizetype rhs) noexcept
Definition qtools_p.h:109
constexpr char toHexLower(char32_t value) noexcept
Definition qtools_p.h:32
constexpr bool isOctalDigit(char32_t c) noexcept
Definition qtools_p.h:57
constexpr bool isHexDigit(char32_t c) noexcept
Definition qtools_p.h:37
constexpr int fromHex(char32_t c) noexcept
Definition qtools_p.h:44
constexpr char toAsciiUpper(char ch) noexcept
Definition qtools_p.h:92
constexpr char toAsciiLower(char ch) noexcept
Definition qtools_p.h:87
#define Q_DECL_CONST_FUNCTION
static const qint64 headerSize
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
const GLubyte * c
CalculateGrowingBlockSizeResult Q_CORE_EXPORT Q_DECL_CONST_FUNCTION qCalculateGrowingBlockSize(qsizetype elementCount, qsizetype elementSize, qsizetype headerSize=0) noexcept
qsizetype Q_CORE_EXPORT Q_DECL_CONST_FUNCTION qCalculateBlockSize(qsizetype elementCount, qsizetype elementSize, qsizetype headerSize=0) noexcept
unsigned char uchar
Definition qtypes.h:32
ptrdiff_t qsizetype
Definition qtypes.h:165