Wed, 12 Mar 2014 16:20:40 +0200
- added a long int overload to StringFormatArg
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 | |
651
747e84062279
- doxygenified Version.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
650
diff
changeset
|
23 | //! \file Format.h |
747e84062279
- doxygenified Version.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
650
diff
changeset
|
24 | //! Contains string formatting-related functions and classes. |
747e84062279
- doxygenified Version.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
650
diff
changeset
|
25 | |
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
|
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 | //! 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
|
28 | //! 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
|
29 | //! |
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 | 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
|
31 | { |
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 | 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
|
33 | 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
|
34 | 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
|
35 | 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
|
36 | 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
|
37 | StringFormatArg (int a) : m_text (QString::number (a)) {} |
654
a74f2ff353b8
- added a long int overload to StringFormatArg
Santeri Piippo <crimsondusk64@gmail.com>
parents:
651
diff
changeset
|
38 | StringFormatArg (long a) : m_text (QString::number (a)) {} |
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
|
39 | 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
|
40 | 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
|
41 | 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
|
42 | 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
|
43 | 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
|
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 | 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
|
46 | { |
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 | 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
|
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 | |
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 | 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
|
51 | 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
|
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 | 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
|
54 | |
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 | 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
|
56 | { |
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 | 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
|
58 | 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
|
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 | 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
|
61 | 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
|
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 | |
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 | 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
|
65 | } |
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 | 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
|
68 | { |
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 | 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
|
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 | 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
|
73 | 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
|
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 | |
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 | //! |
650
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
77 | //! 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
|
78 | //! |
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 | 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
|
80 | 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
|
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 | 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
|
83 | 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
|
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 | |
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 | //! |
651
747e84062279
- doxygenified Version.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
650
diff
changeset
|
87 | //! 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
|
88 | //! |
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 | 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
|
90 | 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
|
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 | (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
|
93 | } |
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
|
94 | |
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
|
95 | //! |
651
747e84062279
- doxygenified Version.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
650
diff
changeset
|
96 | //! @brief Format the message with the given args. |
747e84062279
- doxygenified Version.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
650
diff
changeset
|
97 | //! |
747e84062279
- doxygenified Version.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
650
diff
changeset
|
98 | //! The formatting ultimately uses QString's arg() method to actually format |
747e84062279
- doxygenified Version.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
650
diff
changeset
|
99 | //! the args so the format string should be prepared accordingly, with %1 |
747e84062279
- doxygenified Version.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
650
diff
changeset
|
100 | //! referring to the first arg, %2 to the second, etc. |
747e84062279
- doxygenified Version.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
650
diff
changeset
|
101 | //! |
650
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
102 | //! \param fmtstr The string to format |
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
103 | //! \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
|
104 | //! \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
|
105 | //! |
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 | 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
|
107 | 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
|
108 | { |
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 | 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
|
110 | 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
|
111 | } |
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
|
112 | |
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
|
113 | //! |
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 | //! 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
|
115 | //! 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
|
116 | //! |
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 | 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
|
118 | |
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 | //! |
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 | //! 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
|
121 | //! \param fmtstr The string to format |
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
122 | //! \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
|
123 | //! |
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
|
124 | 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
|
125 | 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
|
126 | { |
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 | 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
|
128 | 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
|
129 | } |
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 | //! |
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 | //! 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
|
133 | //! \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
|
134 | //! \param fmtstr The string to format |
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
135 | //! \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
|
136 | //! |
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
|
137 | 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
|
138 | 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
|
139 | { |
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 | 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
|
141 | 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
|
142 | } |
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 | //! |
650
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
145 | //! 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
|
146 | //! \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
|
147 | //! \param fmtstr The string to format |
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
148 | //! \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
|
149 | //! |
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
|
150 | 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
|
151 | 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
|
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 | 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
|
154 | 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
|
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 | |
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 | //! |
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 | //! 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
|
159 | //! \param fmtstr The string to format |
db7146a87ae4
- changed doxygen entity style from @argh to \argh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
645
diff
changeset
|
160 | //! \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
|
161 | //! |
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 | 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
|
163 | 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
|
164 | { |
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
|
165 | #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
|
166 | 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
|
167 | 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
|
168 | #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
|
169 | (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
|
170 | (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
|
171 | #endif |
654
a74f2ff353b8
- added a long int overload to StringFormatArg
Santeri Piippo <crimsondusk64@gmail.com>
parents:
651
diff
changeset
|
172 | } |