src/format.h

changeset 1380
bc799b965418
parent 1326
69a90bd2dba2
child 1403
7a2d84112983
equal deleted inserted replaced
1379:35811339ea72 1380:bc799b965418
143 void fprint (QIODevice& dev, QString fmtstr, Args... args) 143 void fprint (QIODevice& dev, QString fmtstr, Args... args)
144 { 144 {
145 formatHelper (fmtstr, args...); 145 formatHelper (fmtstr, args...);
146 dev.write (fmtstr.toUtf8()); 146 dev.write (fmtstr.toUtf8());
147 } 147 }
148
149 class Printer : public QObject
150 {
151 Q_OBJECT
152
153 public:
154 void printLine(const QString& line)
155 {
156 printf("%s\n", line.toUtf8().constData());
157 emit linePrinted(line);
158 }
159
160 signals:
161 void linePrinted(const QString& line);
162 };
163
164 /*
165 * Format and print the given args to stdout. Also is reflected to the status bar.
166 */
167 template<typename... Args>
168 void print(QString formatString, Args&&... args)
169 {
170 singleton<Printer>().printLine(format(formatString, args...));
171 }

mercurial