14 * |
14 * |
15 * You should have received a copy of the GNU General Public License |
15 * You should have received a copy of the GNU General Public License |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 */ |
17 */ |
18 |
18 |
19 #ifndef TYPES_H |
19 #ifndef LDFORGE_TYPES_H |
20 #define TYPES_H |
20 #define LDFORGE_TYPES_H |
21 |
21 |
22 #include <QString> |
22 #include <QString> |
23 #include <QObject> |
23 #include <QObject> |
24 #include <deque> |
24 #include <deque> |
25 #include "common.h" |
25 #include "common.h" |
26 |
26 |
27 class LDObject; |
27 class LDObject; |
28 |
28 |
29 typedef QChar qchar; |
|
30 typedef QString str; |
|
31 class StringConfig; |
29 class StringConfig; |
32 class IntConfig; |
30 class IntConfig; |
33 class FloatConfig; |
31 class FloatConfig; |
34 class QFile; |
32 class QFile; |
35 class QTextStream; |
33 class QTextStream; |
36 |
34 |
37 typedef unsigned int uint; |
35 using str = QString; |
38 typedef unsigned short ushort; |
36 using int8 = qint8; |
39 typedef unsigned long ulong; |
37 using int16 = qint16; |
40 typedef qint8 int8; |
38 using int32 = qint32; |
41 typedef qint16 int16; |
39 using int64 = qint64; |
42 typedef qint32 int32; |
40 using uint8 = quint8; |
43 typedef qint64 int64; |
41 using uint16 = quint16; |
44 typedef quint8 uint8; |
42 using uint32 = quint32; |
45 typedef quint16 uint16; |
43 using uint64 = quint64; |
46 typedef quint32 uint32; |
44 |
47 typedef quint64 uint64; |
45 template<class T> |
48 |
46 using initlist = std::initializer_list<T>; |
49 template<class T> using initlist = std::initializer_list<T>; |
47 |
50 template<class T, class R> using pair = std::pair<T, R>; |
48 template<class T, class R> |
51 using std::size_t; |
49 using pair = std::pair<T, R>; |
52 |
50 |
53 enum Axis { X, Y, Z }; |
51 enum Axis { X, Y, Z }; |
54 static const Axis g_Axes[3] = { X, Y, Z }; |
52 static const Axis g_Axes[3] = { X, Y, Z }; |
55 |
53 |
56 // ============================================================================= |
54 // ============================================================================= |
65 matrix() {} |
63 matrix() {} |
66 matrix (initlist<double> vals); |
64 matrix (initlist<double> vals); |
67 matrix (double fillval); |
65 matrix (double fillval); |
68 matrix (double vals[]); |
66 matrix (double vals[]); |
69 |
67 |
70 double determinant () const; |
68 double getDeterminant() const; |
71 matrix mult (matrix other) const; |
69 matrix mult (matrix other) const; |
72 void puts () const; |
70 void puts() const; |
73 str stringRep () const; |
71 str stringRep() const; |
74 void zero (); |
72 void zero(); |
75 matrix& operator= (matrix other); |
73 matrix& operator= (matrix other); |
76 |
74 |
77 inline double& val (int idx) |
75 inline double& val (int idx) |
78 { return m_vals[idx]; |
76 { return m_vals[idx]; |
79 } |
77 } |
80 |
78 |
177 class StringFormatArg |
176 class StringFormatArg |
178 { public: |
177 { public: |
179 StringFormatArg (const str& v); |
178 StringFormatArg (const str& v); |
180 StringFormatArg (const char& v); |
179 StringFormatArg (const char& v); |
181 StringFormatArg (const uchar& v); |
180 StringFormatArg (const uchar& v); |
182 StringFormatArg (const qchar& v); |
181 StringFormatArg (const QChar& v); |
183 |
182 |
184 #define NUMERIC_FORMAT_ARG(T,C) \ |
183 #define NUMERIC_FORMAT_ARG(T,C) \ |
185 StringFormatArg (const T& v) { \ |
184 StringFormatArg (const T& v) { \ |
186 char valstr[32]; \ |
185 char valstr[32]; \ |
187 sprintf (valstr, "%" #C, v); \ |
186 sprintf (valstr, "%" #C, v); \ |