comparison debug.h @ 57:f583e44d9d31

* Update copyrights; add debug header
author Chris Cannam
date Tue, 16 Nov 2010 13:57:30 +0000
parents
children 8fd71f570884
comparison
equal deleted inserted replaced
56:1394c8cbf991 57:f583e44d9d31
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 EasyMercurial
5
6 Based on HgExplorer by Jari Korhonen
7 Copyright (c) 2010 Jari Korhonen
8 Copyright (c) 2010 Chris Cannam
9 Copyright (c) 2010 Queen Mary, University of London
10
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License as
13 published by the Free Software Foundation; either version 2 of the
14 License, or (at your option) any later version. See the file
15 COPYING included with this distribution for more information.
16 */
17
18 #ifndef _DEBUG_H_
19 #define _DEBUG_H_
20
21 #include <QDebug>
22 #include <QTextStream>
23 #include <string>
24 #include <iostream>
25
26 class QString;
27 class QUrl;
28
29 QDebug &operator<<(QDebug &, const std::string &);
30 std::ostream &operator<<(std::ostream &, const QString &);
31 std::ostream &operator<<(std::ostream &, const QUrl &);
32
33 #ifndef NDEBUG
34
35 extern QDebug &getEasyHgDebug();
36
37 #define DEBUG getEasyHgDebug()
38
39 template <typename T>
40 inline QDebug &operator<<(QDebug &d, const T &t) {
41 QString s;
42 QTextStream ts(&s);
43 ts << t;
44 d << s;
45 return d;
46 }
47
48 #else
49
50 class NoDebug
51 {
52 public:
53 inline NoDebug() {}
54 inline ~NoDebug(){}
55
56 template <typename T>
57 inline NoDebug &operator<<(const T &) { return *this; }
58
59 inline NoDebug &operator<<(QTextStreamFunction) { return *this; }
60 };
61
62 #define DEBUG NoDebug()
63
64 #endif /* !NDEBUG */
65
66 #endif /* !_DEBUG_H_ */
67