- Timestamp:
- Feb 26, 2010, 12:29:07 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/corelib/io/qdebug.h
r561 r604 255 255 } 256 256 257 template <class T> 258 struct QDebugFmt 259 { 260 QDebugFmt(const char *fmt, const T &val) : format(fmt), value(val) {}; 261 const char *format; 262 const T &value; 263 }; 264 265 template <class T> 266 inline QDebugFmt<T> qDebugFmt(const char *fmt, const T &val) 267 { 268 return QDebugFmt<T>(fmt, val); 269 } 270 271 inline QDebugFmt<char> qDebugFmtHex(const char &val) { return qDebugFmt("0x%02X", val); } 272 inline QDebugFmt<char> qDebugFmtHex(const uchar &val) { return qDebugFmtHex(reinterpret_cast<const char &>(val)); } 273 inline QDebugFmt<short> qDebugFmtHex(const short &val) { return qDebugFmt("0x%04X", val); } 274 inline QDebugFmt<short> qDebugFmtHex(const ushort &val) { return qDebugFmtHex(reinterpret_cast<const short &>(val)); } 275 inline QDebugFmt<int> qDebugFmtHex(const int &val) { return qDebugFmt("0x%08X", val); } 276 inline QDebugFmt<int> qDebugFmtHex(const uint &val) { return qDebugFmtHex(reinterpret_cast<const int &>(val)); } 277 inline QDebugFmt<long> qDebugFmtHex(const long &val) { return qDebugFmt("0x%08lX", val); } 278 inline QDebugFmt<long> qDebugFmtHex(const ulong &val) { return qDebugFmtHex(reinterpret_cast<const long &>(val)); } 279 280 #if defined(FORCE_UREF) 281 template <class T> 282 inline QDebug &operator<<(QDebug debug, const QDebugFmt<T> &fmt) 283 #else 284 template <class T> 285 inline QDebug operator<<(QDebug debug, const QDebugFmt<T> &fmt) 286 #endif 287 { 288 debug << QString().sprintf(fmt.format, fmt.value).toAscii().constData(); 289 return debug; 290 } 291 257 292 #if !defined(QT_NO_DEBUG_STREAM) 258 293 Q_CORE_EXPORT_INLINE QDebug qDebug() { return QDebug(QtDebugMsg); }
Note:
See TracChangeset
for help on using the changeset viewer.