| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/io/qdebug.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||
| 2 | ** | - | ||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||
| 4 | ** Copyright (C) 2016 Intel Corporation. | - | ||||||
| 5 | ** Contact: https://www.qt.io/licensing/ | - | ||||||
| 6 | ** | - | ||||||
| 7 | ** This file is part of the QtCore module of the Qt Toolkit. | - | ||||||
| 8 | ** | - | ||||||
| 9 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||
| 10 | ** Commercial License Usage | - | ||||||
| 11 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||
| 12 | ** accordance with the commercial license agreement provided with the | - | ||||||
| 13 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||
| 14 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||
| 15 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||
| 16 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||
| 17 | ** | - | ||||||
| 18 | ** GNU Lesser General Public License Usage | - | ||||||
| 19 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||
| 20 | ** General Public License version 3 as published by the Free Software | - | ||||||
| 21 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||
| 22 | ** packaging of this file. Please review the following information to | - | ||||||
| 23 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||
| 24 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||
| 25 | ** | - | ||||||
| 26 | ** GNU General Public License Usage | - | ||||||
| 27 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||
| 28 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||
| 29 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||
| 30 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||
| 31 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||
| 32 | ** included in the packaging of this file. Please review the following | - | ||||||
| 33 | ** information to ensure the GNU General Public License requirements will | - | ||||||
| 34 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||
| 35 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||
| 36 | ** | - | ||||||
| 37 | ** $QT_END_LICENSE$ | - | ||||||
| 38 | ** | - | ||||||
| 39 | ****************************************************************************/ | - | ||||||
| 40 | - | |||||||
| 41 | #ifdef QT_NO_DEBUG | - | ||||||
| 42 | #undef QT_NO_DEBUG | - | ||||||
| 43 | #endif | - | ||||||
| 44 | #ifdef qDebug | - | ||||||
| 45 | #undef qDebug | - | ||||||
| 46 | #endif | - | ||||||
| 47 | - | |||||||
| 48 | #include "qdebug.h" | - | ||||||
| 49 | #include "qmetaobject.h" | - | ||||||
| 50 | #include <private/qtextstream_p.h> | - | ||||||
| 51 | #include <private/qtools_p.h> | - | ||||||
| 52 | - | |||||||
| 53 | QT_BEGIN_NAMESPACE | - | ||||||
| 54 | - | |||||||
| 55 | using QtMiscUtils::toHexUpper; | - | ||||||
| 56 | using QtMiscUtils::fromHex; | - | ||||||
| 57 | - | |||||||
| 58 | // This file is needed to force compilation of QDebug into the kernel library. | - | ||||||
| 59 | - | |||||||
| 60 | /*! | - | ||||||
| 61 | \class QDebug | - | ||||||
| 62 | \inmodule QtCore | - | ||||||
| 63 | \ingroup shared | - | ||||||
| 64 | - | |||||||
| 65 | \brief The QDebug class provides an output stream for debugging information. | - | ||||||
| 66 | - | |||||||
| 67 | QDebug is used whenever the developer needs to write out debugging or tracing | - | ||||||
| 68 | information to a device, file, string or console. | - | ||||||
| 69 | - | |||||||
| 70 | \section1 Basic Use | - | ||||||
| 71 | - | |||||||
| 72 | In the common case, it is useful to call the qDebug() function to obtain a | - | ||||||
| 73 | default QDebug object to use for writing debugging information. | - | ||||||
| 74 | - | |||||||
| 75 | \snippet qdebug/qdebugsnippet.cpp 1 | - | ||||||
| 76 | - | |||||||
| 77 | This constructs a QDebug object using the constructor that accepts a QtMsgType | - | ||||||
| 78 | value of QtDebugMsg. Similarly, the qWarning(), qCritical() and qFatal() | - | ||||||
| 79 | functions also return QDebug objects for the corresponding message types. | - | ||||||
| 80 | - | |||||||
| 81 | The class also provides several constructors for other situations, including | - | ||||||
| 82 | a constructor that accepts a QFile or any other QIODevice subclass that is | - | ||||||
| 83 | used to write debugging information to files and other devices. The constructor | - | ||||||
| 84 | that accepts a QString is used to write to a string for display or serialization. | - | ||||||
| 85 | - | |||||||
| 86 | \section1 Formatting Options | - | ||||||
| 87 | - | |||||||
| 88 | QDebug formats output so that it's easily readable. It automatically adds spaces | - | ||||||
| 89 | between arguments, and adds quotes around QString, QByteArray, QChar arguments. | - | ||||||
| 90 | - | |||||||
| 91 | You can tweak these options through the space(), nospace() and quote(), noquote() | - | ||||||
| 92 | methods. Furthermore, \l{QTextStream manipulators} can be piped into a QDebug | - | ||||||
| 93 | stream. | - | ||||||
| 94 | - | |||||||
| 95 | QDebugStateSaver limits changes to the formatting to the current scope. | - | ||||||
| 96 | resetFormat() resets the options to the default ones. | - | ||||||
| 97 | - | |||||||
| 98 | \section1 Writing Custom Types to a Stream | - | ||||||
| 99 | - | |||||||
| 100 | Many standard types can be written to QDebug objects, and Qt provides support for | - | ||||||
| 101 | most Qt value types. To add support for custom types, you need to implement a | - | ||||||
| 102 | streaming operator, as in the following example: | - | ||||||
| 103 | - | |||||||
| 104 | \snippet qdebug/qdebugsnippet.cpp 0 | - | ||||||
| 105 | - | |||||||
| 106 | This is described in the \l{Debugging Techniques} and | - | ||||||
| 107 | \l{Creating Custom Qt Types#Making the Type Printable}{Creating Custom Qt Types} | - | ||||||
| 108 | documents. | - | ||||||
| 109 | */ | - | ||||||
| 110 | - | |||||||
| 111 | /*! | - | ||||||
| 112 | \fn QDebug::QDebug(QIODevice *device) | - | ||||||
| 113 | - | |||||||
| 114 | Constructs a debug stream that writes to the given \a device. | - | ||||||
| 115 | */ | - | ||||||
| 116 | - | |||||||
| 117 | /*! | - | ||||||
| 118 | \fn QDebug::QDebug(QString *string) | - | ||||||
| 119 | - | |||||||
| 120 | Constructs a debug stream that writes to the given \a string. | - | ||||||
| 121 | */ | - | ||||||
| 122 | - | |||||||
| 123 | /*! | - | ||||||
| 124 | \fn QDebug::QDebug(QtMsgType type) | - | ||||||
| 125 | - | |||||||
| 126 | Constructs a debug stream that writes to the handler for the message type specified by \a type. | - | ||||||
| 127 | */ | - | ||||||
| 128 | - | |||||||
| 129 | /*! | - | ||||||
| 130 | \fn QDebug::QDebug(const QDebug &other) | - | ||||||
| 131 | - | |||||||
| 132 | Constructs a copy of the \a other debug stream. | - | ||||||
| 133 | */ | - | ||||||
| 134 | - | |||||||
| 135 | /*! | - | ||||||
| 136 | \fn QDebug &QDebug::operator=(const QDebug &other) | - | ||||||
| 137 | - | |||||||
| 138 | Assigns the \a other debug stream to this stream and returns a reference to | - | ||||||
| 139 | this stream. | - | ||||||
| 140 | */ | - | ||||||
| 141 | - | |||||||
| 142 | /*! | - | ||||||
| 143 | \fn QDebug::~QDebug() | - | ||||||
| 144 | - | |||||||
| 145 | Flushes any pending data to be written and destroys the debug stream. | - | ||||||
| 146 | */ | - | ||||||
| 147 | // Has been defined in the header / inlined before Qt 5.4 | - | ||||||
| 148 | QDebug::~QDebug() | - | ||||||
| 149 | { | - | ||||||
| 150 | if (!--stream->ref) { | - | ||||||
| 151 | if (stream->space && stream->buffer.endsWith(QLatin1Char(' '))) | - | ||||||
| 152 | stream->buffer.chop(1); | - | ||||||
| 153 | if (stream->message_output) { | - | ||||||
| 154 | qt_message_output(stream->type, | - | ||||||
| 155 | stream->context, | - | ||||||
| 156 | stream->buffer); | - | ||||||
| 157 | } | - | ||||||
| 158 | delete stream; | - | ||||||
| 159 | } | - | ||||||
| 160 | } | - | ||||||
| 161 | - | |||||||
| 162 | /*! | - | ||||||
| 163 | \internal | - | ||||||
| 164 | */ | - | ||||||
| 165 | void QDebug::putUcs4(uint ucs4) | - | ||||||
| 166 | { | - | ||||||
| 167 | maybeQuote('\''); | - | ||||||
| 168 | if (ucs4 < 0x20) { | - | ||||||
| 169 | stream->ts << "\\x" << hex << ucs4 << reset; | - | ||||||
| 170 | } else if (ucs4 < 0x80) { | - | ||||||
| 171 | stream->ts << char(ucs4); | - | ||||||
| 172 | } else { | - | ||||||
| 173 | if (ucs4 < 0x10000) | - | ||||||
| 174 | stream->ts << "\\u" << qSetFieldWidth(4); | - | ||||||
| 175 | else | - | ||||||
| 176 | stream->ts << "\\U" << qSetFieldWidth(8); | - | ||||||
| 177 | stream->ts << hex << qSetPadChar(QLatin1Char('0')) << ucs4 << reset; | - | ||||||
| 178 | } | - | ||||||
| 179 | maybeQuote('\''); | - | ||||||
| 180 | } | - | ||||||
| 181 | - | |||||||
| 182 | // These two functions return true if the character should be printed by QDebug. | - | ||||||
| 183 | // For QByteArray, this is technically identical to US-ASCII isprint(); | - | ||||||
| 184 | // for QString, we use QChar::isPrint, which requires a full UCS-4 decode. | - | ||||||
| 185 | static inline bool isPrintable(uint ucs4) | - | ||||||
| 186 | { return QChar::isPrint(ucs4); } | - | ||||||
| 187 | static inline bool isPrintable(ushort uc) | - | ||||||
| 188 | { return QChar::isPrint(uc); } | - | ||||||
| 189 | static inline bool isPrintable(uchar c) | - | ||||||
| 190 | { return c >= ' ' && c < 0x7f; } | - | ||||||
| 191 | - | |||||||
| 192 | template <typename Char> | - | ||||||
| 193 | static inline void putEscapedString(QTextStreamPrivate *d, const Char *begin, int length, bool isUnicode = true) | - | ||||||
| 194 | { | - | ||||||
| 195 | QChar quote(QLatin1Char('"')); | - | ||||||
| 196 | d->write("e, 1); | - | ||||||
| 197 | - | |||||||
| 198 | bool lastWasHexEscape = false; | - | ||||||
| 199 | const Char *end = begin + length; | - | ||||||
| 200 | for (const Char *p = begin; p != end; ++p) { | - | ||||||
| 201 | // check if we need to insert "" to break an hex escape sequence | - | ||||||
| 202 | if (Q_UNLIKELY(lastWasHexEscape)) { | - | ||||||
| 203 | if (fromHex(*p) != -1) { | - | ||||||
| 204 | // yes, insert it | - | ||||||
| 205 | QChar quotes[] = { QLatin1Char('"'), QLatin1Char('"') }; | - | ||||||
| 206 | d->write(quotes, 2); | - | ||||||
| 207 | } | - | ||||||
| 208 | lastWasHexEscape = false; | - | ||||||
| 209 | } | - | ||||||
| 210 | - | |||||||
| 211 | if (sizeof(Char) == sizeof(QChar)) { | - | ||||||
| 212 | // Surrogate characters are category Cs (Other_Surrogate), so isPrintable = false for them | - | ||||||
| 213 | int runLength = 0; | - | ||||||
| 214 | while (p + runLength != end && | - | ||||||
| 215 | isPrintable(p[runLength]) && p[runLength] != '\\' && p[runLength] != '"') | - | ||||||
| 216 | ++runLength; | - | ||||||
| 217 | if (runLength) { | - | ||||||
| 218 | d->write(reinterpret_cast<const QChar *>(p), runLength); | - | ||||||
| 219 | p += runLength - 1; | - | ||||||
| 220 | continue; | - | ||||||
| 221 | } | - | ||||||
| 222 | } else if (isPrintable(*p) && *p != '\\' && *p != '"') { | - | ||||||
| 223 | QChar c = QLatin1Char(*p); | - | ||||||
| 224 | d->write(&c, 1); | - | ||||||
| 225 | continue; | - | ||||||
| 226 | } | - | ||||||
| 227 | - | |||||||
| 228 | // print as an escape sequence (maybe, see below for surrogate pairs) | - | ||||||
| 229 | int buflen = 2; | - | ||||||
| 230 | ushort buf[sizeof "\\U12345678" - 1]; | - | ||||||
| 231 | buf[0] = '\\'; | - | ||||||
| 232 | - | |||||||
| 233 | switch (*p) { | - | ||||||
| 234 | case '"': | - | ||||||
| 235 | case '\\': | - | ||||||
| 236 | buf[1] = *p; | - | ||||||
| 237 | break; | - | ||||||
| 238 | case '\b': | - | ||||||
| 239 | buf[1] = 'b'; | - | ||||||
| 240 | break; | - | ||||||
| 241 | case '\f': | - | ||||||
| 242 | buf[1] = 'f'; | - | ||||||
| 243 | break; | - | ||||||
| 244 | case '\n': | - | ||||||
| 245 | buf[1] = 'n'; | - | ||||||
| 246 | break; | - | ||||||
| 247 | case '\r': | - | ||||||
| 248 | buf[1] = 'r'; | - | ||||||
| 249 | break; | - | ||||||
| 250 | case '\t': | - | ||||||
| 251 | buf[1] = 't'; | - | ||||||
| 252 | break; | - | ||||||
| 253 | default: | - | ||||||
| 254 | if (!isUnicode) { | - | ||||||
| 255 | // print as hex escape | - | ||||||
| 256 | buf[1] = 'x'; | - | ||||||
| 257 | buf[2] = toHexUpper(uchar(*p) >> 4); | - | ||||||
| 258 | buf[3] = toHexUpper(uchar(*p)); | - | ||||||
| 259 | buflen = 4; | - | ||||||
| 260 | lastWasHexEscape = true; | - | ||||||
| 261 | break; | - | ||||||
| 262 | } | - | ||||||
| 263 | if (QChar::isHighSurrogate(*p)) { | - | ||||||
| 264 | if ((p + 1) != end && QChar::isLowSurrogate(p[1])) { | - | ||||||
| 265 | // properly-paired surrogates | - | ||||||
| 266 | uint ucs4 = QChar::surrogateToUcs4(*p, p[1]); | - | ||||||
| 267 | if (isPrintable(ucs4)) { | - | ||||||
| 268 | buf[0] = *p; | - | ||||||
| 269 | buf[1] = p[1]; | - | ||||||
| 270 | buflen = 2; | - | ||||||
| 271 | } else { | - | ||||||
| 272 | buf[1] = 'U'; | - | ||||||
| 273 | buf[2] = '0'; // toHexUpper(ucs4 >> 32); | - | ||||||
| 274 | buf[3] = '0'; // toHexUpper(ucs4 >> 28); | - | ||||||
| 275 | buf[4] = toHexUpper(ucs4 >> 20); | - | ||||||
| 276 | buf[5] = toHexUpper(ucs4 >> 16); | - | ||||||
| 277 | buf[6] = toHexUpper(ucs4 >> 12); | - | ||||||
| 278 | buf[7] = toHexUpper(ucs4 >> 8); | - | ||||||
| 279 | buf[8] = toHexUpper(ucs4 >> 4); | - | ||||||
| 280 | buf[9] = toHexUpper(ucs4); | - | ||||||
| 281 | buflen = 10; | - | ||||||
| 282 | } | - | ||||||
| 283 | ++p; | - | ||||||
| 284 | break; | - | ||||||
| 285 | } | - | ||||||
| 286 | // improperly-paired surrogates, fall through | - | ||||||
| 287 | } | - | ||||||
| 288 | buf[1] = 'u'; | - | ||||||
| 289 | buf[2] = toHexUpper(ushort(*p) >> 12); | - | ||||||
| 290 | buf[3] = toHexUpper(ushort(*p) >> 8); | - | ||||||
| 291 | buf[4] = toHexUpper(*p >> 4); | - | ||||||
| 292 | buf[5] = toHexUpper(*p); | - | ||||||
| 293 | buflen = 6; | - | ||||||
| 294 | } | - | ||||||
| 295 | d->write(reinterpret_cast<QChar *>(buf), buflen); | - | ||||||
| 296 | } | - | ||||||
| 297 | - | |||||||
| 298 | d->write("e, 1); | - | ||||||
| 299 | } | - | ||||||
| 300 | - | |||||||
| 301 | /*! | - | ||||||
| 302 | \internal | - | ||||||
| 303 | Duplicated from QtTest::toPrettyUnicode(). | - | ||||||
| 304 | */ | - | ||||||
| 305 | void QDebug::putString(const QChar *begin, size_t length) | - | ||||||
| 306 | { | - | ||||||
| 307 | if (stream->testFlag(Stream::NoQuotes)) { | - | ||||||
| 308 | // no quotes, write the string directly too (no pretty-printing) | - | ||||||
| 309 | // this respects the QTextStream state, though | - | ||||||
| 310 | stream->ts.d_ptr->putString(begin, int(length)); | - | ||||||
| 311 | } else { | - | ||||||
| 312 | // we'll reset the QTextStream formatting mechanisms, so save the state | - | ||||||
| 313 | QDebugStateSaver saver(*this); | - | ||||||
| 314 | stream->ts.d_ptr->params.reset(); | - | ||||||
| 315 | putEscapedString(stream->ts.d_ptr.data(), reinterpret_cast<const ushort *>(begin), int(length)); | - | ||||||
| 316 | } | - | ||||||
| 317 | } | - | ||||||
| 318 | - | |||||||
| 319 | /*! | - | ||||||
| 320 | \internal | - | ||||||
| 321 | Duplicated from QtTest::toPrettyCString(). | - | ||||||
| 322 | */ | - | ||||||
| 323 | void QDebug::putByteArray(const char *begin, size_t length, Latin1Content content) | - | ||||||
| 324 | { | - | ||||||
| 325 | if (stream->testFlag(Stream::NoQuotes)) { | - | ||||||
| 326 | // no quotes, write the string directly too (no pretty-printing) | - | ||||||
| 327 | // this respects the QTextStream state, though | - | ||||||
| 328 | QString string = content == ContainsLatin1 ? QString::fromLatin1(begin, int(length)) : QString::fromUtf8(begin, int(length)); | - | ||||||
| 329 | stream->ts.d_ptr->putString(string); | - | ||||||
| 330 | } else { | - | ||||||
| 331 | // we'll reset the QTextStream formatting mechanisms, so save the state | - | ||||||
| 332 | QDebugStateSaver saver(*this); | - | ||||||
| 333 | stream->ts.d_ptr->params.reset(); | - | ||||||
| 334 | putEscapedString(stream->ts.d_ptr.data(), reinterpret_cast<const uchar *>(begin), | - | ||||||
| 335 | int(length), content == ContainsLatin1); | - | ||||||
| 336 | } | - | ||||||
| 337 | } | - | ||||||
| 338 | - | |||||||
| 339 | /*! | - | ||||||
| 340 | \fn QDebug::swap(QDebug &other) | - | ||||||
| 341 | \since 5.0 | - | ||||||
| 342 | - | |||||||
| 343 | Swaps this debug stream instance with \a other. This function is | - | ||||||
| 344 | very fast and never fails. | - | ||||||
| 345 | */ | - | ||||||
| 346 | - | |||||||
| 347 | /*! | - | ||||||
| 348 | Resets the stream formatting options, bringing it back to its original constructed state. | - | ||||||
| 349 | - | |||||||
| 350 | \sa space(), quote() | - | ||||||
| 351 | \since 5.4 | - | ||||||
| 352 | */ | - | ||||||
| 353 | QDebug &QDebug::resetFormat() | - | ||||||
| 354 | { | - | ||||||
| 355 | stream->ts.reset(); | - | ||||||
| 356 | stream->space = true; | - | ||||||
| 357 | if (stream->context.version > 1)
| 0-921 | ||||||
| 358 | stream->flags = 0; executed 921 times by 12 tests: stream->flags = 0;Executed by:
| 921 | ||||||
| 359 | stream->setVerbosity(Stream::defaultVerbosityDefaultVerbosity); | - | ||||||
| 360 | return *this; executed 921 times by 12 tests: return *this;Executed by:
| 921 | ||||||
| 361 | } | - | ||||||
| 362 | - | |||||||
| 363 | /*! | - | ||||||
| 364 | \fn QDebug &QDebug::space() | - | ||||||
| 365 | - | |||||||
| 366 | Writes a space character to the debug stream and returns a reference to | - | ||||||
| 367 | the stream. | - | ||||||
| 368 | - | |||||||
| 369 | The stream remembers that automatic insertion of spaces is | - | ||||||
| 370 | enabled for future writes. | - | ||||||
| 371 | - | |||||||
| 372 | \sa nospace(), maybeSpace() | - | ||||||
| 373 | */ | - | ||||||
| 374 | - | |||||||
| 375 | /*! | - | ||||||
| 376 | \fn QDebug &QDebug::nospace() | - | ||||||
| 377 | - | |||||||
| 378 | Disables automatic insertion of spaces and returns a reference to the stream. | - | ||||||
| 379 | - | |||||||
| 380 | \sa space(), maybeSpace() | - | ||||||
| 381 | */ | - | ||||||
| 382 | - | |||||||
| 383 | /*! | - | ||||||
| 384 | \fn QDebug &QDebug::maybeSpace() | - | ||||||
| 385 | - | |||||||
| 386 | Writes a space character to the debug stream, depending on the current | - | ||||||
| 387 | setting for automatic insertion of spaces, and returns a reference to the stream. | - | ||||||
| 388 | - | |||||||
| 389 | \sa space(), nospace() | - | ||||||
| 390 | */ | - | ||||||
| 391 | - | |||||||
| 392 | /*! | - | ||||||
| 393 | \fn bool QDebug::autoInsertSpaces() const | - | ||||||
| 394 | - | |||||||
| 395 | Returns \c true if this QDebug instance will automatically insert spaces | - | ||||||
| 396 | between writes. | - | ||||||
| 397 | - | |||||||
| 398 | \since 5.0 | - | ||||||
| 399 | - | |||||||
| 400 | \sa QDebugStateSaver | - | ||||||
| 401 | */ | - | ||||||
| 402 | - | |||||||
| 403 | /*! | - | ||||||
| 404 | \fn void QDebug::setAutoInsertSpaces(bool b) | - | ||||||
| 405 | - | |||||||
| 406 | Enables automatic insertion of spaces between writes if \a b is true; otherwise | - | ||||||
| 407 | automatic insertion of spaces is disabled. | - | ||||||
| 408 | - | |||||||
| 409 | \since 5.0 | - | ||||||
| 410 | - | |||||||
| 411 | \sa QDebugStateSaver | - | ||||||
| 412 | */ | - | ||||||
| 413 | - | |||||||
| 414 | - | |||||||
| 415 | /*! | - | ||||||
| 416 | \fn QDebug &QDebug::quote() | - | ||||||
| 417 | \since 5.4 | - | ||||||
| 418 | - | |||||||
| 419 | Enables automatic insertion of quotation characters around QChar, QString and QByteArray | - | ||||||
| 420 | contents and returns a reference to the stream. | - | ||||||
| 421 | - | |||||||
| 422 | Quoting is enabled by default. | - | ||||||
| 423 | - | |||||||
| 424 | \sa noquote(), maybeQuote() | - | ||||||
| 425 | */ | - | ||||||
| 426 | - | |||||||
| 427 | /*! | - | ||||||
| 428 | \fn QDebug &QDebug::noquote() | - | ||||||
| 429 | \since 5.4 | - | ||||||
| 430 | - | |||||||
| 431 | Disables automatic insertion of quotation characters around QChar, QString and QByteArray | - | ||||||
| 432 | contents and returns a reference to the stream. | - | ||||||
| 433 | - | |||||||
| 434 | When quoting is disabled, these types are printed without quotation | - | ||||||
| 435 | characters and without escaping of non-printable characters. | - | ||||||
| 436 | - | |||||||
| 437 | \sa quote(), maybeQuote() | - | ||||||
| 438 | */ | - | ||||||
| 439 | - | |||||||
| 440 | /*! | - | ||||||
| 441 | \fn QDebug &QDebug::maybeQuote(char c) | - | ||||||
| 442 | \since 5.4 | - | ||||||
| 443 | - | |||||||
| 444 | Writes a character \a c to the debug stream, depending on the | - | ||||||
| 445 | current setting for automatic insertion of quotes, and returns a reference to the stream. | - | ||||||
| 446 | - | |||||||
| 447 | The default character is a double quote \c{"}. | - | ||||||
| 448 | - | |||||||
| 449 | \sa quote(), noquote() | - | ||||||
| 450 | */ | - | ||||||
| 451 | - | |||||||
| 452 | /*! | - | ||||||
| 453 | \fn int QDebug::verbosity() const | - | ||||||
| 454 | \since 5.6 | - | ||||||
| 455 | - | |||||||
| 456 | Returns the verbosity of the debug stream. | - | ||||||
| 457 | - | |||||||
| 458 | Streaming operators can check the value to decide whether | - | ||||||
| 459 | verbose output is desired and print more information depending on the | - | ||||||
| 460 | level. Higher values indicate that more information is desired. | - | ||||||
| 461 | - | |||||||
| 462 | The allowed range is from 0 to 7. The default value is 2. | - | ||||||
| 463 | - | |||||||
| 464 | \sa setVerbosity() | - | ||||||
| 465 | */ | - | ||||||
| 466 | - | |||||||
| 467 | /*! | - | ||||||
| 468 | \fn void QDebug::setVerbosity(int verbosityLevel) | - | ||||||
| 469 | \since 5.6 | - | ||||||
| 470 | - | |||||||
| 471 | Sets the verbosity of the stream to \a verbosityLevel. | - | ||||||
| 472 | - | |||||||
| 473 | The allowed range is from 0 to 7. The default value is 2. | - | ||||||
| 474 | - | |||||||
| 475 | \sa verbosity() | - | ||||||
| 476 | */ | - | ||||||
| 477 | - | |||||||
| 478 | /*! | - | ||||||
| 479 | \fn QDebug &QDebug::operator<<(QChar t) | - | ||||||
| 480 | - | |||||||
| 481 | Writes the character, \a t, to the stream and returns a reference to the | - | ||||||
| 482 | stream. Normally, QDebug prints control characters and non-US-ASCII | - | ||||||
| 483 | characters as their C escape sequences or their Unicode value (\\u1234). To | - | ||||||
| 484 | print non-printable characters without transformation, enable the noquote() | - | ||||||
| 485 | functionality, but note that some QDebug backends may not be 8-bit clean | - | ||||||
| 486 | and may not be able to represent \c t. | - | ||||||
| 487 | */ | - | ||||||
| 488 | - | |||||||
| 489 | /*! | - | ||||||
| 490 | \fn QDebug &QDebug::operator<<(bool t) | - | ||||||
| 491 | - | |||||||
| 492 | Writes the boolean value, \a t, to the stream and returns a reference to the | - | ||||||
| 493 | stream. | - | ||||||
| 494 | */ | - | ||||||
| 495 | - | |||||||
| 496 | /*! | - | ||||||
| 497 | \fn QDebug &QDebug::operator<<(char t) | - | ||||||
| 498 | - | |||||||
| 499 | Writes the character, \a t, to the stream and returns a reference to the | - | ||||||
| 500 | stream. | - | ||||||
| 501 | */ | - | ||||||
| 502 | - | |||||||
| 503 | /*! | - | ||||||
| 504 | \fn QDebug &QDebug::operator<<(signed short i) | - | ||||||
| 505 | - | |||||||
| 506 | Writes the signed short integer, \a i, to the stream and returns a reference | - | ||||||
| 507 | to the stream. | - | ||||||
| 508 | */ | - | ||||||
| 509 | - | |||||||
| 510 | /*! | - | ||||||
| 511 | \fn QDebug &QDebug::operator<<(unsigned short i) | - | ||||||
| 512 | - | |||||||
| 513 | Writes then unsigned short integer, \a i, to the stream and returns a | - | ||||||
| 514 | reference to the stream. | - | ||||||
| 515 | */ | - | ||||||
| 516 | - | |||||||
| 517 | /*! | - | ||||||
| 518 | \fn QDebug &QDebug::operator<<(signed int i) | - | ||||||
| 519 | - | |||||||
| 520 | Writes the signed integer, \a i, to the stream and returns a reference | - | ||||||
| 521 | to the stream. | - | ||||||
| 522 | */ | - | ||||||
| 523 | - | |||||||
| 524 | /*! | - | ||||||
| 525 | \fn QDebug &QDebug::operator<<(unsigned int i) | - | ||||||
| 526 | - | |||||||
| 527 | Writes then unsigned integer, \a i, to the stream and returns a reference to | - | ||||||
| 528 | the stream. | - | ||||||
| 529 | */ | - | ||||||
| 530 | - | |||||||
| 531 | /*! | - | ||||||
| 532 | \fn QDebug &QDebug::operator<<(signed long l) | - | ||||||
| 533 | - | |||||||
| 534 | Writes the signed long integer, \a l, to the stream and returns a reference | - | ||||||
| 535 | to the stream. | - | ||||||
| 536 | */ | - | ||||||
| 537 | - | |||||||
| 538 | /*! | - | ||||||
| 539 | \fn QDebug &QDebug::operator<<(unsigned long l) | - | ||||||
| 540 | - | |||||||
| 541 | Writes then unsigned long integer, \a l, to the stream and returns a reference | - | ||||||
| 542 | to the stream. | - | ||||||
| 543 | */ | - | ||||||
| 544 | - | |||||||
| 545 | /*! | - | ||||||
| 546 | \fn QDebug &QDebug::operator<<(qint64 i) | - | ||||||
| 547 | - | |||||||
| 548 | Writes the signed 64-bit integer, \a i, to the stream and returns a reference | - | ||||||
| 549 | to the stream. | - | ||||||
| 550 | */ | - | ||||||
| 551 | - | |||||||
| 552 | /*! | - | ||||||
| 553 | \fn QDebug &QDebug::operator<<(quint64 i) | - | ||||||
| 554 | - | |||||||
| 555 | Writes then unsigned 64-bit integer, \a i, to the stream and returns a | - | ||||||
| 556 | reference to the stream. | - | ||||||
| 557 | */ | - | ||||||
| 558 | - | |||||||
| 559 | /*! | - | ||||||
| 560 | \fn QDebug &QDebug::operator<<(float f) | - | ||||||
| 561 | - | |||||||
| 562 | Writes the 32-bit floating point number, \a f, to the stream and returns a | - | ||||||
| 563 | reference to the stream. | - | ||||||
| 564 | */ | - | ||||||
| 565 | - | |||||||
| 566 | /*! | - | ||||||
| 567 | \fn QDebug &QDebug::operator<<(double f) | - | ||||||
| 568 | - | |||||||
| 569 | Writes the 64-bit floating point number, \a f, to the stream and returns a | - | ||||||
| 570 | reference to the stream. | - | ||||||
| 571 | */ | - | ||||||
| 572 | - | |||||||
| 573 | /*! | - | ||||||
| 574 | \fn QDebug &QDebug::operator<<(const char *s) | - | ||||||
| 575 | - | |||||||
| 576 | Writes the '\\0'-terminated string, \a s, to the stream and returns a | - | ||||||
| 577 | reference to the stream. The string is never quoted nor transformed to the | - | ||||||
| 578 | output, but note that some QDebug backends might not be 8-bit clean. | - | ||||||
| 579 | */ | - | ||||||
| 580 | - | |||||||
| 581 | /*! | - | ||||||
| 582 | \fn QDebug &QDebug::operator<<(const QString &s) | - | ||||||
| 583 | - | |||||||
| 584 | Writes the string, \a s, to the stream and returns a reference to the | - | ||||||
| 585 | stream. Normally, QDebug prints the string inside quotes and transforms | - | ||||||
| 586 | non-printable characters to their Unicode values (\\u1234). | - | ||||||
| 587 | - | |||||||
| 588 | To print non-printable characters without transformation, enable the | - | ||||||
| 589 | noquote() functionality. Note that some QDebug backends might not be 8-bit | - | ||||||
| 590 | clean. | - | ||||||
| 591 | - | |||||||
| 592 | Output examples: | - | ||||||
| 593 | \code | - | ||||||
| 594 | QString s; | - | ||||||
| 595 | - | |||||||
| 596 | s = "a"; | - | ||||||
| 597 | qDebug().noquote() << s; // prints: a | - | ||||||
| 598 | qDebug() << s; // prints: "a" | - | ||||||
| 599 | - | |||||||
| 600 | s = "\"a\r\n\""; | - | ||||||
| 601 | qDebug() << s; // prints: "\"a\r\n\"" | - | ||||||
| 602 | - | |||||||
| 603 | s = "\033"; // escape character | - | ||||||
| 604 | qDebug() << s; // prints: "\u001B" | - | ||||||
| 605 | - | |||||||
| 606 | s = "\u00AD"; // SOFT HYPHEN | - | ||||||
| 607 | qDebug() << s; // prints: "\u00AD" | - | ||||||
| 608 | - | |||||||
| 609 | s = "\u00E1"; // LATIN SMALL LETTER A WITH ACUTE | - | ||||||
| 610 | qDebug() << s; // prints: "á" | - | ||||||
| 611 | - | |||||||
| 612 | s = "a\u0301"; // "a" followed by COMBINING ACUTE ACCENT | - | ||||||
| 613 | qDebug() << s; // prints: "á"; | - | ||||||
| 614 | - | |||||||
| 615 | s = "\u0430\u0301"; // CYRILLIC SMALL LETTER A followed by COMBINING ACUTE ACCENT | - | ||||||
| 616 | qDebug() << s; // prints: "а́" | - | ||||||
| 617 | \endcode | - | ||||||
| 618 | */ | - | ||||||
| 619 | - | |||||||
| 620 | /*! | - | ||||||
| 621 | \fn QDebug &QDebug::operator<<(const QStringRef &s) | - | ||||||
| 622 | - | |||||||
| 623 | Writes the string, \a s, to the stream and returns a reference to the | - | ||||||
| 624 | stream. Normally, QDebug prints the string inside quotes and transforms | - | ||||||
| 625 | non-printable characters to their Unicode values (\\u1234). | - | ||||||
| 626 | - | |||||||
| 627 | To print non-printable characters without transformation, enable the | - | ||||||
| 628 | noquote() functionality. Note that some QDebug backends might not be 8-bit | - | ||||||
| 629 | clean. | - | ||||||
| 630 | - | |||||||
| 631 | See the QString overload for examples. | - | ||||||
| 632 | */ | - | ||||||
| 633 | - | |||||||
| 634 | /*! | - | ||||||
| 635 | \fn QDebug &QDebug::operator<<(QLatin1String s) | - | ||||||
| 636 | - | |||||||
| 637 | Writes the string, \a s, to the stream and returns a reference to the | - | ||||||
| 638 | stream. Normally, QDebug prints the string inside quotes and transforms | - | ||||||
| 639 | non-printable characters to their Unicode values (\\u1234). | - | ||||||
| 640 | - | |||||||
| 641 | To print non-printable characters without transformation, enable the | - | ||||||
| 642 | noquote() functionality. Note that some QDebug backends might not be 8-bit | - | ||||||
| 643 | clean. | - | ||||||
| 644 | - | |||||||
| 645 | See the QString overload for examples. | - | ||||||
| 646 | */ | - | ||||||
| 647 | - | |||||||
| 648 | /*! | - | ||||||
| 649 | \fn QDebug &QDebug::operator<<(const QByteArray &b) | - | ||||||
| 650 | - | |||||||
| 651 | Writes the byte array, \a b, to the stream and returns a reference to the | - | ||||||
| 652 | stream. Normally, QDebug prints the array inside quotes and transforms | - | ||||||
| 653 | control or non-US-ASCII characters to their C escape sequences (\\xAB). This | - | ||||||
| 654 | way, the output is always 7-bit clean and the string can be copied from the | - | ||||||
| 655 | output and pasted back into C++ sources, if necessary. | - | ||||||
| 656 | - | |||||||
| 657 | To print non-printable characters without transformation, enable the | - | ||||||
| 658 | noquote() functionality. Note that some QDebug backends might not be 8-bit | - | ||||||
| 659 | clean. | - | ||||||
| 660 | - | |||||||
| 661 | Output examples: | - | ||||||
| 662 | \code | - | ||||||
| 663 | QByteArray ba; | - | ||||||
| 664 | - | |||||||
| 665 | ba = "a"; | - | ||||||
| 666 | qDebug().noquote() << ba; // prints: a | - | ||||||
| 667 | qDebug() << ba; // prints: "a" | - | ||||||
| 668 | - | |||||||
| 669 | ba = "\"a\r\n\""; | - | ||||||
| 670 | qDebug() << ba; // prints: "\"a\r\n\"" | - | ||||||
| 671 | - | |||||||
| 672 | ba = "\033"; // escape character | - | ||||||
| 673 | qDebug() << ba; // prints: "\x1B" | - | ||||||
| 674 | - | |||||||
| 675 | ba = "\xC3\xA1"; | - | ||||||
| 676 | qDebug() << ba; // prints: "\xC3\xA1" | - | ||||||
| 677 | - | |||||||
| 678 | ba = QByteArray("a\0b", 3); | - | ||||||
| 679 | qDebug() << ba // prints: "\a\x00""b" | - | ||||||
| 680 | \endcode | - | ||||||
| 681 | - | |||||||
| 682 | Note how QDebug needed to close and reopen the string in the way C and C++ | - | ||||||
| 683 | languages concatenate string literals so that the letter 'b' is not | - | ||||||
| 684 | interpreted as part of the previous hexadecimal escape sequence. | - | ||||||
| 685 | */ | - | ||||||
| 686 | - | |||||||
| 687 | /*! | - | ||||||
| 688 | \fn QDebug &QDebug::operator<<(const void *p) | - | ||||||
| 689 | - | |||||||
| 690 | Writes a pointer, \a p, to the stream and returns a reference to the stream. | - | ||||||
| 691 | */ | - | ||||||
| 692 | - | |||||||
| 693 | /*! | - | ||||||
| 694 | \fn QDebug &QDebug::operator<<(QTextStreamFunction f) | - | ||||||
| 695 | \internal | - | ||||||
| 696 | */ | - | ||||||
| 697 | - | |||||||
| 698 | /*! | - | ||||||
| 699 | \fn QDebug &QDebug::operator<<(QTextStreamManipulator m) | - | ||||||
| 700 | \internal | - | ||||||
| 701 | */ | - | ||||||
| 702 | - | |||||||
| 703 | /*! | - | ||||||
| 704 | \fn QDebug operator<<(QDebug stream, const QList<T> &list) | - | ||||||
| 705 | \relates QDebug | - | ||||||
| 706 | - | |||||||
| 707 | Writes the contents of \a list to \a stream. \c T needs to | - | ||||||
| 708 | support streaming into QDebug. | - | ||||||
| 709 | */ | - | ||||||
| 710 | - | |||||||
| 711 | /*! | - | ||||||
| 712 | \fn QDebug operator<<(QDebug stream, const std::list<T, Alloc> &list) | - | ||||||
| 713 | \relates QDebug | - | ||||||
| 714 | \since 5.7 | - | ||||||
| 715 | - | |||||||
| 716 | Writes the contents of \a list to \a stream. \c T needs to | - | ||||||
| 717 | support streaming into QDebug. | - | ||||||
| 718 | */ | - | ||||||
| 719 | - | |||||||
| 720 | /*! | - | ||||||
| 721 | \fn QDebug operator<<(QDebug stream, const QVector<T> &vector) | - | ||||||
| 722 | \relates QDebug | - | ||||||
| 723 | - | |||||||
| 724 | Writes the contents of \a vector to \a stream. \c T needs to | - | ||||||
| 725 | support streaming into QDebug. | - | ||||||
| 726 | */ | - | ||||||
| 727 | - | |||||||
| 728 | /*! | - | ||||||
| 729 | \fn QDebug operator<<(QDebug stream, const std::vector<T, Alloc> &vector) | - | ||||||
| 730 | \relates QDebug | - | ||||||
| 731 | \since 5.7 | - | ||||||
| 732 | - | |||||||
| 733 | Writes the contents of \a vector to \a stream. \c T needs to | - | ||||||
| 734 | support streaming into QDebug. | - | ||||||
| 735 | */ | - | ||||||
| 736 | - | |||||||
| 737 | /*! | - | ||||||
| 738 | \fn QDebug operator<<(QDebug stream, const QSet<T> &set) | - | ||||||
| 739 | \relates QDebug | - | ||||||
| 740 | - | |||||||
| 741 | Writes the contents of \a set to \a stream. \c T needs to | - | ||||||
| 742 | support streaming into QDebug. | - | ||||||
| 743 | */ | - | ||||||
| 744 | - | |||||||
| 745 | /*! | - | ||||||
| 746 | \fn QDebug operator<<(QDebug stream, const QMap<Key, T> &map) | - | ||||||
| 747 | \relates QDebug | - | ||||||
| 748 | - | |||||||
| 749 | Writes the contents of \a map to \a stream. Both \c Key and | - | ||||||
| 750 | \c T need to support streaming into QDebug. | - | ||||||
| 751 | */ | - | ||||||
| 752 | - | |||||||
| 753 | /*! | - | ||||||
| 754 | \fn QDebug operator<<(QDebug stream, const std::map<Key, T, Compare, Alloc> &map) | - | ||||||
| 755 | \relates QDebug | - | ||||||
| 756 | \since 5.7 | - | ||||||
| 757 | - | |||||||
| 758 | Writes the contents of \a map to \a stream. Both \c Key and | - | ||||||
| 759 | \c T need to support streaming into QDebug. | - | ||||||
| 760 | */ | - | ||||||
| 761 | - | |||||||
| 762 | /*! | - | ||||||
| 763 | \fn QDebug operator<<(QDebug stream, const std::multimap<Key, T, Compare, Alloc> &map) | - | ||||||
| 764 | \relates QDebug | - | ||||||
| 765 | \since 5.7 | - | ||||||
| 766 | - | |||||||
| 767 | Writes the contents of \a map to \a stream. Both \c Key and | - | ||||||
| 768 | \c T need to support streaming into QDebug. | - | ||||||
| 769 | */ | - | ||||||
| 770 | - | |||||||
| 771 | /*! | - | ||||||
| 772 | \fn QDebug operator<<(QDebug stream, const QHash<Key, T> &hash) | - | ||||||
| 773 | \relates QDebug | - | ||||||
| 774 | - | |||||||
| 775 | Writes the contents of \a hash to \a stream. Both \c Key and | - | ||||||
| 776 | \c T need to support streaming into QDebug. | - | ||||||
| 777 | */ | - | ||||||
| 778 | - | |||||||
| 779 | /*! | - | ||||||
| 780 | \fn QDebug operator<<(QDebug stream, const QPair<T1, T2> &pair) | - | ||||||
| 781 | \relates QDebug | - | ||||||
| 782 | - | |||||||
| 783 | Writes the contents of \a pair to \a stream. Both \c T1 and | - | ||||||
| 784 | \c T2 need to support streaming into QDebug. | - | ||||||
| 785 | */ | - | ||||||
| 786 | - | |||||||
| 787 | /*! | - | ||||||
| 788 | \fn QDebug operator<<(QDebug stream, const QFlags<T> &flag) | - | ||||||
| 789 | \relates QDebug | - | ||||||
| 790 | \since 4.7 | - | ||||||
| 791 | - | |||||||
| 792 | Writes \a flag to \a stream. | - | ||||||
| 793 | */ | - | ||||||
| 794 | - | |||||||
| 795 | /*! | - | ||||||
| 796 | \fn QDebug operator<<(QDebug debug, const QSharedPointer<T> &ptr) | - | ||||||
| 797 | \relates QSharedPointer | - | ||||||
| 798 | \since 5.7 | - | ||||||
| 799 | - | |||||||
| 800 | Writes the pointer tracked by \a ptr into the debug object \a debug for | - | ||||||
| 801 | debugging purposes. | - | ||||||
| 802 | - | |||||||
| 803 | \sa {Debugging Techniques} | - | ||||||
| 804 | */ | - | ||||||
| 805 | - | |||||||
| 806 | /*! | - | ||||||
| 807 | \class QDebugStateSaver | - | ||||||
| 808 | \inmodule QtCore | - | ||||||
| 809 | \brief Convenience class for custom QDebug operators | - | ||||||
| 810 | - | |||||||
| 811 | Saves the settings used by QDebug, and restores them upon destruction, | - | ||||||
| 812 | then calls \l {QDebug::maybeSpace()}{maybeSpace()}, to separate arguments with a space if | - | ||||||
| 813 | \l {QDebug::autoInsertSpaces()}{autoInsertSpaces()} was true at the time of constructing the QDebugStateSaver. | - | ||||||
| 814 | - | |||||||
| 815 | The automatic insertion of spaces between writes is one of the settings | - | ||||||
| 816 | that QDebugStateSaver stores for the duration of the current block. | - | ||||||
| 817 | - | |||||||
| 818 | The settings of the internal QTextStream are also saved and restored, | - | ||||||
| 819 | so that using << hex in a QDebug operator doesn't affect other QDebug | - | ||||||
| 820 | operators. | - | ||||||
| 821 | - | |||||||
| 822 | \since 5.1 | - | ||||||
| 823 | */ | - | ||||||
| 824 | - | |||||||
| 825 | class QDebugStateSaverPrivate | - | ||||||
| 826 | { | - | ||||||
| 827 | public: | - | ||||||
| 828 | QDebugStateSaverPrivate(QDebug &dbg) | - | ||||||
| 829 | : m_dbg(dbg), | - | ||||||
| 830 | m_spaces(dbg.autoInsertSpaces()), | - | ||||||
| 831 | m_flags(0), | - | ||||||
| 832 | m_streamParams(dbg.stream->ts.d_ptr->params) | - | ||||||
| 833 | { | - | ||||||
| 834 | if (m_dbg.stream->context.version > 1) | - | ||||||
| 835 | m_flags = m_dbg.stream->flags; | - | ||||||
| 836 | } | - | ||||||
| 837 | void restoreState() | - | ||||||
| 838 | { | - | ||||||
| 839 | const bool currentSpaces = m_dbg.autoInsertSpaces(); | - | ||||||
| 840 | if (currentSpaces && !m_spaces) | - | ||||||
| 841 | if (m_dbg.stream->buffer.endsWith(QLatin1Char(' '))) | - | ||||||
| 842 | m_dbg.stream->buffer.chop(1); | - | ||||||
| 843 | - | |||||||
| 844 | m_dbg.setAutoInsertSpaces(m_spaces); | - | ||||||
| 845 | m_dbg.stream->ts.d_ptr->params = m_streamParams; | - | ||||||
| 846 | if (m_dbg.stream->context.version > 1) | - | ||||||
| 847 | m_dbg.stream->flags = m_flags; | - | ||||||
| 848 | - | |||||||
| 849 | if (!currentSpaces && m_spaces) | - | ||||||
| 850 | m_dbg.stream->ts << ' '; | - | ||||||
| 851 | } | - | ||||||
| 852 | - | |||||||
| 853 | QDebug &m_dbg; | - | ||||||
| 854 | - | |||||||
| 855 | // QDebug state | - | ||||||
| 856 | const bool m_spaces; | - | ||||||
| 857 | int m_flags; | - | ||||||
| 858 | - | |||||||
| 859 | // QTextStream state | - | ||||||
| 860 | const QTextStreamPrivate::Params m_streamParams; | - | ||||||
| 861 | }; | - | ||||||
| 862 | - | |||||||
| 863 | - | |||||||
| 864 | /*! | - | ||||||
| 865 | Creates a QDebugStateSaver instance, which saves the settings | - | ||||||
| 866 | currently used by \a dbg. | - | ||||||
| 867 | - | |||||||
| 868 | \sa QDebug::setAutoInsertSpaces(), QDebug::autoInsertSpaces() | - | ||||||
| 869 | */ | - | ||||||
| 870 | QDebugStateSaver::QDebugStateSaver(QDebug &dbg) | - | ||||||
| 871 | : d(new QDebugStateSaverPrivate(dbg)) | - | ||||||
| 872 | { | - | ||||||
| 873 | } | - | ||||||
| 874 | - | |||||||
| 875 | /*! | - | ||||||
| 876 | Destroys a QDebugStateSaver instance, which restores the settings | - | ||||||
| 877 | used when the QDebugStateSaver instance was created. | - | ||||||
| 878 | - | |||||||
| 879 | \sa QDebug::setAutoInsertSpaces(), QDebug::autoInsertSpaces() | - | ||||||
| 880 | */ | - | ||||||
| 881 | QDebugStateSaver::~QDebugStateSaver() | - | ||||||
| 882 | { | - | ||||||
| 883 | d->restoreState(); | - | ||||||
| 884 | } | - | ||||||
| 885 | - | |||||||
| 886 | /*! | - | ||||||
| 887 | \internal | - | ||||||
| 888 | - | |||||||
| 889 | Specialization of the primary template in qdebug.h to out-of-line | - | ||||||
| 890 | the common case of QFlags<T>::Int being int. | - | ||||||
| 891 | - | |||||||
| 892 | Just call the generic version so the two don't get out of sync. | - | ||||||
| 893 | */ | - | ||||||
| 894 | void qt_QMetaEnum_flagDebugOperator(QDebug &debug, size_t sizeofT, int value) | - | ||||||
| 895 | { | - | ||||||
| 896 | qt_QMetaEnum_flagDebugOperator<int>(debug, sizeofT, value); | - | ||||||
| 897 | } executed 13 times by 2 tests: end of blockExecuted by:
| 13 | ||||||
| 898 | - | |||||||
| 899 | #ifndef QT_NO_QOBJECT | - | ||||||
| 900 | /*! | - | ||||||
| 901 | \internal | - | ||||||
| 902 | */ | - | ||||||
| 903 | QDebug qt_QMetaEnum_debugOperator(QDebug &dbg, int value, const QMetaObject *meta, const char *name) | - | ||||||
| 904 | { | - | ||||||
| 905 | QDebugStateSaver saver(dbg); | - | ||||||
| 906 | QMetaEnum me = meta->enumerator(meta->indexOfEnumerator(name)); | - | ||||||
| 907 | const char *key = me.valueToKey(value); | - | ||||||
| 908 | dbg.nospace() << meta->className() << "::" << name << '('; | - | ||||||
| 909 | if (key) | - | ||||||
| 910 | dbg << key; | - | ||||||
| 911 | else | - | ||||||
| 912 | dbg << value; | - | ||||||
| 913 | dbg << ')'; | - | ||||||
| 914 | return dbg; | - | ||||||
| 915 | } | - | ||||||
| 916 | - | |||||||
| 917 | QDebug qt_QMetaEnum_flagDebugOperator(QDebug &debug, quint64 value, const QMetaObject *meta, const char *name) | - | ||||||
| 918 | { | - | ||||||
| 919 | QDebugStateSaver saver(debug); | - | ||||||
| 920 | debug.resetFormat(); | - | ||||||
| 921 | debug.noquote(); | - | ||||||
| 922 | debug.nospace(); | - | ||||||
| 923 | debug << "QFlags<"; | - | ||||||
| 924 | const QMetaEnum me = meta->enumerator(meta->indexOfEnumerator(name)); | - | ||||||
| 925 | if (const char *scope = me.scope()) | - | ||||||
| 926 | debug << scope << "::"; | - | ||||||
| 927 | debug << me.name() << ">(" << me.valueToKeys(value) << ')'; | - | ||||||
| 928 | return debug; | - | ||||||
| 929 | } | - | ||||||
| 930 | #endif // !QT_NO_QOBJECT | - | ||||||
| 931 | - | |||||||
| 932 | QT_END_NAMESPACE | - | ||||||
| Source code | Switch to Preprocessed file |