6#include "private/qdebug_p.h"
8#include <private/qlogging_p.h>
9#include <private/qtextstream_p.h>
10#include <private/qtools_p.h>
159 if (
stream->message_output) {
172void QDebug::putUcs4(
uint ucs4)
177 }
else if (ucs4 < 0x80) {
192static inline bool isPrintable(
char32_t ucs4) {
return QChar::isPrint(ucs4); }
193static inline bool isPrintable(
char16_t uc) {
return QChar::isPrint(uc); }
197template <
typename Char>
203 bool lastWasHexEscape =
false;
213 lastWasHexEscape =
false;
219 while (
p + runLength !=
end &&
220 isPrintable(
p[runLength]) &&
p[runLength] !=
'\\' &&
p[runLength] !=
'"')
223 d->write(
reinterpret_cast<const QChar *
>(
p), runLength);
235 char16_t buf[std::char_traits<char>::length(
"\\U12345678")];
265 lastWasHexEscape =
true;
268 if (QChar::isHighSurrogate(*
p)) {
269 if ((
p + 1) !=
end && QChar::isLowSurrogate(
p[1])) {
271 char32_t ucs4 = QChar::surrogateToUcs4(*
p,
p[1]);
300 d->write(
reinterpret_cast<QChar *
>(
buf), buflen);
319 stream->ts.d_ptr->params.reset();
328void QDebug::putByteArray(
const char *
begin,
size_t length, Latin1Content content)
335 stream->ts.d_ptr->putString(
string);
339 stream->ts.d_ptr->params.reset();
341 length, content == ContainsLatin1);
347 using namespace std::chrono;
350 if (
num == 1 && den > 1) {
353 auto tryprefix = [&](
auto d,
char c) {
354 static_assert(
decltype(
d)
::num == 1,
"not an SI prefix");
355 if (den ==
decltype(
d)::den)
360 tryprefix(std::milli{},
'm');
361 tryprefix(std::micro{},
'u');
362 tryprefix(std::nano{},
'n');
363 tryprefix(std::pico{},
'p');
364 tryprefix(std::femto{},
'f');
365 tryprefix(std::atto{},
'a');
367 tryprefix(std::centi{},
'c');
368 tryprefix(std::deci{},
'd');
370 char unit[3] = { prefix,
's' };
375 const char *unit =
nullptr;
376 if (
num > 1 && den == 1) {
378 auto tryunit = [&](
auto d,
const char *
name) {
379 static_assert(
decltype(
d)::period::den == 1,
"not a multiple of a second");
380 if (unit ||
num %
decltype(
d)::period::num)
383 num /=
decltype(
d)::period::num;
385 tryunit(
years{},
"yr");
386 tryunit(
weeks{},
"wk");
387 tryunit(
days{},
"d");
388 tryunit(hours{},
"h");
389 tryunit(minutes{},
"min");
394 if (
num == 1 && den == 1)
401 char buf[2 * (std::numeric_limits<qint64>::digits10 + 2) + 10];
403 auto appendChar = [&](
char c) {
420 memcpy(
buf +
len, unit, strlen(unit));
436#ifdef QT_SUPPORTS_INT128
438constexpr char Q_INT128_MIN_STR[] =
"-170141183460469231731687303715884105728";
440constexpr int Int128BufferSize =
sizeof(Q_INT128_MIN_STR);
441using Int128Buffer = std::array<char, Int128BufferSize>;
452 *--
dst =
"0123456789"[
n % 10];
461static const char *int128Warning()
463 const char *msg =
"Qt was not compiled with int128 support.";
475void QDebug::putInt128([[maybe_unused]]
const void *
p)
477#ifdef QT_SUPPORTS_INT128
480 memcpy(&
i,
p,
sizeof(
i));
481 if (
i == Q_INT128_MIN) {
483 stream->ts << Q_INT128_MIN_STR;
493 stream->ts << int128Warning();
501void QDebug::putUInt128([[maybe_unused]]
const void *
p)
503#ifdef QT_SUPPORTS_INT128
506 memcpy(&
i,
p,
sizeof(
i));
511 stream->ts << int128Warning();
529QDebug &QDebug::resetFormat()
534 stream->verbosity = DefaultVerbosity;
1190 const bool currentSpaces =
m_stream->space;
1192 if (
m_stream->buffer.endsWith(u
' '))
1222QDebugStateSaver::QDebugStateSaver(
QDebug &dbg)
1233QDebugStateSaver::~QDebugStateSaver()
1248 qt_QMetaEnum_flagDebugOperator<int>(
debug, sizeofT,
value);
1251#ifndef QT_NO_QOBJECT
1293 const int verbosity = dbg.verbosity();
1294 if (verbosity >= QDebug::DefaultVerbosity) {
1295 if (
const char *scope = me.
scope())
1296 dbg << scope << u
"::";
1300 const bool scoped = me.
isScoped() || verbosity & 1;
1307 dbg <<
value <<
')';
1343 const int verbosity =
debug.verbosity();
1346 debug.resetFormat();
1352 const bool classScope = verbosity >= QDebug::DefaultVerbosity;
1354 debug << u
"QFlags<";
1356 if (
const char *scope = me.
scope())
1357 debug << scope << u
"::";
1360 const bool enumScope = me.
isScoped() || verbosity > QDebug::MinimumVerbosity;
const QTextStreamPrivate::Params m_streamParams
QDebug::Stream * m_stream
QDebugStateSaverPrivate(QDebug::Stream *stream)
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString static QString asprintf(const char *format,...) Q_ATTRIBUTE_FORMAT_PRINTF(1
void qt_message_output(QtMsgType msgType, const QMessageLogContext &context, const QString &message)
Combined button and popup list for selecting options.
qsizetype fromUtf8(uchar b, OutputPtr &dst, InputPtr &src, InputPtr end)
Q_CORE_EXPORT QByteArray toPrintable(const char *data, qint64 len, qsizetype maxSize)
constexpr int isAsciiPrintable(char32_t ch) noexcept
constexpr char toHexUpper(char32_t value) noexcept
constexpr char toHexLower(char32_t value) noexcept
constexpr int fromHex(char32_t c) noexcept
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
QTextStream & reset(QTextStream &stream)
Calls QTextStream::reset() on stream and returns stream.
std::chrono::duration< IntRep, std::ratio_multiply< std::ratio< 7 >, days::period > > weeks
std::chrono::duration< IntRep, std::ratio< 86400 > > days
std::chrono::duration< IntRep, std::ratio_multiply< std::ratio< 146097, 400 >, days::period > > years
Q_CORE_EXPORT int qsnprintf(char *str, size_t n, const char *fmt,...)
QDebug qt_QMetaEnum_debugOperator(QDebug &dbg, qint64 value, const QMetaObject *meta, const char *name)
void qt_QMetaEnum_flagDebugOperator(QDebug &debug, size_t sizeofT, int value)
static void putEscapedString(QTextStreamPrivate *d, const Char *begin, size_t length, bool isUnicode=true)
static QByteArray timeUnit(qint64 num, qint64 den)
static bool isPrintable(char32_t ucs4)
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr const T & qMin(const T &a, const T &b)
GLenum GLuint GLenum GLsizei length
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLenum GLsizei const GLchar * buf
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
QTextStreamManipulator qSetPadChar(QChar ch)
QTextStreamManipulator qSetFieldWidth(int width)
unsigned long long quint64
static QString quote(const QString &str)
QTextStream out(stdout)
[7]
\inmodule QtCore \reentrant