aboutsummaryrefslogtreecommitdiff
path: root/lib/quotient_common.cpp
blob: 5d7a3027e109dc0c0a17b40561753198f925447b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "quotient_common.h"

#include <QtCore/QDebug>

using namespace Quotient;

template <typename Enum>
inline QDebug suppressScopeAndDump(QDebug dbg, Enum e)
{
    // Suppress "Quotient::" prefix
    QDebugStateSaver _dss(dbg);
    dbg.setVerbosity(0 /* QDebug::MinimumVerbosity since Qt 5.13 */);
    return qt_QMetaEnum_debugOperator(dbg, std::underlying_type_t<Enum>(e),
                                      qt_getEnumMetaObject(e),
                                      qt_getEnumName(e));
}

template <typename Enum>
inline QDebug suppressScopeAndDump(QDebug dbg, const QFlags<Enum>& f)
{
    // Suppress "Quotient::" prefix
    QDebugStateSaver _dss(dbg);
    dbg.setVerbosity(0 /* QDebug::MinimumVerbosity since Qt 5.13 */);
    return qt_QMetaEnum_flagDebugOperator_helper(dbg, f);
}

QDebug operator<<(QDebug dbg, Membership m)
{
    return suppressScopeAndDump(dbg, m);
}

QDebug operator<<(QDebug dbg, MembershipMask mm)
{
    return suppressScopeAndDump(dbg, mm) << ")";
}

QDebug operator<<(QDebug dbg, JoinState js)
{
    return suppressScopeAndDump(dbg, js);
}

QDebug operator<<(QDebug dbg, JoinStates jss)
{
    return suppressScopeAndDump(dbg, jss) << ")";
}