Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qlocale_tools.cpp File Reference
#include "qlocale_tools_p.h"
#include "qdoublescanprint_p.h"
#include "qlocale_p.h"
#include "qstring.h"
#include <private/qtools_p.h>
#include <private/qnumeric_p.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <limits>
#include <charconv>
+ Include dependency graph for qlocale_tools.cpp:

Go to the source code of this file.

Macros

#define LLONG_MAX   Q_INT64_C(0x7fffffffffffffff)
 
#define LLONG_MIN   (-LLONG_MAX - Q_INT64_C(1))
 
#define ULLONG_MAX   Q_UINT64_C(0xffffffffffffffff)
 
#define BIG_BASE_LOOP(b)
 
#define SMALL_BASE_LOOP(b)
 

Functions

QT_CLOCALE_HOLDER void qt_doubleToAscii (double d, QLocaleData::DoubleForm form, int precision, char *buf, qsizetype bufSize, bool &sign, int &length, int &decpt)
 
QSimpleParsedNumber< double > qt_asciiToDouble (const char *num, qsizetype numLen, StrayCharacterMode strayCharMode)
 
static auto scanPrefix (const char *p, const char *stop, int base)
 
static bool isDigitForBase (char d, int base)
 
QSimpleParsedNumber< qulonglongqstrntoull (const char *begin, qsizetype size, int base)
 
QSimpleParsedNumber< qlonglongqstrntoll (const char *begin, qsizetype size, int base)
 
template<typename Char >
static Q_ALWAYS_INLINE void qulltoString_helper (qulonglong number, int base, Char *&p)
 
QString qulltoBasicLatin (qulonglong number, int base, bool negative)
 
QString qulltoa (qulonglong number, int base, const QStringView zero)
 
double qstrntod (const char *s00, qsizetype len, const char **se, bool *ok)
 
QString qdtoa (qreal d, int *decpt, int *sign)
 
static QLocaleData::DoubleForm resolveFormat (int precision, int decpt, qsizetype length)
 
static constexpr int digits (int number)
 
template<typename T >
static T dtoString (double d, QLocaleData::DoubleForm form, int precision, bool uppercase)
 
QString qdtoBasicLatin (double d, QLocaleData::DoubleForm form, int precision, bool uppercase)
 
QByteArray qdtoAscii (double d, QLocaleData::DoubleForm form, int precision, bool uppercase)
 

Macro Definition Documentation

◆ BIG_BASE_LOOP

#define BIG_BASE_LOOP (   b)
Value:
do { \
const int r = number % b; \
*--p = Char((r < 10 ? '0' : 'a' - 10) + r); \
number /= b; \
} while (number)
GLboolean GLboolean GLboolean b
GLboolean r
[2]
GLfloat GLfloat p
[1]
char Char

◆ LLONG_MAX

#define LLONG_MAX   Q_INT64_C(0x7fffffffffffffff)

Definition at line 30 of file qlocale_tools.cpp.

◆ LLONG_MIN

#define LLONG_MIN   (-LLONG_MAX - Q_INT64_C(1))

Definition at line 33 of file qlocale_tools.cpp.

◆ SMALL_BASE_LOOP

#define SMALL_BASE_LOOP (   b)
Value:
do { \
*--p = Char('0' + number % b); \
number /= b; \
} while (number)

◆ ULLONG_MAX

#define ULLONG_MAX   Q_UINT64_C(0xffffffffffffffff)

Definition at line 36 of file qlocale_tools.cpp.

Function Documentation

◆ digits()

static constexpr int digits ( int  number)
staticconstexpr

Definition at line 626 of file qlocale_tools.cpp.

References i, number, Q_ASSERT, and Q_LIKELY.

Referenced by QTest::countSignificantDigits(), digitCount(), QLocaleData::doubleToString(), dtoString(), qdtoa(), QSystemLocalePrivate::zeroDigit(), and zeroPad().

+ Here is the caller graph for this function:

◆ dtoString()

template<typename T >
static T dtoString ( double  d,
QLocaleData::DoubleForm  form,
int  precision,
bool  uppercase 
)
static

Definition at line 639 of file qlocale_tools.cpp.

References d, QGraphicsItem::data(), QLocaleData::DFDecimal, QLocaleData::DFExponent, QLocaleData::DFSignificantDigits, digits(), QLocale::FloatingPointShortest, form, i, isZero(), Q_ASSERT, qAbs(), qIsFinite(), qMax(), qt_doubleToAscii(), resolveFormat(), sign(), view, and wholePartSpace().

+ Here is the call graph for this function:

◆ isDigitForBase()

static bool isDigitForBase ( char  d,
int  base 
)
static

Definition at line 408 of file qlocale_tools.cpp.

References base, d, and qMin().

Referenced by qstrntoll().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qdtoa()

QString qdtoa ( qreal  d,
int *  decpt,
int *  sign 
)

Definition at line 572 of file qlocale_tools.cpp.

References d, QLocaleData::DFSignificantDigits, digits(), QLocale::FloatingPointShortest, qt_doubleToAscii(), and sign().

Referenced by QV4::RuntimeHelpers::numberToString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qdtoAscii()

QByteArray qdtoAscii ( double  d,
QLocaleData::DoubleForm  form,
int  precision,
bool  uppercase 
)

Definition at line 793 of file qlocale_tools.cpp.

References d, and form.

Referenced by QByteArray::number().

+ Here is the caller graph for this function:

◆ qdtoBasicLatin()

QString qdtoBasicLatin ( double  d,
QLocaleData::DoubleForm  form,
int  precision,
bool  uppercase 
)

Definition at line 788 of file qlocale_tools.cpp.

References d, and form.

Referenced by QString::number().

+ Here is the caller graph for this function:

◆ qstrntod()

double qstrntod ( const char *  s00,
qsizetype  len,
const char **  se,
bool *  ok 
)

Converts the initial portion of the string pointed to by s00 to a double, using the 'C' locale. The function sets the pointer pointed to by se to point to the character past the last character converted.

Definition at line 562 of file qlocale_tools.cpp.

References ok, qt_asciiToDouble(), and TrailingJunkAllowed.

Referenced by qstrtod().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qstrntoll()

QSimpleParsedNumber< qlonglong > qstrntoll ( const char *  begin,
qsizetype  size,
int  base 
)

Definition at line 439 of file qlocale_tools.cpp.

References ascii_isspace(), base, begin(), isDigitForBase(), and scanPrefix().

Referenced by QLocaleData::bytearrayToLongLong(), deviceNumber(), getWinLocaleName(), parsePosixTime(), and qt_doubleToAscii().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qstrntoull()

QSimpleParsedNumber< qulonglong > qstrntoull ( const char *  begin,
qsizetype  size,
int  base 
)

Definition at line 421 of file qlocale_tools.cpp.

References ascii_isspace(), base, begin(), and scanPrefix().

Referenced by QLocaleData::bytearrayToUnsLongLong(), from_string(), parse_field_width(), QIPAddressUtils::parseIp4Internal(), QIPAddressUtils::parseIp6(), and winIso639LangName().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qt_asciiToDouble()

QSimpleParsedNumber< double > qt_asciiToDouble ( const char *  num,
qsizetype  numLen,
StrayCharacterMode  strayCharMode 
)

Definition at line 253 of file qlocale_tools.cpp.

References c2, d, fmt, i, isZero(), Q_ASSERT, qIsFinite(), qIsNaN(), qsnprintf(), qt_inf(), qt_qnan(), TrailingJunkAllowed, TrailingJunkProhibited, and WhitespacesAllowed.

Referenced by qstrntod(), QLocaleData::stringToDouble(), QStringView::toDouble(), and QtPrivate::toDouble().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qt_doubleToAscii()

QT_CLOCALE_HOLDER void qt_doubleToAscii ( double  d,
QLocaleData::DoubleForm  form,
int  precision,
char *  buf,
qsizetype  bufSize,
bool &  sign,
int &  length,
int &  decpt 
)

Definition at line 45 of file qlocale_tools.cpp.

References d, QLocaleData::DFDecimal, QLocaleData::DFExponent, QLocaleData::DFSignificantDigits, QLocale::FloatingPointShortest, form, isZero(), Q_ASSERT, qMin(), qstrntoll(), qt_is_inf(), qt_is_nan(), sign(), and wholePartSpace().

Referenced by QLocaleData::doubleToString(), dtoString(), and qdtoa().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qulltoa()

QString qulltoa ( qulonglong  number,
int  base,
const QStringView  zero 
)

Definition at line 520 of file qlocale_tools.cpp.

References base, QChar::highSurrogate(), QChar::lowSurrogate(), number, QChar::surrogateToUcs4(), unicodeForDigit(), and zero.

Referenced by QLocaleData::longLongToString(), QIPAddressUtils::number(), and QLocaleData::unsLongLongToString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qulltoBasicLatin()

QString qulltoBasicLatin ( qulonglong  number,
int  base,
bool  negative 
)

Definition at line 502 of file qlocale_tools.cpp.

References base, number, and QStringLiteral.

Referenced by QString::number(), and QString::number().

+ Here is the caller graph for this function:

◆ qulltoString_helper()

template<typename Char >
static Q_ALWAYS_INLINE void qulltoString_helper ( qulonglong  number,
int  base,
Char *&  p 
)
static

Definition at line 473 of file qlocale_tools.cpp.

References base, BIG_BASE_LOOP, and SMALL_BASE_LOOP.

◆ resolveFormat()

static QLocaleData::DoubleForm resolveFormat ( int  precision,
int  decpt,
qsizetype  length 
)
static

Definition at line 592 of file qlocale_tools.cpp.

References QLocaleData::DFDecimal, QLocaleData::DFExponent, QLocale::FloatingPointShortest, and Q_ASSERT.

Referenced by dtoString().

+ Here is the caller graph for this function:

◆ scanPrefix()

static auto scanPrefix ( const char *  p,
const char *  stop,
int  base 
)
static

Definition at line 370 of file qlocale_tools.cpp.

References base, QtMiscUtils::isAsciiDigit(), next, Q_ASSERT, and R.

Referenced by qstrntoll(), and qstrntoull().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: