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
qmath.h
Go to the documentation of this file.
1// Copyright (C) 2021 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 QMATH_H
5#define QMATH_H
6
7#if 0
8#pragma qt_class(QtMath)
9#endif
10
11#include <QtCore/qglobal.h>
12#include <QtCore/qalgorithms.h>
13#include <QtCore/qnumeric.h>
14
15#if __has_include(<bit>) && __cplusplus > 201703L
16#include <bit>
17#endif
18
19#include <cmath>
20
22
23#define QT_SINE_TABLE_SIZE 256
24
25extern Q_CORE_EXPORT const qreal qt_sine_table[QT_SINE_TABLE_SIZE];
26
27template <typename T> int qCeil(T v)
28{
29 using std::ceil;
30 return QtPrivate::qCheckedFPConversionToInteger<int>(ceil(v));
31}
32
33template <typename T> int qFloor(T v)
34{
35 using std::floor;
36 return QtPrivate::qCheckedFPConversionToInteger<int>(floor(v));
37}
38
39template <typename T> auto qFabs(T v)
40{
41 using std::fabs;
42 return fabs(v);
43}
44
45template <typename T> auto qSin(T v)
46{
47 using std::sin;
48 return sin(v);
49}
50
51template <typename T> auto qCos(T v)
52{
53 using std::cos;
54 return cos(v);
55}
56
57template <typename T> auto qTan(T v)
58{
59 using std::tan;
60 return tan(v);
61}
62
63template <typename T> auto qAcos(T v)
64{
65 using std::acos;
66 return acos(v);
67}
68
69template <typename T> auto qAsin(T v)
70{
71 using std::asin;
72 return asin(v);
73}
74
75template <typename T> auto qAtan(T v)
76{
77 using std::atan;
78 return atan(v);
79}
80
81template <typename T1, typename T2> auto qAtan2(T1 y, T2 x)
82{
83 using std::atan2;
84 return atan2(y, x);
85}
86
87template <typename T> auto qSqrt(T v)
88{
89 using std::sqrt;
90 return sqrt(v);
91}
92
93namespace QtPrivate {
94template <typename R, typename F> // For qfloat16 to specialize
95struct QHypotType { using type = decltype(std::hypot(R(1), F(1))); };
96
97// Implements hypot() without limiting number of arguments:
98template <typename T>
100{
101 T scale, total;
102 template <typename F> friend class QHypotHelper;
103 QHypotHelper(T first, T prior) : scale(first), total(prior) {}
104public:
105 QHypotHelper(T first) : scale(qAbs(first)), total(1) {}
106 T result() const
107 { return qIsFinite(scale) ? scale > 0 ? scale * T(qSqrt(total)) : T(0) : scale; }
108
109 template<typename F, typename ...Fs>
110 auto add(F first, Fs... rest) const
111 { return add(first).add(rest...); }
112
113 template<typename F, typename R = typename QHypotType<T, F>::type>
114 QHypotHelper<R> add(F next) const
115 {
116 if (qIsInf(scale) || (qIsNaN(scale) && !qIsInf(next)))
117 return QHypotHelper<R>(scale, R(1));
118 if (qIsNaN(next))
119 return QHypotHelper<R>(next, R(1));
120 const R val = qAbs(next);
121 if (!(scale > 0) || qIsInf(next))
122 return QHypotHelper<R>(val, R(1));
123 if (!(val > 0))
124 return QHypotHelper<R>(scale, total);
125 if (val > scale) {
126 const R ratio = scale / next;
127 return QHypotHelper<R>(val, total * ratio * ratio + R(1));
128 }
129 const R ratio = next / scale;
130 return QHypotHelper<R>(scale, total + ratio * ratio);
131 }
132};
133} // QtPrivate
134
135template<typename F, typename ...Fs>
136auto qHypot(F first, Fs... rest)
137{
138 return QtPrivate::QHypotHelper<F>(first).add(rest...).result();
139}
140
141// However, where possible, use the standard library implementations:
142template <typename Tx, typename Ty>
143auto qHypot(Tx x, Ty y)
144{
145 // C99 has hypot(), hence C++11 has std::hypot()
146 using std::hypot;
147 return hypot(x, y);
148}
149
150#if defined(__cpp_lib_hypot) && __cpp_lib_hypot >= 201603L // Expected to be true
151template <typename Tx, typename Ty, typename Tz>
152auto qHypot(Tx x, Ty y, Tz z)
153{
154 using std::hypot;
155 return hypot(x, y, z);
156}
157#endif // else: no need to over-ride the arbitrarily-many-arg form
158
159template <typename T> auto qLn(T v)
160{
161 using std::log;
162 return log(v);
163}
164
165template <typename T> auto qExp(T v)
166{
167 using std::exp;
168 return exp(v);
169}
170
171template <typename T1, typename T2> auto qPow(T1 x, T2 y)
172{
173 using std::pow;
174 return pow(x, y);
175}
176
177// TODO: use template variables (e.g. Qt::pi<type>) for these once we have C++14 support:
178
179#ifndef M_E
180#define M_E (2.7182818284590452354)
181#endif
182
183#ifndef M_LOG2E
184#define M_LOG2E (1.4426950408889634074)
185#endif
186
187#ifndef M_LOG10E
188#define M_LOG10E (0.43429448190325182765)
189#endif
190
191#ifndef M_LN2
192#define M_LN2 (0.69314718055994530942)
193#endif
194
195#ifndef M_LN10
196#define M_LN10 (2.30258509299404568402)
197#endif
198
199#ifndef M_PI
200#define M_PI (3.14159265358979323846)
201#endif
202
203#ifndef M_PI_2
204#define M_PI_2 (1.57079632679489661923)
205#endif
206
207#ifndef M_PI_4
208#define M_PI_4 (0.78539816339744830962)
209#endif
210
211#ifndef M_1_PI
212#define M_1_PI (0.31830988618379067154)
213#endif
214
215#ifndef M_2_PI
216#define M_2_PI (0.63661977236758134308)
217#endif
218
219#ifndef M_2_SQRTPI
220#define M_2_SQRTPI (1.12837916709551257390)
221#endif
222
223#ifndef M_SQRT2
224#define M_SQRT2 (1.41421356237309504880)
225#endif
226
227#ifndef M_SQRT1_2
228#define M_SQRT1_2 (0.70710678118654752440)
229#endif
230
231inline qreal qFastSin(qreal x)
232{
233 int si = int(x * (0.5 * QT_SINE_TABLE_SIZE / M_PI)); // Would be more accurate with qRound, but slower.
234 qreal d = x - si * (2.0 * M_PI / QT_SINE_TABLE_SIZE);
235 int ci = si + QT_SINE_TABLE_SIZE / 4;
236 si &= QT_SINE_TABLE_SIZE - 1;
237 ci &= QT_SINE_TABLE_SIZE - 1;
238 return qt_sine_table[si] + (qt_sine_table[ci] - 0.5 * qt_sine_table[si] * d) * d;
239}
240
241inline qreal qFastCos(qreal x)
242{
243 int ci = int(x * (0.5 * QT_SINE_TABLE_SIZE / M_PI)); // Would be more accurate with qRound, but slower.
244 qreal d = x - ci * (2.0 * M_PI / QT_SINE_TABLE_SIZE);
245 int si = ci + QT_SINE_TABLE_SIZE / 4;
246 si &= QT_SINE_TABLE_SIZE - 1;
247 ci &= QT_SINE_TABLE_SIZE - 1;
248 return qt_sine_table[si] - (qt_sine_table[ci] + 0.5 * qt_sine_table[si] * d) * d;
249}
250
251constexpr inline float qDegreesToRadians(float degrees)
252{
253 return degrees * float(M_PI / 180);
254}
255
256constexpr inline double qDegreesToRadians(double degrees)
257{
258 return degrees * (M_PI / 180);
259}
260
261constexpr inline long double qDegreesToRadians(long double degrees)
262{
263 return degrees * (M_PI / 180);
264}
265
266template <typename T, std::enable_if_t<std::is_integral_v<T>, bool> = true>
267constexpr inline double qDegreesToRadians(T degrees)
268{
269 return qDegreesToRadians(static_cast<double>(degrees));
270}
271
272constexpr inline float qRadiansToDegrees(float radians)
273{
274 return radians * float(180 / M_PI);
275}
276
277constexpr inline double qRadiansToDegrees(double radians)
278{
279 return radians * (180 / M_PI);
280}
281
282constexpr inline long double qRadiansToDegrees(long double radians)
283{
284 return radians * (180 / M_PI);
285}
286
287// A qRadiansToDegrees(Integral) overload isn't here; it's extremely
288// questionable that someone is manipulating quantities in radians
289// using integral datatypes...
290
291namespace QtPrivate {
292constexpr inline quint32 qConstexprNextPowerOfTwo(quint32 v)
293{
294 v |= v >> 1;
295 v |= v >> 2;
296 v |= v >> 4;
297 v |= v >> 8;
298 v |= v >> 16;
299 ++v;
300 return v;
301}
302
303constexpr inline quint64 qConstexprNextPowerOfTwo(quint64 v)
304{
305 v |= v >> 1;
306 v |= v >> 2;
307 v |= v >> 4;
308 v |= v >> 8;
309 v |= v >> 16;
310 v |= v >> 32;
311 ++v;
312 return v;
313}
314
315constexpr inline quint32 qConstexprNextPowerOfTwo(qint32 v)
316{
317 return qConstexprNextPowerOfTwo(quint32(v));
318}
319
320constexpr inline quint64 qConstexprNextPowerOfTwo(qint64 v)
321{
322 return qConstexprNextPowerOfTwo(quint64(v));
323}
324} // namespace QtPrivate
325
326constexpr inline quint32 qNextPowerOfTwo(quint32 v)
327{
328 Q_ASSERT(static_cast<qint32>(v) >= 0); // There is a next power of two
329#if defined(__cpp_lib_int_pow2) && __cpp_lib_int_pow2 >= 202002L
330 return std::bit_ceil(v + 1);
331#elif defined(QT_HAS_BUILTIN_CLZ)
332 if (v == 0)
333 return 1;
334 return 2U << (31 ^ QAlgorithmsPrivate::qt_builtin_clz(v));
335#else
336 return QtPrivate::qConstexprNextPowerOfTwo(v);
337#endif
338}
339
340constexpr inline quint64 qNextPowerOfTwo(quint64 v)
341{
342 Q_ASSERT(static_cast<qint64>(v) >= 0); // There is a next power of two
343#if defined(__cpp_lib_int_pow2) && __cpp_lib_int_pow2 >= 202002L
344 return std::bit_ceil(v + 1);
345#elif defined(QT_HAS_BUILTIN_CLZLL)
346 if (v == 0)
347 return 1;
348 return Q_UINT64_C(2) << (63 ^ QAlgorithmsPrivate::qt_builtin_clzll(v));
349#else
350 return QtPrivate::qConstexprNextPowerOfTwo(v);
351#endif
352}
353
354constexpr inline quint32 qNextPowerOfTwo(qint32 v)
355{
356 return qNextPowerOfTwo(quint32(v));
357}
358
359constexpr inline quint64 qNextPowerOfTwo(qint64 v)
360{
361 return qNextPowerOfTwo(quint64(v));
362}
363
364constexpr inline unsigned long qNextPowerOfTwo(unsigned long v)
365{
366 return qNextPowerOfTwo(QIntegerForSizeof<long>::Unsigned(v));
367}
368
369constexpr inline unsigned long qNextPowerOfTwo(long v)
370{
371 return qNextPowerOfTwo(QIntegerForSizeof<long>::Unsigned(v));
372}
373
374QT_END_NAMESPACE
375
376#endif // QMATH_H
\inmodule QtCore
QDataStream & operator>>(QDataStream &in, QByteArray &ba)
Reads a byte array into ba from the stream in and returns a reference to the stream.
quint16 qChecksum(QByteArrayView data, Qt::ChecksumType standard)
Definition qlist.h:80
static QLatin1StringView scriptToCode(QLocale::Script script)
Definition qlocale.cpp:254
QString toUpper(const QString &str, bool *ok) const
static const QLocalePrivate * get(const QLocale &l)
Definition qlocale_p.h:541
QString toLower(const QString &str, bool *ok) const
quint16 languageId() const
Definition qlocale_p.h:526
static QLocale::Language codeToLanguage(QStringView code, QLocale::LanguageCodeTypes codeTypes=QLocale::AnyLanguageCode) noexcept
Definition qlocale.cpp:109
const QLocaleData *const m_data
Definition qlocale_p.h:559
QLatin1StringView scriptCode() const
Definition qlocale_p.h:536
QLocale::MeasurementSystem measurementSystem() const
Definition qlocale.cpp:3556
quint16 territoryId() const
Definition qlocale_p.h:527
static QLatin1StringView territoryToCode(QLocale::Territory territory)
Definition qlocale.cpp:262
qsizetype m_index
Definition qlocale_p.h:561
static QLocale::Territory codeToTerritory(QStringView code) noexcept
Definition qlocale.cpp:210
static std::array< char, 4 > languageToCode(QLocale::Language language, QLocale::LanguageCodeTypes codeTypes=QLocale::AnyLanguageCode)
Definition qlocale.cpp:229
static QLocale::Script codeToScript(QStringView code) noexcept
Definition qlocale.cpp:204
QLocale::NumberOptions m_numberOptions
Definition qlocale_p.h:562
QLatin1StringView territoryCode() const
Definition qlocale_p.h:538
constexpr QLocalePrivate(const QLocaleData *data, qsizetype index, QLocale::NumberOptions numberOptions=QLocale::DefaultNumberOptions, int refs=0)
Definition qlocale_p.h:520
std::array< char, 4 > languageCode(QLocale::LanguageCodeTypes codeTypes=QLocale::AnyLanguageCode) const
Definition qlocale_p.h:532
static QBasicAtomicInt s_generation
Definition qlocale_p.h:564
QByteArray bcp47Name(char separator='-') const
Definition qlocale.cpp:489
QBasicAtomicInt ref
Definition qlocale_p.h:560
~QScopedArrayPointer()=default
const T & operator[](qsizetype i) const
T & operator[](qsizetype i)
friend bool operator==(std::nullptr_t, const QScopedPointer< T, Cleanup > &rhs) noexcept
bool operator!() const noexcept
T & operator*() const
friend bool operator==(const QScopedPointer< T, Cleanup > &lhs, std::nullptr_t) noexcept
T * operator->() const noexcept
bool isNull() const noexcept
T * get() const noexcept
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
friend bool operator!=(std::nullptr_t, const QScopedPointer< T, Cleanup > &rhs) noexcept
friend bool operator!=(const QScopedPointer< T, Cleanup > &lhs, std::nullptr_t) noexcept
T * data() const noexcept
friend bool operator!=(const QScopedPointer< T, Cleanup > &lhs, const QScopedPointer< T, Cleanup > &rhs) noexcept
friend bool operator==(const QScopedPointer< T, Cleanup > &lhs, const QScopedPointer< T, Cleanup > &rhs) noexcept
qsizetype fallbackLocaleIndex() const
Definition qlocale_p.h:568
@ StringToAlternateQuotation
Definition qlocale_p.h:162
@ DateTimeToStringShort
Definition qlocale_p.h:150
@ StandaloneMonthNameLong
Definition qlocale_p.h:168
@ ListToSeparatedString
Definition qlocale_p.h:164
@ StandaloneDayNameNarrow
Definition qlocale_p.h:173
@ StandaloneMonthNameNarrow
Definition qlocale_p.h:170
@ StringToStandardQuotation
Definition qlocale_p.h:161
@ StandaloneDayNameShort
Definition qlocale_p.h:172
@ StandaloneDayNameLong
Definition qlocale_p.h:171
@ StandaloneMonthNameShort
Definition qlocale_p.h:169
virtual QLocale fallbackLocale() const
virtual QVariant query(QueryType type, QVariant &&in=QVariant()) const
QHypotHelper< R > add(F next) const
Definition qmath.h:114
QHypotHelper(T first)
Definition qmath.h:105
auto add(F first, Fs... rest) const
Definition qmath.h:110
Combined button and popup list for selecting options.
qsizetype fromUtf8(uchar b, OutputPtr &dst, InputPtr &src, InputPtr end)
int toUtf8(char16_t u, OutputPtr &dst, InputPtr &src, InputPtr end)
bool isContinuationByte(uchar b)
constexpr char ascii_space_chars[]
Definition qlocale_p.h:71
constexpr auto makeCharacterSetMatch() noexcept
Definition qlocale_p.h:80
constexpr quint32 qConstexprNextPowerOfTwo(quint32 v)
Definition qmath.h:292
static constexpr bool isLowerCaseAscii(char c)
static const quint16 crc_tbl[16]
QByteArray qCompress(const uchar *data, qsizetype nbytes, int compressionLevel)
ZLibOp
@ Decompression
static Q_DECL_COLD_FUNCTION const char * zlibOpAsString(ZLibOp op)
static QByteArray toCase_template(T &input, uchar(*lookup)(uchar))
static void q_fromPercentEncoding(QByteArray *ba, char percent)
int qstrnicmp(const char *str1, qsizetype len1, const char *str2, qsizetype len2)
static qsizetype lastIndexOfHelper(const char *haystack, qsizetype l, const char *needle, qsizetype ol, qsizetype from)
static constexpr bool isUpperCaseAscii(char c)
static QByteArray xxflate(ZLibOp op, QArrayDataPointer< char > out, QByteArrayView input, qxp::function_ref< int(z_stream *) const > init, qxp::function_ref< int(z_stream *, size_t) const > processChunk, qxp::function_ref< void(z_stream *) const > deinit)
static constexpr uchar asciiLower(uchar c)
static qsizetype countCharHelper(QByteArrayView haystack, char needle) noexcept
static constexpr uchar asciiUpper(uchar c)
Q_CORE_EXPORT char * qstrncpy(char *dst, const char *src, size_t len)
Q_CORE_EXPORT int qstrnicmp(const char *, const char *, size_t len)
Q_CORE_EXPORT int qstricmp(const char *, const char *)
Q_CORE_EXPORT char * qstrdup(const char *)
Q_CORE_EXPORT char * qstrcpy(char *dst, const char *src)
Q_DECL_PURE_FUNCTION Q_CORE_EXPORT const void * qmemrchr(const void *s, int needle, size_t n) noexcept
Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2)
#define __has_include(x)
#define __has_feature(x)
auto qHypot(F first, Fs... rest)
Definition qmath.h:136
bool qt_splitLocaleName(QStringView name, QStringView *lang=nullptr, QStringView *script=nullptr, QStringView *cntry=nullptr) noexcept
Definition qlocale.cpp:649
Q_DECLARE_TYPEINFO(QLocaleData::GroupSizes, Q_PRIMITIVE_TYPE)
Q_DECLARE_TYPEINFO(QLocaleId, Q_PRIMITIVE_TYPE)
qsizetype qt_repeatCount(QStringView s) noexcept
Definition qlocale.cpp:762
constexpr bool ascii_isspace(uchar c) noexcept
Definition qlocale_p.h:587
#define ForEachQLocaleRange(X)
Definition qlocale_p.h:471
QString qt_readEscapedFormatString(QStringView format, qsizetype *idx)
Definition qlocale.cpp:712
StrayCharacterMode
@ TrailingJunkAllowed
@ TrailingJunkProhibited
@ WhitespacesAllowed
Q_CORE_EXPORT double qstrntod(const char *s00, qsizetype len, char const **se, bool *ok)
double qstrtod(const char *s00, char const **se, bool *ok)
QSimpleParsedNumber< double > qt_asciiToDouble(const char *num, qsizetype numLen, StrayCharacterMode strayCharMode=TrailingJunkProhibited)
QByteArray qdtoAscii(double d, QLocaleData::DoubleForm form, int precision, bool uppercase)
char * qulltoa2(char *p, qulonglong n, int base)
int wholePartSpace(double d)
QString qdtoBasicLatin(double d, QLocaleData::DoubleForm form, int precision, bool uppercase)
UcsInt unicodeForDigit(uint digit, UcsInt zero)
QString qulltoa(qulonglong l, int base, const QStringView zero)
QSimpleParsedNumber< qulonglong > qstrntoull(const char *nptr, qsizetype size, int base)
void qt_doubleToAscii(double d, QLocaleData::DoubleForm form, int precision, char *buf, qsizetype bufSize, bool &sign, int &length, int &decpt)
QString qulltoBasicLatin(qulonglong l, int base, bool negative)
#define M_1_PI
Definition qmath.h:212
#define M_LN10
Definition qmath.h:196
constexpr double qDegreesToRadians(double degrees)
Definition qmath.h:256
auto qHypot(Tx x, Ty y)
Definition qmath.h:143
#define QT_SINE_TABLE_SIZE
Definition qmath.h:23
qreal qFastSin(qreal x)
Definition qmath.h:231
constexpr long double qRadiansToDegrees(long double radians)
Definition qmath.h:282
constexpr unsigned long qNextPowerOfTwo(long v)
Definition qmath.h:369
qreal qFastCos(qreal x)
Definition qmath.h:241
auto qLn(T v)
Definition qmath.h:159
constexpr float qRadiansToDegrees(float radians)
Definition qmath.h:272
constexpr long double qDegreesToRadians(long double degrees)
Definition qmath.h:261
constexpr double qRadiansToDegrees(double radians)
Definition qmath.h:277
auto qAsin(T v)
Definition qmath.h:69
auto qAtan2(T1 y, T2 x)
Definition qmath.h:81
auto qAcos(T v)
Definition qmath.h:63
#define M_2_SQRTPI
Definition qmath.h:220
#define M_SQRT2
Definition qmath.h:224
auto qSqrt(T v)
Definition qmath.h:87
auto qFabs(T v)
Definition qmath.h:39
#define M_LN2
Definition qmath.h:192
#define M_PI_2
Definition qmath.h:204
#define M_2_PI
Definition qmath.h:216
#define M_E
Definition qmath.h:180
#define M_LOG10E
Definition qmath.h:188
constexpr unsigned long qNextPowerOfTwo(unsigned long v)
Definition qmath.h:364
auto qPow(T1 x, T2 y)
Definition qmath.h:171
int qFloor(T v)
Definition qmath.h:33
#define M_LOG2E
Definition qmath.h:184
#define M_SQRT1_2
Definition qmath.h:228
auto qCos(T v)
Definition qmath.h:51
constexpr quint32 qNextPowerOfTwo(quint32 v)
Definition qmath.h:326
int qCeil(T v)
Definition qmath.h:27
auto qAtan(T v)
Definition qmath.h:75
#define M_PI
Definition qmath.h:200
constexpr double qDegreesToRadians(T degrees)
Definition qmath.h:267
auto qSin(T v)
Definition qmath.h:45
#define M_PI_4
Definition qmath.h:208
constexpr float qDegreesToRadians(float degrees)
Definition qmath.h:251
auto qExp(T v)
Definition qmath.h:165
auto qTan(T v)
Definition qmath.h:57
QScopedPointerObjectDeleteLater< QObject > QScopedPointerDeleteLater
constexpr size_t qHash(const QSize &s, size_t seed=0) noexcept
Definition qsize.h:191
@ LittleEndianness
@ DetectEndianness
@ BigEndianness
CharBuff buff
Definition qlocale_p.h:239
static constexpr int MaxRange
Definition qlocale_p.h:49
constexpr bool matches(uchar c) const noexcept
Definition qlocale_p.h:61
constexpr QCharacterSetMatch(std::string_view set) noexcept
Definition qlocale_p.h:52
static char16_t * convertToUnicode(char16_t *dst, QLatin1StringView in) noexcept
Definition qstring.cpp:5720
static QChar * convertToUnicode(QChar *dst, QByteArrayView in, QStringConverter::State *state) noexcept
static char * convertFromUnicode(char *out, QStringView in, QStringConverter::State *state) noexcept
static QChar * convertToUnicode(QChar *buffer, QLatin1StringView in) noexcept
static Q_CORE_EXPORT char * convertFromUnicode(char *out, QStringView in) noexcept
Definition qstring.cpp:5727
QStringView viewListEntry(const char16_t *table, qsizetype index) const
Definition qlocale_p.h:429
char32_t ucsFirst(const char16_t *table) const
Definition qlocale_p.h:433
QString getData(const char16_t *table) const
Definition qlocale_p.h:415
QString getListEntry(const char16_t *table, qsizetype index) const
Definition qlocale_p.h:425
QStringView viewData(const char16_t *table) const
Definition qlocale_p.h:421
void setZero(QStringView zero)
Definition qlocale_p.h:355
bool isValid(NumberMode mode) const
Definition qlocale_p.h:375
QString positiveSign() const
Definition qlocale.cpp:1110
static float convertDoubleToFloat(double d, bool *ok)
Definition qlocale_p.h:319
QString groupSeparator() const
Definition qlocale.cpp:1069
QSimpleParsedNumber< qint64 > stringToLongLong(QStringView str, int base, QLocale::NumberOptions options) const
Definition qlocale.cpp:4831
char32_t zeroUcs() const
Definition qlocale.cpp:1089
quint8 m_grouping_least
Definition qlocale_p.h:512
QString zeroDigit() const
Definition qlocale.cpp:1084
bool numberToCLocale(QStringView s, QLocale::NumberOptions number_options, NumberMode mode, CharBuff *result) const
Definition qlocale.cpp:4609
quint8 m_grouping_higher
Definition qlocale_p.h:511
QString decimalPoint() const
Definition qlocale.cpp:1064
QString doubleToString(double d, int precision=-1, DoubleForm form=DFSignificantDigits, int width=-1, unsigned flags=NoFlags) const
Definition qlocale.cpp:4056
static Q_AUTOTEST_EXPORT bool allLocaleDataRows(bool(*check)(qsizetype, const QLocaleData &))
Definition qlocale.cpp:519
quint8 m_weekend_start
Definition qlocale_p.h:508
quint8 m_currency_digits
Definition qlocale_p.h:505
QLocaleId id() const
Definition qlocale_p.h:396
QString listSeparator() const
Definition qlocale.cpp:1079
static QSimpleParsedNumber< quint64 > bytearrayToUnsLongLong(QByteArrayView num, int base)
Definition qlocale.cpp:4878
QString percentSign() const
Definition qlocale.cpp:1074
@ BlankBeforePositive
Definition qlocale_p.h:264
@ AddTrailingZeroes
Definition qlocale_p.h:261
double stringToDouble(QStringView str, bool *ok, QLocale::NumberOptions options) const
Definition qlocale.cpp:4815
QString longLongToString(qint64 l, int precision=-1, int base=10, int width=-1, unsigned flags=NoFlags) const
Definition qlocale.cpp:4297
@ DoubleScientificMode
Definition qlocale_p.h:275
@ DoubleStandardMode
Definition qlocale_p.h:275
@ DFSignificantDigits
Definition qlocale_p.h:255
quint8 m_first_day_of_week
Definition qlocale_p.h:507
quint8 m_weekend_end
Definition qlocale_p.h:509
NumericData numericData(NumberMode mode) const
Definition qlocale.cpp:4382
quint8 m_currency_rounding
Definition qlocale_p.h:506
QString exponentSeparator() const
Definition qlocale.cpp:1115
static qsizetype findLocaleIndex(QLocaleId localeId) noexcept
Definition qlocale.cpp:579
QString negativeSign() const
Definition qlocale.cpp:1105
static const QLocaleData * c() noexcept
Definition qlocale.cpp:953
QSimpleParsedNumber< quint64 > stringToUnsLongLong(QStringView str, int base, QLocale::NumberOptions options) const
Definition qlocale.cpp:4842
QString unsLongLongToString(quint64 l, int precision=-1, int base=10, int width=-1, unsigned flags=NoFlags) const
Definition qlocale.cpp:4312
quint8 m_grouping_first
Definition qlocale_p.h:510
QLocaleId withLikelySubtagsAdded() const noexcept
Fill in blank fields of a locale ID.
Definition qlocale.cpp:321
QLocaleId withLikelySubtagsRemoved() const noexcept
Definition qlocale.cpp:410
ushort script_id
Definition qlocale_p.h:223
bool operator==(QLocaleId other) const noexcept
Definition qlocale_p.h:192
bool matchesAll() const noexcept
Definition qlocale_p.h:201
bool isValid() const noexcept
Definition qlocale_p.h:196
bool operator!=(QLocaleId other) const noexcept
Definition qlocale_p.h:194
bool acceptScriptTerritory(QLocaleId other) const noexcept
Definition qlocale_p.h:212
ushort territory_id
Definition qlocale_p.h:223
bool acceptLanguage(quint16 lang) const noexcept
Definition qlocale_p.h:206
QByteArray name(char separator='-') const
Definition qlocale.cpp:434
ushort language_id
Definition qlocale_p.h:223
static void cleanup(T *pointer) noexcept
void operator()(T *pointer) const noexcept
void operator()(T *pointer) const
static void cleanup(T *pointer)
void operator()(void *pointer) const noexcept
static void cleanup(void *pointer) noexcept
CurrencyToStringArgument(const QVariant &v, const QString &s)
Definition qlocale_p.h:119
static QChar * convertToUnicode(QChar *out, QByteArrayView, QStringConverter::State *state, DataEndianness endian)
static char * convertFromUnicode(char *out, QStringView in, QStringConverter::State *state, DataEndianness endian)
static char * convertFromUnicode(char *out, QStringView in, QStringConverter::State *state, DataEndianness endian)
static QChar * convertToUnicode(QChar *out, QByteArrayView, QStringConverter::State *state, DataEndianness endian)
static const bool skipAsciiHandling
static void appendByte(qchar8_t *&ptr, qchar8_t b)
static uchar peekByte(const uchar *ptr, qsizetype n=0)
static qptrdiff availableBytes(const qchar8_t *ptr, const qchar8_t *end)
static void appendByte(uchar *&ptr, uchar b)
static void advanceByte(const uchar *&ptr, qsizetype n=1)
static const bool isTrusted
static void appendUtf16(char32_t *&ptr, char16_t uc)
static const bool skipAsciiHandling
static char16_t peekUtf16(const char16_t *ptr, qsizetype n=0)
static const int Error
static void appendUcs4(char16_t *&ptr, char32_t uc)
static const int EndOfString
static void advanceUtf16(const char16_t *&ptr, qsizetype n=1)
static uchar peekByte(const char *ptr, qsizetype n=0)
static void advanceByte(const char *&ptr, qsizetype n=1)
static uchar peekByte(const qchar8_t *ptr, qsizetype n=0)
static void appendUtf16(char16_t *&ptr, char16_t uc)
static const bool allowNonCharacters
static qptrdiff availableUtf16(const char16_t *ptr, const char16_t *end)
static qptrdiff availableBytes(const char *ptr, const char *end)
static void appendUcs4(char32_t *&ptr, char32_t uc)
static qptrdiff availableBytes(const uchar *ptr, const uchar *end)
static void advanceByte(const qchar8_t *&ptr, qsizetype n=1)
static Q_CORE_EXPORT char16_t * convertToUnicode(char16_t *dst, QByteArrayView in) noexcept
static int compareUtf8(QByteArrayView utf8, QStringView utf16, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
static QChar * convertToUnicode(QChar *buffer, QByteArrayView in) noexcept
static ValidUtf8Result isValidUtf8(QByteArrayView in)
static QString convertToUnicode(QByteArrayView in)
static Q_CORE_EXPORT char * convertFromLatin1(char *out, QLatin1StringView in)
static char16_t * convertToUnicode(char16_t *dst, QByteArrayView in, QStringConverter::State *state)
static QChar * convertToUnicode(QChar *out, QByteArrayView in, QStringConverter::State *state)
static char * convertFromUnicode(char *out, QStringView in, QStringConverter::State *state)
static char * convertFromUnicode(char *dst, QStringView in) noexcept