diff options
Diffstat (limited to 'lib/quotient_common.cpp')
-rw-r--r-- | lib/quotient_common.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/quotient_common.cpp b/lib/quotient_common.cpp new file mode 100644 index 00000000..5d7a3027 --- /dev/null +++ b/lib/quotient_common.cpp @@ -0,0 +1,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) << ")"; +} |