Thu, 04 Jan 2018 19:52:24 +0200
replaced Origin with default-constructed Vertex
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
968 | 3 | * Copyright (C) 2013 - 2015 Teemu Piippo |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
1006
a6b462051ae0
Copyright header fix, some minor stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1002
diff
changeset
|
8 | * (at your option) any later version. |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #pragma once |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include <QString> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | #include <QObject> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include <QStringList> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include <QMetaType> |
733
cc39df788660
- reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
24 | #include <QVector3D> |
920
147497785496
- fixed stability problems
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
25 | #include <functional> |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | #include "macros.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | class LDObject; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | class QFile; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | class QTextStream; |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
739
diff
changeset
|
31 | class Matrix; |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
32 | class LDDocument; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | using int8 = qint8; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | using int16 = qint16; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | using int32 = qint32; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | using int64 = qint64; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | using uint8 = quint8; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | using uint16 = quint16; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | using uint32 = quint32; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | using uint64 = quint64; |
944 | 42 | using LDObjectList = QList<LDObject*>; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | template<typename T, typename R> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | using Pair = std::pair<T, R>; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | enum Axis |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | X, |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | Y, |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | Z |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | }; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | |
794 | 54 | // |
55 | // Derivative of QVector3D: this class is used for the vertices. | |
56 | // | |
733
cc39df788660
- reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
57 | class Vertex : public QVector3D |
cc39df788660
- reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
58 | { |
cc39df788660
- reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
59 | public: |
1217 | 60 | using ApplyFunction = std::function<void(Axis, double&)>; |
61 | using ApplyConstFunction = std::function<void(Axis, double)>; | |
733
cc39df788660
- reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
62 | |
cc39df788660
- reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
63 | Vertex(); |
1217 | 64 | Vertex(const QVector3D& a); |
65 | Vertex(qreal xpos, qreal ypos, qreal zpos); | |
733
cc39df788660
- reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
66 | |
1217 | 67 | void apply(ApplyFunction func); |
68 | void apply(ApplyConstFunction func) const; | |
69 | QString toString(bool mangled = false) const; | |
70 | void transform(const Matrix& matr, const Vertex& pos); | |
71 | void setCoordinate(Axis ax, qreal value); | |
733
cc39df788660
- reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
72 | |
1002
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
73 | Vertex& operator+= (const Vertex& other); |
1217 | 74 | Vertex operator+(const Vertex& other) const; |
1002
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
75 | Vertex& operator*= (qreal scalar); |
1217 | 76 | Vertex operator*(qreal scalar) const; |
77 | bool operator<(const Vertex& other) const; | |
78 | double operator[](Axis ax) const; | |
733
cc39df788660
- reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
79 | }; |
cc39df788660
- reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
80 | |
1217 | 81 | inline Vertex operator*(qreal scalar, const Vertex& vertex) |
1002
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
82 | { |
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
83 | return vertex * scalar; |
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
84 | } |
a3ee23db8393
Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
978
diff
changeset
|
85 | |
1217 | 86 | Q_DECLARE_METATYPE(Vertex) |
733
cc39df788660
- reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
87 | |
794 | 88 | // |
89 | // A mathematical 3 x 3 matrix | |
90 | // | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
91 | class Matrix |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | { |
794 | 93 | public: |
94 | Matrix() {} | |
1217 | 95 | Matrix(const std::initializer_list<double>& vals); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | |
794 | 97 | // Constructs a matrix all 9 elements initialized to the same value. |
1217 | 98 | Matrix(double fillval); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
99 | |
794 | 100 | // Constructs a matrix with a C-array. |
101 | // note: @vals is expected to have exactly 9 elements. | |
1217 | 102 | Matrix(double vals[]); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 | |
794 | 104 | // Calculates the matrix's determinant. |
105 | double getDeterminant() const; | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
106 | |
794 | 107 | // Multiplies this matrix with @other |
108 | // note: a.mult(b) is not equivalent to b.mult(a)! | |
1217 | 109 | Matrix mult(const Matrix& other) const; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | |
794 | 111 | // Prints the matrix to stdout. |
112 | void dump() const; | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
113 | |
794 | 114 | // Yields a string representation of the matrix. |
115 | QString toString() const; | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | |
794 | 117 | // Zeroes the matrix out. |
118 | void zero(); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
119 | |
794 | 120 | // Assigns the matrix values to the values of @other. |
121 | Matrix& operator= (const Matrix& other); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
122 | |
794 | 123 | // Returns a mutable reference to a value by @idx |
1217 | 124 | inline double& value(int idx) |
794 | 125 | { |
126 | return m_vals[idx]; | |
127 | } | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
128 | |
794 | 129 | // An overload of value() for const matrices. |
1217 | 130 | inline const double& value(int idx) const |
794 | 131 | { |
132 | return m_vals[idx]; | |
133 | } | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
134 | |
794 | 135 | // An operator overload for mult(). |
1217 | 136 | inline Matrix operator*(const Matrix& other) const |
794 | 137 | { |
1217 | 138 | return mult(other); |
794 | 139 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
140 | |
794 | 141 | // An operator overload for value(). |
1217 | 142 | inline double& operator[](int idx) |
794 | 143 | { |
1217 | 144 | return value(idx); |
794 | 145 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
146 | |
794 | 147 | // An operator overload for value() const. |
1217 | 148 | inline const double& operator[](int idx) const |
794 | 149 | { |
1217 | 150 | return value(idx); |
794 | 151 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
152 | |
794 | 153 | // Checks whether the two matrices have the same values. |
154 | bool operator== (const Matrix& other) const; | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
155 | |
794 | 156 | private: |
157 | double m_vals[9]; | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
158 | }; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
159 | |
794 | 160 | // |
161 | // Defines a bounding box that encompasses a given set of objects. | |
162 | // vertex0 is the minimum vertex, vertex1 is the maximum vertex. | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
163 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
164 | class LDBoundingBox |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
165 | { |
794 | 166 | public: |
167 | LDBoundingBox(); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
168 | |
1217 | 169 | void calcObject(LDObject* obj); |
170 | void calcVertex(const Vertex& vertex); | |
1010
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
171 | Vertex center() const; |
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
172 | bool isEmpty() const; |
794 | 173 | double longestMeasurement() const; |
1010
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
174 | void reset(); |
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
175 | const Vertex& vertex0() const; |
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
176 | const Vertex& vertex1() const; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
177 | |
1217 | 178 | LDBoundingBox& operator<<(LDObject* obj); |
179 | LDBoundingBox& operator<<(const Vertex& v); | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
180 | |
1010
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
181 | private: |
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
182 | bool m_isEmpty; |
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
183 | Vertex m_vertex0; |
969b48eddd6b
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
184 | Vertex m_vertex1; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
185 | }; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
186 | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
847
diff
changeset
|
187 | extern const Matrix IdentityMatrix; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
188 | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
847
diff
changeset
|
189 | static const double Pi = 3.14159265358979323846; |
816 | 190 | |
191 | ||
192 | // ============================================================================= | |
193 | // Plural expression | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
847
diff
changeset
|
194 | template<typename T> |
1217 | 195 | static inline const char* plural(T n) |
816 | 196 | { |
197 | return (n != 1) ? "s" : ""; | |
198 | } | |
199 | ||
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
847
diff
changeset
|
200 | template<typename T> |
1217 | 201 | bool isZero(T a) |
816 | 202 | { |
1217 | 203 | return qFuzzyCompare(a + 1.0, 1.0); |
816 | 204 | } |
205 | ||
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
847
diff
changeset
|
206 | template<typename T> |
1217 | 207 | bool isInteger(T a) |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
847
diff
changeset
|
208 | { |
1217 | 209 | return (qAbs(a - floor(a)) < 0.00001) or(qAbs(a - ceil(a)) < 0.00001); |
847 | 210 | } |
211 | ||
212 | template<typename T> | |
1217 | 213 | void removeDuplicates(T& a) |
816 | 214 | { |
1217 | 215 | std::sort(a.begin(), a.end()); |
216 | a.erase(std::unique(a.begin(), a.end()), a.end()); | |
816 | 217 | } |
218 | ||
219 | // | |
220 | // Returns true if first arg is equal to any of the other args | |
221 | // | |
222 | template<typename T, typename Arg, typename... Args> | |
1217 | 223 | bool isOneOf(T const& a, Arg const& arg, Args const&... args) |
816 | 224 | { |
225 | if (a == arg) | |
226 | return true; | |
227 | ||
1217 | 228 | return isOneOf(a, args...); |
816 | 229 | } |
230 | ||
231 | template<typename T> | |
1217 | 232 | bool isOneOf(T const&) |
816 | 233 | { |
234 | return false; | |
235 | } |