annotate base/Debug.h @ 1119:e22bfe8ca248 tonioni

fixes the problem that the last note was not exported to csv
author Matthias Mauch <mail@matthiasmauch.net>
date Fri, 14 Aug 2015 18:16:14 +0100
parents c1e43c8d2527
children 8f076d02569a
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@685 39 #ifndef NDEBUG
Chris@685 40
Chris@1061 41 class SVDebug {
Chris@1061 42 public:
Chris@1061 43 SVDebug();
Chris@1061 44 ~SVDebug();
Chris@1061 45
Chris@1061 46 template <typename T>
Chris@1061 47 inline SVDebug &operator<<(const T &t) {
Chris@1061 48 if (m_ok) {
Chris@1061 49 if (m_eol) {
Chris@1061 50 m_stream << m_prefix << " ";
Chris@1061 51 }
Chris@1061 52 m_stream << t;
Chris@1061 53 m_eol = false;
Chris@1061 54 }
Chris@1061 55 return *this;
Chris@1061 56 }
Chris@1061 57
Chris@1061 58 inline SVDebug &operator<<(QTextStreamFunction) {
Chris@1061 59 m_stream << std::endl;
Chris@1061 60 m_eol = true;
Chris@1061 61 return *this;
Chris@1061 62 }
Chris@1061 63
Chris@1061 64 private:
Chris@1061 65 std::fstream m_stream;
Chris@1061 66 char *m_prefix;
Chris@1061 67 bool m_ok;
Chris@1061 68 bool m_eol;
Chris@1061 69 };
Chris@1061 70
Chris@1061 71 extern SVDebug &getSVDebug();
Chris@685 72
Chris@690 73 #define SVDEBUG getSVDebug()
Chris@685 74
Chris@685 75 #else
Chris@685 76
Chris@685 77 class NoDebug
Chris@685 78 {
Chris@685 79 public:
Chris@685 80 inline NoDebug() {}
Chris@685 81 inline ~NoDebug(){}
Chris@685 82
Chris@685 83 template <typename T>
Chris@685 84 inline NoDebug &operator<<(const T &) { return *this; }
Chris@685 85
Chris@685 86 inline NoDebug &operator<<(QTextStreamFunction) { return *this; }
Chris@685 87 };
Chris@685 88
Chris@690 89 #define SVDEBUG NoDebug()
Chris@685 90
Chris@685 91 #endif /* !NDEBUG */
Chris@685 92
Chris@685 93 #endif /* !_DEBUG_H_ */
Chris@685 94