Add a flag to enable Qt deprecation warnings on Qt < 5.13
[quassel.git] / src / test / global / printers.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005-2019 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) version 3.                                           *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
19  ***************************************************************************/
20
21 #include "printers.h"
22
23 #include <QDebug>
24
25 namespace {
26
27 template<typename T>
28 void debugOut(const T& value, ::std::ostream* os)
29 {
30     // Just use Qt's own debug print support to print the value into a string
31     QString out;
32     QDebug dbg(&out);
33     dbg.nospace() << value;
34     *os << out.toStdString();
35 }
36
37 }  // anon
38
39 void PrintTo(const QByteArray& value, std::ostream* os)
40 {
41     debugOut(value, os);
42 }
43
44 void PrintTo(const QDateTime& value, std::ostream* os)
45 {
46     debugOut(value, os);
47 }
48
49 void PrintTo(const QString& value, std::ostream* os)
50 {
51     debugOut(value, os);
52 }
53
54 void PrintTo(const QVariant& value, std::ostream* os)
55 {
56     debugOut(value, os);
57 }
58
59 void PrintTo(const QVariantList& value, std::ostream* os)
60 {
61     debugOut(value, os);
62 }
63
64 void PrintTo(const QVariantMap& value, std::ostream* os)
65 {
66     debugOut(value, os);
67 }