Chris@57: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@57: Chris@57: /* Chris@57: EasyMercurial Chris@57: Chris@57: Based on HgExplorer by Jari Korhonen Chris@57: Copyright (c) 2010 Jari Korhonen Chris@244: Copyright (c) 2011 Chris Cannam Chris@244: Copyright (c) 2011 Queen Mary, University of London Chris@57: Chris@57: This program is free software; you can redistribute it and/or Chris@57: modify it under the terms of the GNU General Public License as Chris@57: published by the Free Software Foundation; either version 2 of the Chris@57: License, or (at your option) any later version. See the file Chris@57: COPYING included with this distribution for more information. Chris@57: */ Chris@57: Chris@57: #ifndef _DEBUG_H_ Chris@57: #define _DEBUG_H_ Chris@57: Chris@57: #include Chris@57: #include Chris@57: #include Chris@57: #include Chris@57: Chris@57: class QString; Chris@57: class QUrl; Chris@57: Chris@57: QDebug &operator<<(QDebug &, const std::string &); Chris@57: std::ostream &operator<<(std::ostream &, const QString &); Chris@57: std::ostream &operator<<(std::ostream &, const QUrl &); Chris@57: Chris@57: #ifndef NDEBUG Chris@57: Chris@57: extern QDebug &getEasyHgDebug(); Chris@57: Chris@57: #define DEBUG getEasyHgDebug() Chris@57: Chris@57: template Chris@57: inline QDebug &operator<<(QDebug &d, const T &t) { Chris@57: QString s; Chris@57: QTextStream ts(&s); Chris@57: ts << t; Chris@57: d << s; Chris@57: return d; Chris@57: } Chris@57: Chris@57: #else Chris@57: Chris@57: class NoDebug Chris@57: { Chris@57: public: Chris@57: inline NoDebug() {} Chris@57: inline ~NoDebug(){} Chris@57: Chris@57: template Chris@57: inline NoDebug &operator<<(const T &) { return *this; } Chris@57: Chris@57: inline NoDebug &operator<<(QTextStreamFunction) { return *this; } Chris@57: }; Chris@57: Chris@57: #define DEBUG NoDebug() Chris@57: Chris@57: #endif /* !NDEBUG */ Chris@57: Chris@57: #endif /* !_DEBUG_H_ */ Chris@57: