Engauge Digitizer 2
Loading...
Searching...
No Matches
Compatibility.cpp
Go to the documentation of this file.
1/******************************************************************************************************
2 * (C) 2020 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3 * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4 * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5 ******************************************************************************************************/
6
7#include "Compatibility.h"
8#include "Logger.h"
9#include <QTextStream>
10#include <QtGlobal>
11
12using namespace std;
13
17
18QTextStream &Compatibility::endl (QTextStream &str)
19{
20 LOG4CPP_INFO_S ((*mainCat)) << "Compatibility::endl";
21
22 // Comments:
23 // 1) QTextStream in text mode uses \n\r for carriage return
24 // 2) \n by itself does not flush
25 // 3) \n by itself could be safely used wherever this method is used, but this method has nice comments
26 // and the performance gain from skipping the flush that end() adds is insignificant
27
28#if QT_VERSION < QT_VERSION_CHECK (5, 14, 0)
29 str << "\n"; // std::endl will not compile
30#else
31 str << Qt::endl; // Enum
32#endif
33
34 return str;
35}
36
37QTextStream &Compatibility::flush (QTextStream &str)
38{
39
40#if QT_VERSION < QT_VERSION_CHECK (5, 14, 0)
41 // std::flush will not compile so we skip flushing
42#else
43 str << Qt::flush; // Enum
44#endif
45
46 return str;
47}
48
49#if QT_VERSION < QT_VERSION_CHECK (5, 14, 0)
50QString::SplitBehavior Compatibility::SkipEmptyParts ()
51{
52 return QString::SkipEmptyParts;
53}
54#else
56{
57 return Qt::SkipEmptyParts;
58}
59#endif
log4cpp::Category * mainCat
Definition Logger.cpp:14
Compatibility()
Single default constructor.
static QTextStream & endl(QTextStream &stream)
End of line.
static Qt::SplitBehavior SkipEmptyParts()
SplitBehavior.
static QTextStream & flush(QTextStream &stream)
Flush.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18