src/format.h

changeset 1217
314e12e23c3a
parent 1011
4fdd74a04790
child 1221
7f6715f08faf
--- a/src/format.h	Thu Jan 04 19:40:52 2018 +0200
+++ b/src/format.h	Thu Jan 04 19:44:26 2018 +0200
@@ -26,26 +26,26 @@
 class StringFormatArg
 {
 public:
-	StringFormatArg (const QString& a) : m_text (a) {}
-	StringFormatArg (char a) : m_text (a) {}
-	StringFormatArg (uchar a) : m_text (a) {}
-	StringFormatArg (QChar a) : m_text (a) {}
-	StringFormatArg (int a) : m_text (QString::number (a)) {}
-	StringFormatArg (long a) : m_text (QString::number (a)) {}
-	StringFormatArg (float a) : m_text (QString::number (a)) {}
-	StringFormatArg (double a) : m_text (QString::number (a)) {}
-	StringFormatArg (const Vertex& a) : m_text (a.toString()) {}
-	StringFormatArg (const Matrix& a) : m_text (a.toString()) {}
-	StringFormatArg (const char* a) : m_text (a) {}
-	StringFormatArg (LDColor a) : m_text (a.indexString()) {}
+	StringFormatArg(const QString& a) : m_text(a) {}
+	StringFormatArg(char a) : m_text(a) {}
+	StringFormatArg(uchar a) : m_text(a) {}
+	StringFormatArg(QChar a) : m_text(a) {}
+	StringFormatArg(int a) : m_text(QString::number(a)) {}
+	StringFormatArg(long a) : m_text(QString::number(a)) {}
+	StringFormatArg(float a) : m_text(QString::number(a)) {}
+	StringFormatArg(double a) : m_text(QString::number(a)) {}
+	StringFormatArg(const Vertex& a) : m_text(a.toString()) {}
+	StringFormatArg(const Matrix& a) : m_text(a.toString()) {}
+	StringFormatArg(const char* a) : m_text(a) {}
+	StringFormatArg(LDColor a) : m_text(a.indexString()) {}
 
-	StringFormatArg (const void* a)
+	StringFormatArg(const void* a)
 	{
-		m_text.sprintf ("%p", a);
+		m_text.sprintf("%p", a);
 	}
 
 	template<typename T>
-	StringFormatArg (const QList<T>& a)
+	StringFormatArg(const QList<T>& a)
 	{
 		m_text = "{";
 
@@ -54,7 +54,7 @@
 			if (&it != &a.first())
 				m_text += ", ";
 
-			StringFormatArg arg (it);
+			StringFormatArg arg(it);
 			m_text += arg.text();
 		}
 
@@ -73,15 +73,15 @@
 
 // Helper function for format()
 template<typename Arg1, typename... Rest>
-void formatHelper (QString& str, Arg1 arg1, Rest... rest)
+void formatHelper(QString& str, Arg1 arg1, Rest... rest)
 {
-	str = str.arg (StringFormatArg (arg1).text());
-	formatHelper (str, rest...);
+	str = str.arg(StringFormatArg(arg1).text());
+	formatHelper(str, rest...);
 }
 
 
-static void formatHelper (QString& str) __attribute__ ((unused));
-static void formatHelper (QString& str)
+static void formatHelper(QString& str) __attribute__((unused));
+static void formatHelper(QString& str)
 {
 	(void) str;
 }
@@ -92,49 +92,49 @@
 // The formatting ultimately uses String's arg() method to actually format the args so the format string should be
 // prepared accordingly, with %1 referring to the first arg, %2 to the second, etc.
 template<typename... Args>
-QString format (QString fmtstr, Args... args)
+QString format(QString fmtstr, Args... args)
 {
-	formatHelper (fmtstr, args...);
+	formatHelper(fmtstr, args...);
 	return fmtstr;
 }
 
 
 // From messageLog.cc - declared here so that I don't need to include messageLog.h here.
-void printToLog (const QString& msg);
+void printToLog(const QString& msg);
 
 
 // Format and print the given args to the message log.
 template<typename... Args>
-void print (QString fmtstr, Args... args)
+void print(QString fmtstr, Args... args)
 {
-	formatHelper (fmtstr, args...);
-	printToLog (fmtstr);
+	formatHelper(fmtstr, args...);
+	printToLog(fmtstr);
 }
 
 template<typename... Args>
-void fprint (FILE* fp, QString fmtstr, Args... args)
+void fprint(FILE* fp, QString fmtstr, Args... args)
 {
-	formatHelper (fmtstr, args...);
-	fprintf (fp, "%s", qPrintable (fmtstr));
+	formatHelper(fmtstr, args...);
+	fprintf(fp, "%s", qPrintable(fmtstr));
 }
 
 
 template<typename... Args>
-void fprint (QIODevice& dev, QString fmtstr, Args... args)
+void fprint(QIODevice& dev, QString fmtstr, Args... args)
 {
-	formatHelper (fmtstr, args...);
-	dev.write (fmtstr.toUtf8());
+	formatHelper(fmtstr, args...);
+	dev.write(fmtstr.toUtf8());
 }
 
 
 // Exactly like print() except no-op in release builds.
 template<typename... Args>
 #ifndef RELEASE
-void dprint (QString fmtstr, Args... args)
+void dprint(QString fmtstr, Args... args)
 {
-	formatHelper (fmtstr, args...);
-	printToLog (fmtstr);
+	formatHelper(fmtstr, args...);
+	printToLog(fmtstr);
 }
 #else
-void dprint (QString, Args...) {}
+void dprint(QString, Args...) {}
 #endif

mercurial