Mercurial > hg > svcore
annotate base/Debug.h @ 1267:1d8418cca63a 3.0-integration
Further column op tests and fixes
author | Chris Cannam |
---|---|
date | Thu, 17 Nov 2016 14:46:03 +0000 |
parents | 8f076d02569a |
children | ad2d3e0a8b7c |
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@1061 | 16 #ifndef SV_DEBUG_H |
Chris@1061 | 17 #define SV_DEBUG_H |
Chris@685 | 18 |
Chris@685 | 19 #include <QDebug> |
Chris@685 | 20 #include <QTextStream> |
Chris@843 | 21 |
Chris@1042 | 22 #include "RealTime.h" |
Chris@871 | 23 |
Chris@685 | 24 #include <string> |
Chris@685 | 25 #include <iostream> |
Chris@1061 | 26 #include <fstream> |
Chris@685 | 27 |
Chris@685 | 28 class QString; |
Chris@685 | 29 class QUrl; |
Chris@685 | 30 |
Chris@685 | 31 QDebug &operator<<(QDebug &, const std::string &); |
Chris@685 | 32 std::ostream &operator<<(std::ostream &, const QString &); |
Chris@685 | 33 std::ostream &operator<<(std::ostream &, const QUrl &); |
Chris@685 | 34 |
Chris@843 | 35 using std::cout; |
Chris@843 | 36 using std::cerr; |
Chris@843 | 37 using std::endl; |
Chris@843 | 38 |
Chris@1061 | 39 class SVDebug { |
Chris@1061 | 40 public: |
Chris@1061 | 41 SVDebug(); |
Chris@1061 | 42 ~SVDebug(); |
Chris@1061 | 43 |
Chris@1061 | 44 template <typename T> |
Chris@1061 | 45 inline SVDebug &operator<<(const T &t) { |
Chris@1061 | 46 if (m_ok) { |
Chris@1061 | 47 if (m_eol) { |
Chris@1061 | 48 m_stream << m_prefix << " "; |
Chris@1061 | 49 } |
Chris@1061 | 50 m_stream << t; |
Chris@1061 | 51 m_eol = false; |
Chris@1061 | 52 } |
Chris@1061 | 53 return *this; |
Chris@1061 | 54 } |
Chris@1061 | 55 |
Chris@1061 | 56 inline SVDebug &operator<<(QTextStreamFunction) { |
Chris@1061 | 57 m_stream << std::endl; |
Chris@1061 | 58 m_eol = true; |
Chris@1061 | 59 return *this; |
Chris@1061 | 60 } |
Chris@1061 | 61 |
Chris@1061 | 62 private: |
Chris@1061 | 63 std::fstream m_stream; |
Chris@1061 | 64 char *m_prefix; |
Chris@1061 | 65 bool m_ok; |
Chris@1061 | 66 bool m_eol; |
Chris@1061 | 67 }; |
Chris@1061 | 68 |
Chris@1061 | 69 extern SVDebug &getSVDebug(); |
Chris@685 | 70 |
Chris@690 | 71 #define SVDEBUG getSVDebug() |
Chris@685 | 72 |
Chris@685 | 73 #endif /* !_DEBUG_H_ */ |
Chris@685 | 74 |