19#ifndef LIB_QUENTIER_UTILITY_PRINTABLE_H
20#define LIB_QUENTIER_UTILITY_PRINTABLE_H
22#include <quentier/utility/Linkage.h>
40 virtual QTextStream & print(QTextStream & strm)
const = 0;
42 virtual const QString toString()
const;
44 friend QUENTIER_EXPORT QTextStream & operator<<(
45 QTextStream & strm,
const Printable & printable);
47 friend QUENTIER_EXPORT QDebug & operator<<(
48 QDebug & debug,
const Printable & printable);
62const QString ToString(
const T &
object)
65 QTextStream strm(&str, QIODevice::WriteOnly);
70template <
class TKey,
class TValue>
71const QString ToString(
const QHash<TKey, TValue> &
object)
74 QTextStream strm(&str, QIODevice::WriteOnly);
75 strm << QStringLiteral(
"QHash: \n");
77 typedef typename QHash<TKey, TValue>::const_iterator CIter;
78 CIter hashEnd =
object.end();
79 for (CIter it =
object.begin(); it != hashEnd; ++it) {
80 strm << QStringLiteral(
"[") << it.key() << QStringLiteral(
"] = ")
81 << it.value() << QStringLiteral(
";\n");
87const QString ToString(
const QSet<T> &
object)
90 QTextStream strm(&str, QIODevice::WriteOnly);
91 strm << QStringLiteral(
"QSet: \n");
93 typedef typename QSet<T>::const_iterator CIter;
94 CIter setEnd =
object.end();
95 for (CIter it =
object.begin(); it != setEnd; ++it) {
96 strm << QStringLiteral(
"[") << *it << QStringLiteral(
"];\n");
101#define QUENTIER_DECLARE_PRINTABLE(type, ...) \
102 QUENTIER_EXPORT QTextStream & operator<<( \
103 QTextStream & strm, const type & obj); \
104 inline QDebug & operator<<(QDebug & debug, const type & obj) \
106 debug << ToString<type, ##__VA_ARGS__>(obj); \
The Printable class is the interface for Quentier's internal classes which should be able to write th...
Definition Printable.h:38