annotate base/Debug.h @ 700:5117d7cf59ec

Merge
author Chris Cannam
date Wed, 17 Aug 2011 22:14:52 +0100
parents 1424aa29ae95
children e802e550a1f2
rev   line source
Chris@685 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@685 2
Chris@685 3 /*
Chris@685 4 Sonic Visualiser
Chris@685 5 An audio file viewer and annotation editor.
Chris@685 6 Centre for Digital Music, Queen Mary, University of London.
Chris@685 7 This file copyright 2010-2011 Chris Cannam and QMUL.
Chris@685 8
Chris@685 9 This program is free software; you can redistribute it and/or
Chris@685 10 modify it under the terms of the GNU General Public License as
Chris@685 11 published by the Free Software Foundation; either version 2 of the
Chris@685 12 License, or (at your option) any later version. See the file
Chris@685 13 COPYING included with this distribution for more information.
Chris@685 14 */
Chris@685 15
Chris@685 16 #ifndef _DEBUG_H_
Chris@685 17 #define _DEBUG_H_
Chris@685 18
Chris@685 19 #include <QDebug>
Chris@685 20 #include <QTextStream>
Chris@685 21 #include <string>
Chris@685 22 #include <iostream>
Chris@685 23
Chris@685 24 class QString;
Chris@685 25 class QUrl;
Chris@685 26
Chris@685 27 QDebug &operator<<(QDebug &, const std::string &);
Chris@685 28 std::ostream &operator<<(std::ostream &, const QString &);
Chris@685 29 std::ostream &operator<<(std::ostream &, const QUrl &);
Chris@685 30
Chris@685 31 #ifndef NDEBUG
Chris@685 32
Chris@685 33 extern QDebug &getSVDebug();
Chris@685 34
Chris@690 35 #define SVDEBUG getSVDebug()
Chris@685 36
Chris@685 37 template <typename T>
Chris@685 38 inline QDebug &operator<<(QDebug &d, const T &t) {
Chris@685 39 QString s;
Chris@685 40 QTextStream ts(&s);
Chris@685 41 ts << t;
Chris@685 42 d << s;
Chris@685 43 return d;
Chris@685 44 }
Chris@685 45
Chris@685 46 #else
Chris@685 47
Chris@685 48 class NoDebug
Chris@685 49 {
Chris@685 50 public:
Chris@685 51 inline NoDebug() {}
Chris@685 52 inline ~NoDebug(){}
Chris@685 53
Chris@685 54 template <typename T>
Chris@685 55 inline NoDebug &operator<<(const T &) { return *this; }
Chris@685 56
Chris@685 57 inline NoDebug &operator<<(QTextStreamFunction) { return *this; }
Chris@685 58 };
Chris@685 59
Chris@690 60 #define SVDEBUG NoDebug()
Chris@685 61
Chris@685 62 #endif /* !NDEBUG */
Chris@685 63
Chris@685 64 #endif /* !_DEBUG_H_ */
Chris@685 65