Wed, 05 Mar 2014 18:31:22 +0200
- changed doxygen entity style from @argh to \argh
645
c0708f2d22b3
- added license header to format.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
1 | /* |
c0708f2d22b3
- added license header to format.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
c0708f2d22b3
- added license header to format.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
3 | * Copyright (C) 2013, 2014 Santeri Piippo |
c0708f2d22b3
- added license header to format.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
4 | * |
c0708f2d22b3
- added license header to format.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
c0708f2d22b3
- added license header to format.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
c0708f2d22b3
- added license header to format.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
c0708f2d22b3
- added license header to format.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
8 | * (at your option) any later version. |
c0708f2d22b3
- added license header to format.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
9 | * |
c0708f2d22b3
- added license header to format.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
c0708f2d22b3
- added license header to format.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
c0708f2d22b3
- added license header to format.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
c0708f2d22b3
- added license header to format.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
13 | * GNU General Public License for more details. |
c0708f2d22b3
- added license header to format.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
14 | * |
c0708f2d22b3
- added license header to format.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
c0708f2d22b3
- added license header to format.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
c0708f2d22b3
- added license header to format.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
17 | */ |
c0708f2d22b3
- added license header to format.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
18 | |
644
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #pragma once |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include <QString> |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | #include "Types.h" |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | //! |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | //! Converts a given value into a string that can be retrieved with text(). |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | //! Used as the argument type to the formatting functions, hence its name. |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | //! |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | class StringFormatArg |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | { |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | public: |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | StringFormatArg (const QString& a) : m_text (a) {} |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | StringFormatArg (const char& a) : m_text (a) {} |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | StringFormatArg (const uchar& a) : m_text (a) {} |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | StringFormatArg (const QChar& a) : m_text (a) {} |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | StringFormatArg (int a) : m_text (QString::number (a)) {} |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | StringFormatArg (const float& a) : m_text (QString::number (a)) {} |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | StringFormatArg (const double& a) : m_text (QString::number (a)) {} |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | StringFormatArg (const Vertex& a) : m_text (a.toString (false)) {} |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | StringFormatArg (const Matrix& a) : m_text (a.toString()) {} |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | StringFormatArg (const char* a) : m_text (a) {} |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | StringFormatArg (const void* a) |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | { |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | m_text.sprintf ("%p", a); |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | } |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | template<typename T> |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | StringFormatArg (const QList<T>& a) |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | { |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | m_text = "{"; |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | for (const T& it : a) |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | { |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | if (&it != &a.first()) |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | m_text += ", "; |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | StringFormatArg arg (it); |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | m_text += arg.text(); |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | } |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | m_text += "}"; |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | } |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | inline QString text() const |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | { |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | return m_text; |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | } |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | private: |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | QString m_text; |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
70 | }; |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | //! |
650
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
73 | //! Helper function for \c format |
644
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | //! |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
75 | template<typename Arg1, typename... Rest> |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
76 | void formatHelper (QString& str, Arg1 arg1, Rest... rest) |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | { |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
78 | str = str.arg (StringFormatArg (arg1).text()); |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
79 | formatHelper (str, rest...); |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | } |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
81 | |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
82 | //! |
650
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
83 | //! Overload of \c formatHelper with no template args |
644
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | //! |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
85 | static void formatHelper (QString& str) __attribute__ ((unused)); |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | static void formatHelper (QString& str) |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
87 | { |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
88 | (void) str; |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | } |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
91 | //! |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | //! Format the message with the given args |
650
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
93 | //! \param fmtstr The string to format |
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
94 | //! \param args The args to format with |
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
95 | //! \return The formatted string |
644
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | //! |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | template<typename... Args> |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
98 | QString format (QString fmtstr, Args... args) |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
99 | { |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
100 | formatHelper (fmtstr, args...); |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
101 | return fmtstr; |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
102 | } |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 | |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | //! |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
105 | //! From MessageLog.cc - declared here so that I don't need to include |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
106 | //! MessageLog.h here. Prints the given message to log. |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
107 | //! |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
108 | void printToLog (const QString& msg); |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
109 | |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | //! |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
111 | //! Format and print the given args to the message log. |
650
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
112 | //! \param fmtstr The string to format |
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
113 | //! \param args The args to format with |
644
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | //! |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
115 | template<typename... Args> |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | void print (QString fmtstr, Args... args) |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
117 | { |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
118 | formatHelper (fmtstr, args...); |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
119 | printToLog (fmtstr); |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
120 | } |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
121 | |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
122 | //! |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
123 | //! Format and print the given args to the given file descriptor |
650
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
124 | //! \param fp The file descriptor to print to |
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
125 | //! \param fmtstr The string to format |
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
126 | //! \param args The args to format with |
644
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
127 | //! |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
128 | template<typename... Args> |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
129 | void fprint (FILE* fp, QString fmtstr, Args... args) |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
130 | { |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
131 | formatHelper (fmtstr, args...); |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
132 | fprintf (fp, "%s", qPrintable (fmtstr)); |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
133 | } |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
134 | |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
135 | //! |
650
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
136 | //! Overload of \c fprint with a QIODevice |
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
137 | //! \param dev The IO device to print to |
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
138 | //! \param fmtstr The string to format |
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
139 | //! \param args The args to format with |
644
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
140 | //! |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
141 | template<typename... Args> |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
142 | void fprint (QIODevice& dev, QString fmtstr, Args... args) |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
143 | { |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
144 | formatHelper (fmtstr, args...); |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
145 | dev.write (fmtstr.toUtf8()); |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
146 | } |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
147 | |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
148 | //! |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
149 | //! Exactly like print() except no-op in release builds. |
650
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
150 | //! \param fmtstr The string to format |
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
151 | //! \param args The args to format with |
644
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
152 | //! |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
153 | template<typename... Args> |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
154 | void dprint (QString fmtstr, Args... args) |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
155 | { |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
156 | #ifndef RELEASE |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
157 | formatHelper (fmtstr, args...); |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
158 | printToLog (fmtstr); |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
159 | #else |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
160 | (void) fmtstr; |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
161 | (void) args; |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
162 | #endif |
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
163 | } |