21 #include <quentier/utility/Linkage.h> 28 #include <QTextStream> 42 virtual QTextStream & print(QTextStream & strm)
const = 0;
44 [[nodiscard]] QString toString()
const;
46 friend QUENTIER_EXPORT QTextStream & operator<<(
47 QTextStream & strm,
const Printable & printable);
49 friend QUENTIER_EXPORT QDebug & operator<<(
50 QDebug & debug,
const Printable & printable);
58 [[nodiscard]] QString ToString(
const T &
object)
61 QTextStream strm(&str, QIODevice::WriteOnly);
66 template <
class TKey,
class TValue>
67 [[nodiscard]] QString ToString(
const QHash<TKey, TValue> &
object)
70 QTextStream strm(&str, QIODevice::WriteOnly);
71 strm << QStringLiteral(
"QHash: \n");
73 using CIter =
typename QHash<TKey, TValue>::const_iterator;
74 CIter hashEnd =
object.end();
75 for (CIter it =
object.begin(); it != hashEnd; ++it) {
76 strm << QStringLiteral(
"[") << it.key() << QStringLiteral(
"] = ")
77 << it.value() << QStringLiteral(
";\n");
83 [[nodiscard]] QString ToString(
const QSet<T> &
object)
86 QTextStream strm(&str, QIODevice::WriteOnly);
87 strm << QStringLiteral(
"QSet: \n");
89 using CIter =
typename QSet<T>::const_iterator;
90 CIter setEnd =
object.end();
91 for (CIter it =
object.begin(); it != setEnd; ++it) {
92 strm << QStringLiteral(
"[") << *it << QStringLiteral(
"];\n");
97 #define QUENTIER_DECLARE_PRINTABLE(type, ...) \ 98 QUENTIER_EXPORT QTextStream & operator<<( \ 99 QTextStream & strm, const type & obj); \ 100 inline QDebug & operator<<(QDebug & debug, const type & obj) \ 102 debug << ToString<type, ##__VA_ARGS__>(obj); \ 105 // QUENTIER_DECLARE_PRINTABLE The Printable class is the interface for Quentier's internal classes which should be able to write th...
Definition: Printable.h:37
Definition: ApplicationSettings.h:27