6#include <QtCore/QDebug>
14
15
16
17
18
19
20
23
24
25
26
27
28
29
30
33
34
35
36
37
38
39
40
43
44
45
46
51 writer([&d](QStringView s){ d << s; });
57
58
59
60
61
62
67 for (
int it = 0; it < s.size();++it) {
69 bool noslash = c != QLatin1Char(
'\\');
70 bool noquote = c != QLatin1Char(
'"');
71 bool nonewline = c != QLatin1Char(
'\n');
72 bool noreturn = c != QLatin1Char(
'\r');
73 if (noslash && noquote && nonewline && noreturn)
75 sink(s.mid(it0, it - it0));
88 sink(s.mid(it0, s.size() - it0));
94
95
96
97
98
123 QDebug & d = debug.noquote().nospace();
124 dumper([&d](QStringView s){
130
131
132
133
134
137 QDebug d = qDebug().noquote().nospace();
142 d = qInfo().noquote().nospace();
145 d = qWarning().noquote().nospace();
149 d = qCritical().noquote().nospace();
152 dumper([&d](QStringView s){
158
159
160
164 QStringView spaces = u" ";
165 while (indent > spaces.size()) {
167 indent -= spaces.size();
169 s(spaces.left(indent));
174
175
176
181 sinkIndent(s, indent);
185
186
187
188
192 QDebug dd = d.noquote().nospace();
193 dumper([&dd](QStringView s) { dd << s; });
Helper class to accept eithe a string or a dumper (a function that writes to a sink)
QMLDOM_EXPORT void dumperToQDebug(const Dumper &dumper, QDebug debug)
QMLDOM_EXPORT void dumpErrorLevel(const Sink &s, ErrorLevel level)
Dumps a string describing the given error level (ErrorLevel::Error -> Error,...)
QMLDOM_EXPORT void dumperToQDebug(const Dumper &dumper, ErrorLevel level=ErrorLevel::Debug)
writes the dumper to the QDebug object corrsponding to the given error level
QMLDOM_EXPORT void sinkNewline(const Sink &s, int indent=0)
sinks a neline and indents by the given amount
QMLDOM_EXPORT QDebug operator<<(QDebug d, const Dumper &dumper)
QMLDOM_EXPORT void sinkIndent(const Sink &s, int indent)
sinks the requested amount of spaces
QMLDOM_EXPORT void sinkEscaped(const Sink &sink, QStringView s, EscapeOptions options=EscapeOptions::OuterQuotes)
dumps a string as quoted string (escaping things like quotes or newlines)
QMLDOM_EXPORT QString dumperToString(const Dumper &writer)
Converts a dumper to a string.