1 | // |
2 | // NamedTuple.h |
3 | // |
4 | // Library: Foundation |
5 | // Package: Core |
6 | // Module: NamedTuple |
7 | // |
8 | // Definition of the NamedTuple class. |
9 | // |
10 | // Copyright (c) 2007, Applied Informatics Software Engineering GmbH. |
11 | // and Contributors. |
12 | // |
13 | // SPDX-License-Identifier: BSL-1.0 |
14 | // |
15 | |
16 | |
17 | #ifndef Foundation_NamedTuple_INCLUDED |
18 | #define Foundation_NamedTuple_INCLUDED |
19 | |
20 | |
21 | #include "Poco/Foundation.h" |
22 | #include "Poco/Tuple.h" |
23 | #include "Poco/TypeList.h" |
24 | #include "Poco/DynamicAny.h" |
25 | #include "Poco/SharedPtr.h" |
26 | #include "Poco/Format.h" |
27 | |
28 | |
29 | namespace Poco { |
30 | |
31 | |
32 | template<class T0, |
33 | class T1 = NullTypeList, |
34 | class T2 = NullTypeList, |
35 | class T3 = NullTypeList, |
36 | class T4 = NullTypeList, |
37 | class T5 = NullTypeList, |
38 | class T6 = NullTypeList, |
39 | class T7 = NullTypeList, |
40 | class T8 = NullTypeList, |
41 | class T9 = NullTypeList, |
42 | class T10 = NullTypeList, |
43 | class T11 = NullTypeList, |
44 | class T12 = NullTypeList, |
45 | class T13 = NullTypeList, |
46 | class T14 = NullTypeList, |
47 | class T15 = NullTypeList, |
48 | class T16 = NullTypeList, |
49 | class T17 = NullTypeList, |
50 | class T18 = NullTypeList, |
51 | class T19 = NullTypeList, |
52 | class T20 = NullTypeList, |
53 | class T21 = NullTypeList, |
54 | class T22 = NullTypeList, |
55 | class T23 = NullTypeList, |
56 | class T24 = NullTypeList, |
57 | class T25 = NullTypeList, |
58 | class T26 = NullTypeList, |
59 | class T27 = NullTypeList, |
60 | class T28 = NullTypeList, |
61 | class T29 = NullTypeList, |
62 | class T30 = NullTypeList, |
63 | class T31 = NullTypeList, |
64 | class T32 = NullTypeList, |
65 | class T33 = NullTypeList, |
66 | class T34 = NullTypeList, |
67 | class T35 = NullTypeList, |
68 | class T36 = NullTypeList, |
69 | class T37 = NullTypeList, |
70 | class T38 = NullTypeList, |
71 | class T39 = NullTypeList> |
72 | struct NamedTuple: public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39> |
73 | { |
74 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39> TupleType; |
75 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39>::Type Type; |
76 | typedef std::vector<std::string> NameVec; |
77 | typedef SharedPtr<NameVec> NameVecPtr; |
78 | |
79 | NamedTuple(): _pNames(0) |
80 | { |
81 | init(); |
82 | } |
83 | |
84 | NamedTuple(const NameVecPtr& rNames) |
85 | { |
86 | if (rNames->size() != TupleType::length) |
87 | throw InvalidArgumentException("Wrong names vector length." ); |
88 | |
89 | _pNames = rNames; |
90 | } |
91 | |
92 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
93 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
94 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
95 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
96 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
97 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
98 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
99 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
100 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
101 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
102 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
103 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
104 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
105 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
106 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
107 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
108 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
109 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
110 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
111 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
112 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
113 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
114 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
115 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
116 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
117 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
118 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
119 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
120 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
121 | typename TypeWrapper<T29>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
122 | typename TypeWrapper<T30>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
123 | typename TypeWrapper<T31>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
124 | typename TypeWrapper<T32>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32), |
125 | typename TypeWrapper<T33>::CONSTTYPE& t33 = POCO_TYPEWRAPPER_DEFAULTVALUE(T33), |
126 | typename TypeWrapper<T34>::CONSTTYPE& t34 = POCO_TYPEWRAPPER_DEFAULTVALUE(T34), |
127 | typename TypeWrapper<T35>::CONSTTYPE& t35 = POCO_TYPEWRAPPER_DEFAULTVALUE(T35), |
128 | typename TypeWrapper<T36>::CONSTTYPE& t36 = POCO_TYPEWRAPPER_DEFAULTVALUE(T36), |
129 | typename TypeWrapper<T37>::CONSTTYPE& t37 = POCO_TYPEWRAPPER_DEFAULTVALUE(T37), |
130 | typename TypeWrapper<T38>::CONSTTYPE& t38 = POCO_TYPEWRAPPER_DEFAULTVALUE(T38), |
131 | typename TypeWrapper<T39>::CONSTTYPE& t39 = POCO_TYPEWRAPPER_DEFAULTVALUE(T39)): |
132 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39), |
133 | _pNames(0) |
134 | { |
135 | init(); |
136 | } |
137 | |
138 | NamedTuple(const NameVecPtr& rNames, |
139 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
140 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
141 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
142 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
143 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
144 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
145 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
146 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
147 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
148 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
149 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
150 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
151 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
152 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
153 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
154 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
155 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
156 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
157 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
158 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
159 | typename TypeWrapper<T0>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
160 | typename TypeWrapper<T1>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
161 | typename TypeWrapper<T2>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
162 | typename TypeWrapper<T3>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
163 | typename TypeWrapper<T4>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
164 | typename TypeWrapper<T5>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
165 | typename TypeWrapper<T6>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
166 | typename TypeWrapper<T7>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
167 | typename TypeWrapper<T8>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
168 | typename TypeWrapper<T9>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
169 | typename TypeWrapper<T10>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
170 | typename TypeWrapper<T11>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
171 | typename TypeWrapper<T12>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32), |
172 | typename TypeWrapper<T13>::CONSTTYPE& t33 = POCO_TYPEWRAPPER_DEFAULTVALUE(T33), |
173 | typename TypeWrapper<T14>::CONSTTYPE& t34 = POCO_TYPEWRAPPER_DEFAULTVALUE(T34), |
174 | typename TypeWrapper<T15>::CONSTTYPE& t35 = POCO_TYPEWRAPPER_DEFAULTVALUE(T35), |
175 | typename TypeWrapper<T16>::CONSTTYPE& t36 = POCO_TYPEWRAPPER_DEFAULTVALUE(T36), |
176 | typename TypeWrapper<T17>::CONSTTYPE& t37 = POCO_TYPEWRAPPER_DEFAULTVALUE(T37), |
177 | typename TypeWrapper<T18>::CONSTTYPE& t38 = POCO_TYPEWRAPPER_DEFAULTVALUE(T38), |
178 | typename TypeWrapper<T19>::CONSTTYPE& t39 = POCO_TYPEWRAPPER_DEFAULTVALUE(T39)): |
179 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39) |
180 | { |
181 | if (rNames->size() != TupleType::length) |
182 | throw InvalidArgumentException("Wrong names vector length." ); |
183 | |
184 | _pNames = rNames; |
185 | } |
186 | |
187 | NamedTuple(const std::string& n0, |
188 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
189 | const std::string& n1 = "B" , |
190 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
191 | const std::string& n2 = "C" , |
192 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
193 | const std::string& n3 = "D" , |
194 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
195 | const std::string& n4 = "E" , |
196 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
197 | const std::string& n5 = "F" , |
198 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
199 | const std::string& n6 = "G" , |
200 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
201 | const std::string& n7 = "H" , |
202 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
203 | const std::string& n8 = "I" , |
204 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
205 | const std::string& n9 = "J" , |
206 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
207 | const std::string& n10 = "K" , |
208 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
209 | const std::string& n11 = "L" , |
210 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
211 | const std::string& n12 = "M" , |
212 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
213 | const std::string& n13 = "N" , |
214 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
215 | const std::string& n14 = "O" , |
216 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
217 | const std::string& n15 = "P" , |
218 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
219 | const std::string& n16 = "Q" , |
220 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
221 | const std::string& n17 = "R" , |
222 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
223 | const std::string& n18 = "S" , |
224 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
225 | const std::string& n19 = "T" , |
226 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
227 | const std::string& n20 = "U" , |
228 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
229 | const std::string& n21 = "V" , |
230 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
231 | const std::string& n22 = "W" , |
232 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
233 | const std::string& n23 = "X" , |
234 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
235 | const std::string& n24 = "Y" , |
236 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
237 | const std::string& n25 = "Z" , |
238 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
239 | const std::string& n26 = "A1" , |
240 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
241 | const std::string& n27 = "B1" , |
242 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
243 | const std::string& n28 = "C1" , |
244 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
245 | const std::string& n29 = "D1" , |
246 | typename TypeWrapper<T29>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
247 | const std::string& n30 = "E1" , |
248 | typename TypeWrapper<T30>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
249 | const std::string& n31 = "F1" , |
250 | typename TypeWrapper<T31>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
251 | const std::string& n32 = "G1" , |
252 | typename TypeWrapper<T32>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32), |
253 | const std::string& n33 = "H1" , |
254 | typename TypeWrapper<T33>::CONSTTYPE& t33 = POCO_TYPEWRAPPER_DEFAULTVALUE(T33), |
255 | const std::string& n34 = "I1" , |
256 | typename TypeWrapper<T34>::CONSTTYPE& t34 = POCO_TYPEWRAPPER_DEFAULTVALUE(T34), |
257 | const std::string& n35 = "J1" , |
258 | typename TypeWrapper<T35>::CONSTTYPE& t35 = POCO_TYPEWRAPPER_DEFAULTVALUE(T35), |
259 | const std::string& n36 = "K1" , |
260 | typename TypeWrapper<T36>::CONSTTYPE& t36 = POCO_TYPEWRAPPER_DEFAULTVALUE(T36), |
261 | const std::string& n37 = "L1" , |
262 | typename TypeWrapper<T37>::CONSTTYPE& t37 = POCO_TYPEWRAPPER_DEFAULTVALUE(T37), |
263 | const std::string& n38 = "M1" , |
264 | typename TypeWrapper<T38>::CONSTTYPE& t38 = POCO_TYPEWRAPPER_DEFAULTVALUE(T38), |
265 | const std::string& n39 = "N1" , |
266 | typename TypeWrapper<T39>::CONSTTYPE& t39 = POCO_TYPEWRAPPER_DEFAULTVALUE(T39)): |
267 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39), |
268 | _pNames(0) |
269 | { |
270 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31,n32,n33,n34,n35,n36,n37,n38,n39); |
271 | } |
272 | |
273 | const DynamicAny get(const std::string& name) const |
274 | { |
275 | NameVec::const_iterator it = _pNames->begin(); |
276 | NameVec::const_iterator itEnd = _pNames->end(); |
277 | |
278 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
279 | { |
280 | if (name == *it) |
281 | { |
282 | switch (counter) |
283 | { |
284 | case 0: return TupleType::template get<0>(); |
285 | case 1: return TupleType::template get<1>(); |
286 | case 2: return TupleType::template get<2>(); |
287 | case 3: return TupleType::template get<3>(); |
288 | case 4: return TupleType::template get<4>(); |
289 | case 5: return TupleType::template get<5>(); |
290 | case 6: return TupleType::template get<6>(); |
291 | case 7: return TupleType::template get<7>(); |
292 | case 8: return TupleType::template get<8>(); |
293 | case 9: return TupleType::template get<9>(); |
294 | case 10: return TupleType::template get<10>(); |
295 | case 11: return TupleType::template get<11>(); |
296 | case 12: return TupleType::template get<12>(); |
297 | case 13: return TupleType::template get<13>(); |
298 | case 14: return TupleType::template get<14>(); |
299 | case 15: return TupleType::template get<15>(); |
300 | case 16: return TupleType::template get<16>(); |
301 | case 17: return TupleType::template get<17>(); |
302 | case 18: return TupleType::template get<18>(); |
303 | case 19: return TupleType::template get<19>(); |
304 | case 20: return TupleType::template get<20>(); |
305 | case 21: return TupleType::template get<21>(); |
306 | case 22: return TupleType::template get<22>(); |
307 | case 23: return TupleType::template get<23>(); |
308 | case 24: return TupleType::template get<24>(); |
309 | case 25: return TupleType::template get<25>(); |
310 | case 26: return TupleType::template get<26>(); |
311 | case 27: return TupleType::template get<27>(); |
312 | case 28: return TupleType::template get<28>(); |
313 | case 29: return TupleType::template get<29>(); |
314 | case 30: return TupleType::template get<30>(); |
315 | case 31: return TupleType::template get<31>(); |
316 | case 32: return TupleType::template get<32>(); |
317 | case 33: return TupleType::template get<33>(); |
318 | case 34: return TupleType::template get<34>(); |
319 | case 35: return TupleType::template get<35>(); |
320 | case 36: return TupleType::template get<36>(); |
321 | case 37: return TupleType::template get<37>(); |
322 | case 38: return TupleType::template get<38>(); |
323 | case 39: return TupleType::template get<39>(); |
324 | default: throw RangeException(); |
325 | } |
326 | } |
327 | } |
328 | |
329 | throw NotFoundException("Name not found: " + name); |
330 | } |
331 | |
332 | const DynamicAny operator [] (const std::string& name) const |
333 | { |
334 | return get(name); |
335 | } |
336 | |
337 | template<int N> |
338 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
339 | { |
340 | return TupleType::template get<N>(); |
341 | } |
342 | |
343 | template<int N> |
344 | typename TypeGetter<N, Type>::HeadType& get() |
345 | { |
346 | return TupleType::template get<N>(); |
347 | } |
348 | |
349 | template<int N> |
350 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
351 | { |
352 | return TupleType::template set<N>(val); |
353 | } |
354 | |
355 | const NameVecPtr& names() |
356 | { |
357 | return _pNames; |
358 | } |
359 | |
360 | void setName(std::size_t index, const std::string& name) |
361 | { |
362 | if (index >= _pNames->size()) |
363 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
364 | |
365 | (*_pNames)[index] = name; |
366 | } |
367 | |
368 | const std::string& getName(std::size_t index) |
369 | { |
370 | if (index >= _pNames->size()) |
371 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
372 | |
373 | return (*_pNames)[index]; |
374 | } |
375 | |
376 | bool operator == (const NamedTuple& other) const |
377 | { |
378 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
379 | } |
380 | |
381 | bool operator != (const NamedTuple& other) const |
382 | { |
383 | return !(*this == other); |
384 | } |
385 | |
386 | bool operator < (const NamedTuple& other) const |
387 | { |
388 | TupleType th(*this); |
389 | TupleType oth(other); |
390 | |
391 | return (th < oth && _pNames == other._pNames) || |
392 | (th == oth && _pNames < other._pNames) || |
393 | (th < oth && _pNames < other._pNames); |
394 | } |
395 | |
396 | private: |
397 | void init(const std::string& n0 = "A" , |
398 | const std::string& n1 = "B" , |
399 | const std::string& n2 = "C" , |
400 | const std::string& n3 = "D" , |
401 | const std::string& n4 = "E" , |
402 | const std::string& n5 = "F" , |
403 | const std::string& n6 = "G" , |
404 | const std::string& n7 = "H" , |
405 | const std::string& n8 = "I" , |
406 | const std::string& n9 = "J" , |
407 | const std::string& n10 = "K" , |
408 | const std::string& n11 = "L" , |
409 | const std::string& n12 = "M" , |
410 | const std::string& n13 = "N" , |
411 | const std::string& n14 = "O" , |
412 | const std::string& n15 = "P" , |
413 | const std::string& n16 = "Q" , |
414 | const std::string& n17 = "R" , |
415 | const std::string& n18 = "S" , |
416 | const std::string& n19 = "T" , |
417 | const std::string& n20 = "U" , |
418 | const std::string& n21 = "V" , |
419 | const std::string& n22 = "W" , |
420 | const std::string& n23 = "X" , |
421 | const std::string& n24 = "Y" , |
422 | const std::string& n25 = "Z" , |
423 | const std::string& n26 = "A1" , |
424 | const std::string& n27 = "B1" , |
425 | const std::string& n28 = "C1" , |
426 | const std::string& n29 = "D1" , |
427 | const std::string& n30 = "E1" , |
428 | const std::string& n31 = "F1" , |
429 | const std::string& n32 = "G1" , |
430 | const std::string& n33 = "H1" , |
431 | const std::string& n34 = "I1" , |
432 | const std::string& n35 = "J1" , |
433 | const std::string& n36 = "K1" , |
434 | const std::string& n37 = "L1" , |
435 | const std::string& n38 = "M1" , |
436 | const std::string& n39 = "N1" ) |
437 | { |
438 | if (!_pNames) |
439 | { |
440 | _pNames = new NameVec; |
441 | _pNames->push_back(n0); |
442 | _pNames->push_back(n1); |
443 | _pNames->push_back(n2); |
444 | _pNames->push_back(n3); |
445 | _pNames->push_back(n4); |
446 | _pNames->push_back(n5); |
447 | _pNames->push_back(n6); |
448 | _pNames->push_back(n7); |
449 | _pNames->push_back(n8); |
450 | _pNames->push_back(n9); |
451 | _pNames->push_back(n10); |
452 | _pNames->push_back(n11); |
453 | _pNames->push_back(n12); |
454 | _pNames->push_back(n13); |
455 | _pNames->push_back(n14); |
456 | _pNames->push_back(n15); |
457 | _pNames->push_back(n16); |
458 | _pNames->push_back(n17); |
459 | _pNames->push_back(n18); |
460 | _pNames->push_back(n19); |
461 | _pNames->push_back(n20); |
462 | _pNames->push_back(n21); |
463 | _pNames->push_back(n22); |
464 | _pNames->push_back(n23); |
465 | _pNames->push_back(n24); |
466 | _pNames->push_back(n25); |
467 | _pNames->push_back(n26); |
468 | _pNames->push_back(n27); |
469 | _pNames->push_back(n28); |
470 | _pNames->push_back(n29); |
471 | _pNames->push_back(n30); |
472 | _pNames->push_back(n31); |
473 | _pNames->push_back(n32); |
474 | _pNames->push_back(n33); |
475 | _pNames->push_back(n34); |
476 | _pNames->push_back(n35); |
477 | _pNames->push_back(n36); |
478 | _pNames->push_back(n37); |
479 | _pNames->push_back(n38); |
480 | _pNames->push_back(n39); |
481 | } |
482 | } |
483 | |
484 | NameVecPtr _pNames; |
485 | }; |
486 | |
487 | |
488 | template<class T0, |
489 | class T1, |
490 | class T2, |
491 | class T3, |
492 | class T4, |
493 | class T5, |
494 | class T6, |
495 | class T7, |
496 | class T8, |
497 | class T9, |
498 | class T10, |
499 | class T11, |
500 | class T12, |
501 | class T13, |
502 | class T14, |
503 | class T15, |
504 | class T16, |
505 | class T17, |
506 | class T18, |
507 | class T19, |
508 | class T20, |
509 | class T21, |
510 | class T22, |
511 | class T23, |
512 | class T24, |
513 | class T25, |
514 | class T26, |
515 | class T27, |
516 | class T28, |
517 | class T29, |
518 | class T30, |
519 | class T31, |
520 | class T32, |
521 | class T33, |
522 | class T34, |
523 | class T35, |
524 | class T36, |
525 | class T37, |
526 | class T38> |
527 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,NullTypeList>: |
528 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38> |
529 | { |
530 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38> TupleType; |
531 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38>::Type Type; |
532 | typedef std::vector<std::string> NameVec; |
533 | typedef SharedPtr<NameVec> NameVecPtr; |
534 | |
535 | NamedTuple(): _pNames(0) |
536 | { |
537 | init(); |
538 | } |
539 | |
540 | NamedTuple(const NameVecPtr& rNames) |
541 | { |
542 | if (rNames->size() != TupleType::length) |
543 | throw InvalidArgumentException("Wrong names vector length." ); |
544 | |
545 | _pNames = rNames; |
546 | } |
547 | |
548 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
549 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
550 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
551 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
552 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
553 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
554 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
555 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
556 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
557 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
558 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
559 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
560 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
561 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
562 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
563 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
564 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
565 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
566 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
567 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
568 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
569 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
570 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
571 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
572 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
573 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
574 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
575 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
576 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
577 | typename TypeWrapper<T29>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
578 | typename TypeWrapper<T30>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
579 | typename TypeWrapper<T31>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
580 | typename TypeWrapper<T32>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32), |
581 | typename TypeWrapper<T33>::CONSTTYPE& t33 = POCO_TYPEWRAPPER_DEFAULTVALUE(T33), |
582 | typename TypeWrapper<T34>::CONSTTYPE& t34 = POCO_TYPEWRAPPER_DEFAULTVALUE(T34), |
583 | typename TypeWrapper<T35>::CONSTTYPE& t35 = POCO_TYPEWRAPPER_DEFAULTVALUE(T35), |
584 | typename TypeWrapper<T36>::CONSTTYPE& t36 = POCO_TYPEWRAPPER_DEFAULTVALUE(T36), |
585 | typename TypeWrapper<T37>::CONSTTYPE& t37 = POCO_TYPEWRAPPER_DEFAULTVALUE(T37), |
586 | typename TypeWrapper<T38>::CONSTTYPE& t38 = POCO_TYPEWRAPPER_DEFAULTVALUE(T38)): |
587 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38), |
588 | _pNames(0) |
589 | { |
590 | init(); |
591 | } |
592 | |
593 | NamedTuple(const NameVecPtr& rNames, |
594 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
595 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
596 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
597 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
598 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
599 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
600 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
601 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
602 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
603 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
604 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
605 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
606 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
607 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
608 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
609 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
610 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
611 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
612 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
613 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
614 | typename TypeWrapper<T0>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
615 | typename TypeWrapper<T1>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
616 | typename TypeWrapper<T2>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
617 | typename TypeWrapper<T3>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
618 | typename TypeWrapper<T4>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
619 | typename TypeWrapper<T5>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
620 | typename TypeWrapper<T6>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
621 | typename TypeWrapper<T7>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
622 | typename TypeWrapper<T8>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
623 | typename TypeWrapper<T9>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
624 | typename TypeWrapper<T10>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
625 | typename TypeWrapper<T11>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
626 | typename TypeWrapper<T12>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32), |
627 | typename TypeWrapper<T13>::CONSTTYPE& t33 = POCO_TYPEWRAPPER_DEFAULTVALUE(T33), |
628 | typename TypeWrapper<T14>::CONSTTYPE& t34 = POCO_TYPEWRAPPER_DEFAULTVALUE(T34), |
629 | typename TypeWrapper<T15>::CONSTTYPE& t35 = POCO_TYPEWRAPPER_DEFAULTVALUE(T35), |
630 | typename TypeWrapper<T16>::CONSTTYPE& t36 = POCO_TYPEWRAPPER_DEFAULTVALUE(T36), |
631 | typename TypeWrapper<T17>::CONSTTYPE& t37 = POCO_TYPEWRAPPER_DEFAULTVALUE(T37), |
632 | typename TypeWrapper<T18>::CONSTTYPE& t38 = POCO_TYPEWRAPPER_DEFAULTVALUE(T38)): |
633 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38) |
634 | { |
635 | if (rNames->size() != TupleType::length) |
636 | throw InvalidArgumentException("Wrong names vector length." ); |
637 | |
638 | _pNames = rNames; |
639 | } |
640 | |
641 | NamedTuple(const std::string& n0, |
642 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
643 | const std::string& n1 = "B" , |
644 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
645 | const std::string& n2 = "C" , |
646 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
647 | const std::string& n3 = "D" , |
648 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
649 | const std::string& n4 = "E" , |
650 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
651 | const std::string& n5 = "F" , |
652 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
653 | const std::string& n6 = "G" , |
654 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
655 | const std::string& n7 = "H" , |
656 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
657 | const std::string& n8 = "I" , |
658 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
659 | const std::string& n9 = "J" , |
660 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
661 | const std::string& n10 = "K" , |
662 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
663 | const std::string& n11 = "L" , |
664 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
665 | const std::string& n12 = "M" , |
666 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
667 | const std::string& n13 = "N" , |
668 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
669 | const std::string& n14 = "O" , |
670 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
671 | const std::string& n15 = "P" , |
672 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
673 | const std::string& n16 = "Q" , |
674 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
675 | const std::string& n17 = "R" , |
676 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
677 | const std::string& n18 = "S" , |
678 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
679 | const std::string& n19 = "T" , |
680 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
681 | const std::string& n20 = "U" , |
682 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
683 | const std::string& n21 = "V" , |
684 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
685 | const std::string& n22 = "W" , |
686 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
687 | const std::string& n23 = "X" , |
688 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
689 | const std::string& n24 = "Y" , |
690 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
691 | const std::string& n25 = "Z" , |
692 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
693 | const std::string& n26 = "A1" , |
694 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
695 | const std::string& n27 = "B1" , |
696 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
697 | const std::string& n28 = "C1" , |
698 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
699 | const std::string& n29 = "D1" , |
700 | typename TypeWrapper<T29>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
701 | const std::string& n30 = "E1" , |
702 | typename TypeWrapper<T30>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
703 | const std::string& n31 = "F1" , |
704 | typename TypeWrapper<T31>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
705 | const std::string& n32 = "G1" , |
706 | typename TypeWrapper<T32>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32), |
707 | const std::string& n33 = "H1" , |
708 | typename TypeWrapper<T33>::CONSTTYPE& t33 = POCO_TYPEWRAPPER_DEFAULTVALUE(T33), |
709 | const std::string& n34 = "I1" , |
710 | typename TypeWrapper<T34>::CONSTTYPE& t34 = POCO_TYPEWRAPPER_DEFAULTVALUE(T34), |
711 | const std::string& n35 = "J1" , |
712 | typename TypeWrapper<T35>::CONSTTYPE& t35 = POCO_TYPEWRAPPER_DEFAULTVALUE(T35), |
713 | const std::string& n36 = "K1" , |
714 | typename TypeWrapper<T36>::CONSTTYPE& t36 = POCO_TYPEWRAPPER_DEFAULTVALUE(T36), |
715 | const std::string& n37 = "L1" , |
716 | typename TypeWrapper<T37>::CONSTTYPE& t37 = POCO_TYPEWRAPPER_DEFAULTVALUE(T37), |
717 | const std::string& n38 = "M1" , |
718 | typename TypeWrapper<T38>::CONSTTYPE& t38 = POCO_TYPEWRAPPER_DEFAULTVALUE(T38)): |
719 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38), |
720 | _pNames(0) |
721 | { |
722 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31,n32,n33,n34,n35,n36,n37,n38); |
723 | } |
724 | |
725 | const DynamicAny get(const std::string& name) const |
726 | { |
727 | NameVec::const_iterator it = _pNames->begin(); |
728 | NameVec::const_iterator itEnd = _pNames->end(); |
729 | |
730 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
731 | { |
732 | if (name == *it) |
733 | { |
734 | switch (counter) |
735 | { |
736 | case 0: return TupleType::template get<0>(); |
737 | case 1: return TupleType::template get<1>(); |
738 | case 2: return TupleType::template get<2>(); |
739 | case 3: return TupleType::template get<3>(); |
740 | case 4: return TupleType::template get<4>(); |
741 | case 5: return TupleType::template get<5>(); |
742 | case 6: return TupleType::template get<6>(); |
743 | case 7: return TupleType::template get<7>(); |
744 | case 8: return TupleType::template get<8>(); |
745 | case 9: return TupleType::template get<9>(); |
746 | case 10: return TupleType::template get<10>(); |
747 | case 11: return TupleType::template get<11>(); |
748 | case 12: return TupleType::template get<12>(); |
749 | case 13: return TupleType::template get<13>(); |
750 | case 14: return TupleType::template get<14>(); |
751 | case 15: return TupleType::template get<15>(); |
752 | case 16: return TupleType::template get<16>(); |
753 | case 17: return TupleType::template get<17>(); |
754 | case 18: return TupleType::template get<18>(); |
755 | case 19: return TupleType::template get<19>(); |
756 | case 20: return TupleType::template get<20>(); |
757 | case 21: return TupleType::template get<21>(); |
758 | case 22: return TupleType::template get<22>(); |
759 | case 23: return TupleType::template get<23>(); |
760 | case 24: return TupleType::template get<24>(); |
761 | case 25: return TupleType::template get<25>(); |
762 | case 26: return TupleType::template get<26>(); |
763 | case 27: return TupleType::template get<27>(); |
764 | case 28: return TupleType::template get<28>(); |
765 | case 29: return TupleType::template get<29>(); |
766 | case 30: return TupleType::template get<30>(); |
767 | case 31: return TupleType::template get<31>(); |
768 | case 32: return TupleType::template get<32>(); |
769 | case 33: return TupleType::template get<33>(); |
770 | case 34: return TupleType::template get<34>(); |
771 | case 35: return TupleType::template get<35>(); |
772 | case 36: return TupleType::template get<36>(); |
773 | case 37: return TupleType::template get<37>(); |
774 | case 38: return TupleType::template get<38>(); |
775 | default: throw RangeException(); |
776 | } |
777 | } |
778 | } |
779 | |
780 | throw NotFoundException("Name not found: " + name); |
781 | } |
782 | |
783 | const DynamicAny operator [] (const std::string& name) const |
784 | { |
785 | return get(name); |
786 | } |
787 | |
788 | template<int N> |
789 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
790 | { |
791 | return TupleType::template get<N>(); |
792 | } |
793 | |
794 | template<int N> |
795 | typename TypeGetter<N, Type>::HeadType& get() |
796 | { |
797 | return TupleType::template get<N>(); |
798 | } |
799 | |
800 | template<int N> |
801 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
802 | { |
803 | return TupleType::template set<N>(val); |
804 | } |
805 | |
806 | const NameVecPtr& names() |
807 | { |
808 | return _pNames; |
809 | } |
810 | |
811 | void setName(std::size_t index, const std::string& name) |
812 | { |
813 | if (index >= _pNames->size()) |
814 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
815 | |
816 | (*_pNames)[index] = name; |
817 | } |
818 | |
819 | const std::string& getName(std::size_t index) |
820 | { |
821 | if (index >= _pNames->size()) |
822 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
823 | |
824 | return (*_pNames)[index]; |
825 | } |
826 | |
827 | bool operator == (const NamedTuple& other) const |
828 | { |
829 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
830 | } |
831 | |
832 | bool operator != (const NamedTuple& other) const |
833 | { |
834 | return !(*this == other); |
835 | } |
836 | |
837 | bool operator < (const NamedTuple& other) const |
838 | { |
839 | TupleType th(*this); |
840 | TupleType oth(other); |
841 | |
842 | return (th < oth && _pNames == other._pNames) || |
843 | (th == oth && _pNames < other._pNames) || |
844 | (th < oth && _pNames < other._pNames); |
845 | } |
846 | |
847 | private: |
848 | void init(const std::string& n0 = "A" , |
849 | const std::string& n1 = "B" , |
850 | const std::string& n2 = "C" , |
851 | const std::string& n3 = "D" , |
852 | const std::string& n4 = "E" , |
853 | const std::string& n5 = "F" , |
854 | const std::string& n6 = "G" , |
855 | const std::string& n7 = "H" , |
856 | const std::string& n8 = "I" , |
857 | const std::string& n9 = "J" , |
858 | const std::string& n10 = "K" , |
859 | const std::string& n11 = "L" , |
860 | const std::string& n12 = "M" , |
861 | const std::string& n13 = "N" , |
862 | const std::string& n14 = "O" , |
863 | const std::string& n15 = "P" , |
864 | const std::string& n16 = "Q" , |
865 | const std::string& n17 = "R" , |
866 | const std::string& n18 = "S" , |
867 | const std::string& n19 = "T" , |
868 | const std::string& n20 = "U" , |
869 | const std::string& n21 = "V" , |
870 | const std::string& n22 = "W" , |
871 | const std::string& n23 = "X" , |
872 | const std::string& n24 = "Y" , |
873 | const std::string& n25 = "Z" , |
874 | const std::string& n26 = "A1" , |
875 | const std::string& n27 = "B1" , |
876 | const std::string& n28 = "C1" , |
877 | const std::string& n29 = "D1" , |
878 | const std::string& n30 = "E1" , |
879 | const std::string& n31 = "F1" , |
880 | const std::string& n32 = "G1" , |
881 | const std::string& n33 = "H1" , |
882 | const std::string& n34 = "I1" , |
883 | const std::string& n35 = "J1" , |
884 | const std::string& n36 = "K1" , |
885 | const std::string& n37 = "L1" , |
886 | const std::string& n38 = "M1" ) |
887 | { |
888 | if (!_pNames) |
889 | { |
890 | _pNames = new NameVec; |
891 | _pNames->push_back(n0); |
892 | _pNames->push_back(n1); |
893 | _pNames->push_back(n2); |
894 | _pNames->push_back(n3); |
895 | _pNames->push_back(n4); |
896 | _pNames->push_back(n5); |
897 | _pNames->push_back(n6); |
898 | _pNames->push_back(n7); |
899 | _pNames->push_back(n8); |
900 | _pNames->push_back(n9); |
901 | _pNames->push_back(n10); |
902 | _pNames->push_back(n11); |
903 | _pNames->push_back(n12); |
904 | _pNames->push_back(n13); |
905 | _pNames->push_back(n14); |
906 | _pNames->push_back(n15); |
907 | _pNames->push_back(n16); |
908 | _pNames->push_back(n17); |
909 | _pNames->push_back(n18); |
910 | _pNames->push_back(n19); |
911 | _pNames->push_back(n20); |
912 | _pNames->push_back(n21); |
913 | _pNames->push_back(n22); |
914 | _pNames->push_back(n23); |
915 | _pNames->push_back(n24); |
916 | _pNames->push_back(n25); |
917 | _pNames->push_back(n26); |
918 | _pNames->push_back(n27); |
919 | _pNames->push_back(n28); |
920 | _pNames->push_back(n29); |
921 | _pNames->push_back(n30); |
922 | _pNames->push_back(n31); |
923 | _pNames->push_back(n32); |
924 | _pNames->push_back(n33); |
925 | _pNames->push_back(n34); |
926 | _pNames->push_back(n35); |
927 | _pNames->push_back(n36); |
928 | _pNames->push_back(n37); |
929 | _pNames->push_back(n38); |
930 | } |
931 | } |
932 | |
933 | NameVecPtr _pNames; |
934 | }; |
935 | |
936 | |
937 | template<class T0, |
938 | class T1, |
939 | class T2, |
940 | class T3, |
941 | class T4, |
942 | class T5, |
943 | class T6, |
944 | class T7, |
945 | class T8, |
946 | class T9, |
947 | class T10, |
948 | class T11, |
949 | class T12, |
950 | class T13, |
951 | class T14, |
952 | class T15, |
953 | class T16, |
954 | class T17, |
955 | class T18, |
956 | class T19, |
957 | class T20, |
958 | class T21, |
959 | class T22, |
960 | class T23, |
961 | class T24, |
962 | class T25, |
963 | class T26, |
964 | class T27, |
965 | class T28, |
966 | class T29, |
967 | class T30, |
968 | class T31, |
969 | class T32, |
970 | class T33, |
971 | class T34, |
972 | class T35, |
973 | class T36, |
974 | class T37> |
975 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,NullTypeList>: |
976 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37> |
977 | { |
978 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37> TupleType; |
979 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37>::Type Type; |
980 | typedef std::vector<std::string> NameVec; |
981 | typedef SharedPtr<NameVec> NameVecPtr; |
982 | |
983 | NamedTuple(): _pNames(0) |
984 | { |
985 | init(); |
986 | } |
987 | |
988 | NamedTuple(const NameVecPtr& rNames) |
989 | { |
990 | if (rNames->size() != TupleType::length) |
991 | throw InvalidArgumentException("Wrong names vector length." ); |
992 | |
993 | _pNames = rNames; |
994 | } |
995 | |
996 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
997 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
998 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
999 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
1000 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
1001 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
1002 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
1003 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
1004 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
1005 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
1006 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
1007 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
1008 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
1009 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
1010 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
1011 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
1012 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
1013 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
1014 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
1015 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
1016 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
1017 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
1018 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
1019 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
1020 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
1021 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
1022 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
1023 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
1024 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
1025 | typename TypeWrapper<T29>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
1026 | typename TypeWrapper<T30>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
1027 | typename TypeWrapper<T31>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
1028 | typename TypeWrapper<T32>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32), |
1029 | typename TypeWrapper<T33>::CONSTTYPE& t33 = POCO_TYPEWRAPPER_DEFAULTVALUE(T33), |
1030 | typename TypeWrapper<T34>::CONSTTYPE& t34 = POCO_TYPEWRAPPER_DEFAULTVALUE(T34), |
1031 | typename TypeWrapper<T35>::CONSTTYPE& t35 = POCO_TYPEWRAPPER_DEFAULTVALUE(T35), |
1032 | typename TypeWrapper<T36>::CONSTTYPE& t36 = POCO_TYPEWRAPPER_DEFAULTVALUE(T36), |
1033 | typename TypeWrapper<T37>::CONSTTYPE& t37 = POCO_TYPEWRAPPER_DEFAULTVALUE(T37)): |
1034 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37), |
1035 | _pNames(0) |
1036 | { |
1037 | init(); |
1038 | } |
1039 | |
1040 | NamedTuple(const NameVecPtr& rNames, |
1041 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
1042 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
1043 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
1044 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
1045 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
1046 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
1047 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
1048 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
1049 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
1050 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
1051 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
1052 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
1053 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
1054 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
1055 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
1056 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
1057 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
1058 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
1059 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
1060 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
1061 | typename TypeWrapper<T0>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
1062 | typename TypeWrapper<T1>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
1063 | typename TypeWrapper<T2>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
1064 | typename TypeWrapper<T3>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
1065 | typename TypeWrapper<T4>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
1066 | typename TypeWrapper<T5>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
1067 | typename TypeWrapper<T6>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
1068 | typename TypeWrapper<T7>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
1069 | typename TypeWrapper<T8>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
1070 | typename TypeWrapper<T9>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
1071 | typename TypeWrapper<T10>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
1072 | typename TypeWrapper<T11>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
1073 | typename TypeWrapper<T12>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32), |
1074 | typename TypeWrapper<T13>::CONSTTYPE& t33 = POCO_TYPEWRAPPER_DEFAULTVALUE(T33), |
1075 | typename TypeWrapper<T14>::CONSTTYPE& t34 = POCO_TYPEWRAPPER_DEFAULTVALUE(T34), |
1076 | typename TypeWrapper<T15>::CONSTTYPE& t35 = POCO_TYPEWRAPPER_DEFAULTVALUE(T35), |
1077 | typename TypeWrapper<T16>::CONSTTYPE& t36 = POCO_TYPEWRAPPER_DEFAULTVALUE(T36), |
1078 | typename TypeWrapper<T17>::CONSTTYPE& t37 = POCO_TYPEWRAPPER_DEFAULTVALUE(T37)): |
1079 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37) |
1080 | { |
1081 | if (rNames->size() != TupleType::length) |
1082 | throw InvalidArgumentException("Wrong names vector length." ); |
1083 | |
1084 | _pNames = rNames; |
1085 | } |
1086 | |
1087 | NamedTuple(const std::string& n0, |
1088 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
1089 | const std::string& n1 = "B" , |
1090 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
1091 | const std::string& n2 = "C" , |
1092 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
1093 | const std::string& n3 = "D" , |
1094 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
1095 | const std::string& n4 = "E" , |
1096 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
1097 | const std::string& n5 = "F" , |
1098 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
1099 | const std::string& n6 = "G" , |
1100 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
1101 | const std::string& n7 = "H" , |
1102 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
1103 | const std::string& n8 = "I" , |
1104 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
1105 | const std::string& n9 = "J" , |
1106 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
1107 | const std::string& n10 = "K" , |
1108 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
1109 | const std::string& n11 = "L" , |
1110 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
1111 | const std::string& n12 = "M" , |
1112 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
1113 | const std::string& n13 = "N" , |
1114 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
1115 | const std::string& n14 = "O" , |
1116 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
1117 | const std::string& n15 = "P" , |
1118 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
1119 | const std::string& n16 = "Q" , |
1120 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
1121 | const std::string& n17 = "R" , |
1122 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
1123 | const std::string& n18 = "S" , |
1124 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
1125 | const std::string& n19 = "T" , |
1126 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
1127 | const std::string& n20 = "U" , |
1128 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
1129 | const std::string& n21 = "V" , |
1130 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
1131 | const std::string& n22 = "W" , |
1132 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
1133 | const std::string& n23 = "X" , |
1134 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
1135 | const std::string& n24 = "Y" , |
1136 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
1137 | const std::string& n25 = "Z" , |
1138 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
1139 | const std::string& n26 = "A1" , |
1140 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
1141 | const std::string& n27 = "B1" , |
1142 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
1143 | const std::string& n28 = "C1" , |
1144 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
1145 | const std::string& n29 = "D1" , |
1146 | typename TypeWrapper<T29>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
1147 | const std::string& n30 = "E1" , |
1148 | typename TypeWrapper<T30>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
1149 | const std::string& n31 = "F1" , |
1150 | typename TypeWrapper<T31>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
1151 | const std::string& n32 = "G1" , |
1152 | typename TypeWrapper<T32>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32), |
1153 | const std::string& n33 = "H1" , |
1154 | typename TypeWrapper<T33>::CONSTTYPE& t33 = POCO_TYPEWRAPPER_DEFAULTVALUE(T33), |
1155 | const std::string& n34 = "I1" , |
1156 | typename TypeWrapper<T34>::CONSTTYPE& t34 = POCO_TYPEWRAPPER_DEFAULTVALUE(T34), |
1157 | const std::string& n35 = "J1" , |
1158 | typename TypeWrapper<T35>::CONSTTYPE& t35 = POCO_TYPEWRAPPER_DEFAULTVALUE(T35), |
1159 | const std::string& n36 = "K1" , |
1160 | typename TypeWrapper<T36>::CONSTTYPE& t36 = POCO_TYPEWRAPPER_DEFAULTVALUE(T36), |
1161 | const std::string& n37 = "L1" , |
1162 | typename TypeWrapper<T37>::CONSTTYPE& t37 = POCO_TYPEWRAPPER_DEFAULTVALUE(T37)): |
1163 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37), |
1164 | _pNames(0) |
1165 | { |
1166 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31,n32,n33,n34,n35,n36,n37); |
1167 | } |
1168 | |
1169 | const DynamicAny get(const std::string& name) const |
1170 | { |
1171 | NameVec::const_iterator it = _pNames->begin(); |
1172 | NameVec::const_iterator itEnd = _pNames->end(); |
1173 | |
1174 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
1175 | { |
1176 | if (name == *it) |
1177 | { |
1178 | switch (counter) |
1179 | { |
1180 | case 0: return TupleType::template get<0>(); |
1181 | case 1: return TupleType::template get<1>(); |
1182 | case 2: return TupleType::template get<2>(); |
1183 | case 3: return TupleType::template get<3>(); |
1184 | case 4: return TupleType::template get<4>(); |
1185 | case 5: return TupleType::template get<5>(); |
1186 | case 6: return TupleType::template get<6>(); |
1187 | case 7: return TupleType::template get<7>(); |
1188 | case 8: return TupleType::template get<8>(); |
1189 | case 9: return TupleType::template get<9>(); |
1190 | case 10: return TupleType::template get<10>(); |
1191 | case 11: return TupleType::template get<11>(); |
1192 | case 12: return TupleType::template get<12>(); |
1193 | case 13: return TupleType::template get<13>(); |
1194 | case 14: return TupleType::template get<14>(); |
1195 | case 15: return TupleType::template get<15>(); |
1196 | case 16: return TupleType::template get<16>(); |
1197 | case 17: return TupleType::template get<17>(); |
1198 | case 18: return TupleType::template get<18>(); |
1199 | case 19: return TupleType::template get<19>(); |
1200 | case 20: return TupleType::template get<20>(); |
1201 | case 21: return TupleType::template get<21>(); |
1202 | case 22: return TupleType::template get<22>(); |
1203 | case 23: return TupleType::template get<23>(); |
1204 | case 24: return TupleType::template get<24>(); |
1205 | case 25: return TupleType::template get<25>(); |
1206 | case 26: return TupleType::template get<26>(); |
1207 | case 27: return TupleType::template get<27>(); |
1208 | case 28: return TupleType::template get<28>(); |
1209 | case 29: return TupleType::template get<29>(); |
1210 | case 30: return TupleType::template get<30>(); |
1211 | case 31: return TupleType::template get<31>(); |
1212 | case 32: return TupleType::template get<32>(); |
1213 | case 33: return TupleType::template get<33>(); |
1214 | case 34: return TupleType::template get<34>(); |
1215 | case 35: return TupleType::template get<35>(); |
1216 | case 36: return TupleType::template get<36>(); |
1217 | case 37: return TupleType::template get<37>(); |
1218 | default: throw RangeException(); |
1219 | } |
1220 | } |
1221 | } |
1222 | |
1223 | throw NotFoundException("Name not found: " + name); |
1224 | } |
1225 | |
1226 | const DynamicAny operator [] (const std::string& name) const |
1227 | { |
1228 | return get(name); |
1229 | } |
1230 | |
1231 | template<int N> |
1232 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
1233 | { |
1234 | return TupleType::template get<N>(); |
1235 | } |
1236 | |
1237 | template<int N> |
1238 | typename TypeGetter<N, Type>::HeadType& get() |
1239 | { |
1240 | return TupleType::template get<N>(); |
1241 | } |
1242 | |
1243 | template<int N> |
1244 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
1245 | { |
1246 | return TupleType::template set<N>(val); |
1247 | } |
1248 | |
1249 | const NameVecPtr& names() |
1250 | { |
1251 | return _pNames; |
1252 | } |
1253 | |
1254 | void setName(std::size_t index, const std::string& name) |
1255 | { |
1256 | if (index >= _pNames->size()) |
1257 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
1258 | |
1259 | (*_pNames)[index] = name; |
1260 | } |
1261 | |
1262 | const std::string& getName(std::size_t index) |
1263 | { |
1264 | if (index >= _pNames->size()) |
1265 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
1266 | |
1267 | return (*_pNames)[index]; |
1268 | } |
1269 | |
1270 | bool operator == (const NamedTuple& other) const |
1271 | { |
1272 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
1273 | } |
1274 | |
1275 | bool operator != (const NamedTuple& other) const |
1276 | { |
1277 | return !(*this == other); |
1278 | } |
1279 | |
1280 | bool operator < (const NamedTuple& other) const |
1281 | { |
1282 | TupleType th(*this); |
1283 | TupleType oth(other); |
1284 | |
1285 | return (th < oth && _pNames == other._pNames) || |
1286 | (th == oth && _pNames < other._pNames) || |
1287 | (th < oth && _pNames < other._pNames); |
1288 | } |
1289 | |
1290 | private: |
1291 | void init(const std::string& n0 = "A" , |
1292 | const std::string& n1 = "B" , |
1293 | const std::string& n2 = "C" , |
1294 | const std::string& n3 = "D" , |
1295 | const std::string& n4 = "E" , |
1296 | const std::string& n5 = "F" , |
1297 | const std::string& n6 = "G" , |
1298 | const std::string& n7 = "H" , |
1299 | const std::string& n8 = "I" , |
1300 | const std::string& n9 = "J" , |
1301 | const std::string& n10 = "K" , |
1302 | const std::string& n11 = "L" , |
1303 | const std::string& n12 = "M" , |
1304 | const std::string& n13 = "N" , |
1305 | const std::string& n14 = "O" , |
1306 | const std::string& n15 = "P" , |
1307 | const std::string& n16 = "Q" , |
1308 | const std::string& n17 = "R" , |
1309 | const std::string& n18 = "S" , |
1310 | const std::string& n19 = "T" , |
1311 | const std::string& n20 = "U" , |
1312 | const std::string& n21 = "V" , |
1313 | const std::string& n22 = "W" , |
1314 | const std::string& n23 = "X" , |
1315 | const std::string& n24 = "Y" , |
1316 | const std::string& n25 = "Z" , |
1317 | const std::string& n26 = "A1" , |
1318 | const std::string& n27 = "B1" , |
1319 | const std::string& n28 = "C1" , |
1320 | const std::string& n29 = "D1" , |
1321 | const std::string& n30 = "E1" , |
1322 | const std::string& n31 = "F1" , |
1323 | const std::string& n32 = "G1" , |
1324 | const std::string& n33 = "H1" , |
1325 | const std::string& n34 = "I1" , |
1326 | const std::string& n35 = "J1" , |
1327 | const std::string& n36 = "K1" , |
1328 | const std::string& n37 = "L1" ) |
1329 | { |
1330 | if (!_pNames) |
1331 | { |
1332 | _pNames = new NameVec; |
1333 | _pNames->push_back(n0); |
1334 | _pNames->push_back(n1); |
1335 | _pNames->push_back(n2); |
1336 | _pNames->push_back(n3); |
1337 | _pNames->push_back(n4); |
1338 | _pNames->push_back(n5); |
1339 | _pNames->push_back(n6); |
1340 | _pNames->push_back(n7); |
1341 | _pNames->push_back(n8); |
1342 | _pNames->push_back(n9); |
1343 | _pNames->push_back(n10); |
1344 | _pNames->push_back(n11); |
1345 | _pNames->push_back(n12); |
1346 | _pNames->push_back(n13); |
1347 | _pNames->push_back(n14); |
1348 | _pNames->push_back(n15); |
1349 | _pNames->push_back(n16); |
1350 | _pNames->push_back(n17); |
1351 | _pNames->push_back(n18); |
1352 | _pNames->push_back(n19); |
1353 | _pNames->push_back(n20); |
1354 | _pNames->push_back(n21); |
1355 | _pNames->push_back(n22); |
1356 | _pNames->push_back(n23); |
1357 | _pNames->push_back(n24); |
1358 | _pNames->push_back(n25); |
1359 | _pNames->push_back(n26); |
1360 | _pNames->push_back(n27); |
1361 | _pNames->push_back(n28); |
1362 | _pNames->push_back(n29); |
1363 | _pNames->push_back(n30); |
1364 | _pNames->push_back(n31); |
1365 | _pNames->push_back(n32); |
1366 | _pNames->push_back(n33); |
1367 | _pNames->push_back(n34); |
1368 | _pNames->push_back(n35); |
1369 | _pNames->push_back(n36); |
1370 | _pNames->push_back(n37); |
1371 | } |
1372 | } |
1373 | |
1374 | NameVecPtr _pNames; |
1375 | }; |
1376 | |
1377 | |
1378 | template<class T0, |
1379 | class T1, |
1380 | class T2, |
1381 | class T3, |
1382 | class T4, |
1383 | class T5, |
1384 | class T6, |
1385 | class T7, |
1386 | class T8, |
1387 | class T9, |
1388 | class T10, |
1389 | class T11, |
1390 | class T12, |
1391 | class T13, |
1392 | class T14, |
1393 | class T15, |
1394 | class T16, |
1395 | class T17, |
1396 | class T18, |
1397 | class T19, |
1398 | class T20, |
1399 | class T21, |
1400 | class T22, |
1401 | class T23, |
1402 | class T24, |
1403 | class T25, |
1404 | class T26, |
1405 | class T27, |
1406 | class T28, |
1407 | class T29, |
1408 | class T30, |
1409 | class T31, |
1410 | class T32, |
1411 | class T33, |
1412 | class T34, |
1413 | class T35, |
1414 | class T36> |
1415 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,NullTypeList>: |
1416 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36> |
1417 | { |
1418 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36> TupleType; |
1419 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36>::Type Type; |
1420 | typedef std::vector<std::string> NameVec; |
1421 | typedef SharedPtr<NameVec> NameVecPtr; |
1422 | |
1423 | NamedTuple(): _pNames(0) |
1424 | { |
1425 | init(); |
1426 | } |
1427 | |
1428 | NamedTuple(const NameVecPtr& rNames) |
1429 | { |
1430 | if (rNames->size() != TupleType::length) |
1431 | throw InvalidArgumentException("Wrong names vector length." ); |
1432 | |
1433 | _pNames = rNames; |
1434 | } |
1435 | |
1436 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
1437 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
1438 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
1439 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
1440 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
1441 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
1442 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
1443 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
1444 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
1445 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
1446 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
1447 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
1448 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
1449 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
1450 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
1451 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
1452 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
1453 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
1454 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
1455 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
1456 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
1457 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
1458 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
1459 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
1460 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
1461 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
1462 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
1463 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
1464 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
1465 | typename TypeWrapper<T29>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
1466 | typename TypeWrapper<T30>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
1467 | typename TypeWrapper<T31>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
1468 | typename TypeWrapper<T32>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32), |
1469 | typename TypeWrapper<T33>::CONSTTYPE& t33 = POCO_TYPEWRAPPER_DEFAULTVALUE(T33), |
1470 | typename TypeWrapper<T34>::CONSTTYPE& t34 = POCO_TYPEWRAPPER_DEFAULTVALUE(T34), |
1471 | typename TypeWrapper<T35>::CONSTTYPE& t35 = POCO_TYPEWRAPPER_DEFAULTVALUE(T35), |
1472 | typename TypeWrapper<T36>::CONSTTYPE& t36 = POCO_TYPEWRAPPER_DEFAULTVALUE(T36)): |
1473 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36), |
1474 | _pNames(0) |
1475 | { |
1476 | init(); |
1477 | } |
1478 | |
1479 | NamedTuple(const NameVecPtr& rNames, |
1480 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
1481 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
1482 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
1483 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
1484 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
1485 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
1486 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
1487 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
1488 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
1489 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
1490 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
1491 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
1492 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
1493 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
1494 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
1495 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
1496 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
1497 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
1498 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
1499 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
1500 | typename TypeWrapper<T0>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
1501 | typename TypeWrapper<T1>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
1502 | typename TypeWrapper<T2>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
1503 | typename TypeWrapper<T3>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
1504 | typename TypeWrapper<T4>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
1505 | typename TypeWrapper<T5>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
1506 | typename TypeWrapper<T6>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
1507 | typename TypeWrapper<T7>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
1508 | typename TypeWrapper<T8>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
1509 | typename TypeWrapper<T9>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
1510 | typename TypeWrapper<T10>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
1511 | typename TypeWrapper<T11>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
1512 | typename TypeWrapper<T12>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32), |
1513 | typename TypeWrapper<T13>::CONSTTYPE& t33 = POCO_TYPEWRAPPER_DEFAULTVALUE(T33), |
1514 | typename TypeWrapper<T14>::CONSTTYPE& t34 = POCO_TYPEWRAPPER_DEFAULTVALUE(T34), |
1515 | typename TypeWrapper<T15>::CONSTTYPE& t35 = POCO_TYPEWRAPPER_DEFAULTVALUE(T35), |
1516 | typename TypeWrapper<T16>::CONSTTYPE& t36 = POCO_TYPEWRAPPER_DEFAULTVALUE(T36)): |
1517 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36) |
1518 | { |
1519 | if (rNames->size() != TupleType::length) |
1520 | throw InvalidArgumentException("Wrong names vector length." ); |
1521 | |
1522 | _pNames = rNames; |
1523 | } |
1524 | |
1525 | NamedTuple(const std::string& n0, |
1526 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
1527 | const std::string& n1 = "B" , |
1528 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
1529 | const std::string& n2 = "C" , |
1530 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
1531 | const std::string& n3 = "D" , |
1532 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
1533 | const std::string& n4 = "E" , |
1534 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
1535 | const std::string& n5 = "F" , |
1536 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
1537 | const std::string& n6 = "G" , |
1538 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
1539 | const std::string& n7 = "H" , |
1540 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
1541 | const std::string& n8 = "I" , |
1542 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
1543 | const std::string& n9 = "J" , |
1544 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
1545 | const std::string& n10 = "K" , |
1546 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
1547 | const std::string& n11 = "L" , |
1548 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
1549 | const std::string& n12 = "M" , |
1550 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
1551 | const std::string& n13 = "N" , |
1552 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
1553 | const std::string& n14 = "O" , |
1554 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
1555 | const std::string& n15 = "P" , |
1556 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
1557 | const std::string& n16 = "Q" , |
1558 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
1559 | const std::string& n17 = "R" , |
1560 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
1561 | const std::string& n18 = "S" , |
1562 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
1563 | const std::string& n19 = "T" , |
1564 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
1565 | const std::string& n20 = "U" , |
1566 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
1567 | const std::string& n21 = "V" , |
1568 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
1569 | const std::string& n22 = "W" , |
1570 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
1571 | const std::string& n23 = "X" , |
1572 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
1573 | const std::string& n24 = "Y" , |
1574 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
1575 | const std::string& n25 = "Z" , |
1576 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
1577 | const std::string& n26 = "A1" , |
1578 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
1579 | const std::string& n27 = "B1" , |
1580 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
1581 | const std::string& n28 = "C1" , |
1582 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
1583 | const std::string& n29 = "D1" , |
1584 | typename TypeWrapper<T29>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
1585 | const std::string& n30 = "E1" , |
1586 | typename TypeWrapper<T30>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
1587 | const std::string& n31 = "F1" , |
1588 | typename TypeWrapper<T31>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
1589 | const std::string& n32 = "G1" , |
1590 | typename TypeWrapper<T32>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32), |
1591 | const std::string& n33 = "H1" , |
1592 | typename TypeWrapper<T33>::CONSTTYPE& t33 = POCO_TYPEWRAPPER_DEFAULTVALUE(T33), |
1593 | const std::string& n34 = "I1" , |
1594 | typename TypeWrapper<T34>::CONSTTYPE& t34 = POCO_TYPEWRAPPER_DEFAULTVALUE(T34), |
1595 | const std::string& n35 = "J1" , |
1596 | typename TypeWrapper<T35>::CONSTTYPE& t35 = POCO_TYPEWRAPPER_DEFAULTVALUE(T35), |
1597 | const std::string& n36 = "K1" , |
1598 | typename TypeWrapper<T36>::CONSTTYPE& t36 = POCO_TYPEWRAPPER_DEFAULTVALUE(T36)): |
1599 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36), |
1600 | _pNames(0) |
1601 | { |
1602 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31,n32,n33,n34,n35,n36); |
1603 | } |
1604 | |
1605 | const DynamicAny get(const std::string& name) const |
1606 | { |
1607 | NameVec::const_iterator it = _pNames->begin(); |
1608 | NameVec::const_iterator itEnd = _pNames->end(); |
1609 | |
1610 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
1611 | { |
1612 | if (name == *it) |
1613 | { |
1614 | switch (counter) |
1615 | { |
1616 | case 0: return TupleType::template get<0>(); |
1617 | case 1: return TupleType::template get<1>(); |
1618 | case 2: return TupleType::template get<2>(); |
1619 | case 3: return TupleType::template get<3>(); |
1620 | case 4: return TupleType::template get<4>(); |
1621 | case 5: return TupleType::template get<5>(); |
1622 | case 6: return TupleType::template get<6>(); |
1623 | case 7: return TupleType::template get<7>(); |
1624 | case 8: return TupleType::template get<8>(); |
1625 | case 9: return TupleType::template get<9>(); |
1626 | case 10: return TupleType::template get<10>(); |
1627 | case 11: return TupleType::template get<11>(); |
1628 | case 12: return TupleType::template get<12>(); |
1629 | case 13: return TupleType::template get<13>(); |
1630 | case 14: return TupleType::template get<14>(); |
1631 | case 15: return TupleType::template get<15>(); |
1632 | case 16: return TupleType::template get<16>(); |
1633 | case 17: return TupleType::template get<17>(); |
1634 | case 18: return TupleType::template get<18>(); |
1635 | case 19: return TupleType::template get<19>(); |
1636 | case 20: return TupleType::template get<20>(); |
1637 | case 21: return TupleType::template get<21>(); |
1638 | case 22: return TupleType::template get<22>(); |
1639 | case 23: return TupleType::template get<23>(); |
1640 | case 24: return TupleType::template get<24>(); |
1641 | case 25: return TupleType::template get<25>(); |
1642 | case 26: return TupleType::template get<26>(); |
1643 | case 27: return TupleType::template get<27>(); |
1644 | case 28: return TupleType::template get<28>(); |
1645 | case 29: return TupleType::template get<29>(); |
1646 | case 30: return TupleType::template get<30>(); |
1647 | case 31: return TupleType::template get<31>(); |
1648 | case 32: return TupleType::template get<32>(); |
1649 | case 33: return TupleType::template get<33>(); |
1650 | case 34: return TupleType::template get<34>(); |
1651 | case 35: return TupleType::template get<35>(); |
1652 | case 36: return TupleType::template get<36>(); |
1653 | default: throw RangeException(); |
1654 | } |
1655 | } |
1656 | } |
1657 | |
1658 | throw NotFoundException("Name not found: " + name); |
1659 | } |
1660 | |
1661 | const DynamicAny operator [] (const std::string& name) const |
1662 | { |
1663 | return get(name); |
1664 | } |
1665 | |
1666 | template<int N> |
1667 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
1668 | { |
1669 | return TupleType::template get<N>(); |
1670 | } |
1671 | |
1672 | template<int N> |
1673 | typename TypeGetter<N, Type>::HeadType& get() |
1674 | { |
1675 | return TupleType::template get<N>(); |
1676 | } |
1677 | |
1678 | template<int N> |
1679 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
1680 | { |
1681 | return TupleType::template set<N>(val); |
1682 | } |
1683 | |
1684 | const NameVecPtr& names() |
1685 | { |
1686 | return _pNames; |
1687 | } |
1688 | |
1689 | void setName(std::size_t index, const std::string& name) |
1690 | { |
1691 | if (index >= _pNames->size()) |
1692 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
1693 | |
1694 | (*_pNames)[index] = name; |
1695 | } |
1696 | |
1697 | const std::string& getName(std::size_t index) |
1698 | { |
1699 | if (index >= _pNames->size()) |
1700 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
1701 | |
1702 | return (*_pNames)[index]; |
1703 | } |
1704 | |
1705 | bool operator == (const NamedTuple& other) const |
1706 | { |
1707 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
1708 | } |
1709 | |
1710 | bool operator != (const NamedTuple& other) const |
1711 | { |
1712 | return !(*this == other); |
1713 | } |
1714 | |
1715 | bool operator < (const NamedTuple& other) const |
1716 | { |
1717 | TupleType th(*this); |
1718 | TupleType oth(other); |
1719 | |
1720 | return (th < oth && _pNames == other._pNames) || |
1721 | (th == oth && _pNames < other._pNames) || |
1722 | (th < oth && _pNames < other._pNames); |
1723 | } |
1724 | |
1725 | private: |
1726 | void init(const std::string& n0 = "A" , |
1727 | const std::string& n1 = "B" , |
1728 | const std::string& n2 = "C" , |
1729 | const std::string& n3 = "D" , |
1730 | const std::string& n4 = "E" , |
1731 | const std::string& n5 = "F" , |
1732 | const std::string& n6 = "G" , |
1733 | const std::string& n7 = "H" , |
1734 | const std::string& n8 = "I" , |
1735 | const std::string& n9 = "J" , |
1736 | const std::string& n10 = "K" , |
1737 | const std::string& n11 = "L" , |
1738 | const std::string& n12 = "M" , |
1739 | const std::string& n13 = "N" , |
1740 | const std::string& n14 = "O" , |
1741 | const std::string& n15 = "P" , |
1742 | const std::string& n16 = "Q" , |
1743 | const std::string& n17 = "R" , |
1744 | const std::string& n18 = "S" , |
1745 | const std::string& n19 = "T" , |
1746 | const std::string& n20 = "U" , |
1747 | const std::string& n21 = "V" , |
1748 | const std::string& n22 = "W" , |
1749 | const std::string& n23 = "X" , |
1750 | const std::string& n24 = "Y" , |
1751 | const std::string& n25 = "Z" , |
1752 | const std::string& n26 = "A1" , |
1753 | const std::string& n27 = "B1" , |
1754 | const std::string& n28 = "C1" , |
1755 | const std::string& n29 = "D1" , |
1756 | const std::string& n30 = "E1" , |
1757 | const std::string& n31 = "F1" , |
1758 | const std::string& n32 = "G1" , |
1759 | const std::string& n33 = "H1" , |
1760 | const std::string& n34 = "I1" , |
1761 | const std::string& n35 = "J1" , |
1762 | const std::string& n36 = "K1" ) |
1763 | { |
1764 | if (!_pNames) |
1765 | { |
1766 | _pNames = new NameVec; |
1767 | _pNames->push_back(n0); |
1768 | _pNames->push_back(n1); |
1769 | _pNames->push_back(n2); |
1770 | _pNames->push_back(n3); |
1771 | _pNames->push_back(n4); |
1772 | _pNames->push_back(n5); |
1773 | _pNames->push_back(n6); |
1774 | _pNames->push_back(n7); |
1775 | _pNames->push_back(n8); |
1776 | _pNames->push_back(n9); |
1777 | _pNames->push_back(n10); |
1778 | _pNames->push_back(n11); |
1779 | _pNames->push_back(n12); |
1780 | _pNames->push_back(n13); |
1781 | _pNames->push_back(n14); |
1782 | _pNames->push_back(n15); |
1783 | _pNames->push_back(n16); |
1784 | _pNames->push_back(n17); |
1785 | _pNames->push_back(n18); |
1786 | _pNames->push_back(n19); |
1787 | _pNames->push_back(n20); |
1788 | _pNames->push_back(n21); |
1789 | _pNames->push_back(n22); |
1790 | _pNames->push_back(n23); |
1791 | _pNames->push_back(n24); |
1792 | _pNames->push_back(n25); |
1793 | _pNames->push_back(n26); |
1794 | _pNames->push_back(n27); |
1795 | _pNames->push_back(n28); |
1796 | _pNames->push_back(n29); |
1797 | _pNames->push_back(n30); |
1798 | _pNames->push_back(n31); |
1799 | _pNames->push_back(n32); |
1800 | _pNames->push_back(n33); |
1801 | _pNames->push_back(n34); |
1802 | _pNames->push_back(n35); |
1803 | _pNames->push_back(n36); |
1804 | } |
1805 | } |
1806 | |
1807 | NameVecPtr _pNames; |
1808 | }; |
1809 | |
1810 | |
1811 | template<class T0, |
1812 | class T1, |
1813 | class T2, |
1814 | class T3, |
1815 | class T4, |
1816 | class T5, |
1817 | class T6, |
1818 | class T7, |
1819 | class T8, |
1820 | class T9, |
1821 | class T10, |
1822 | class T11, |
1823 | class T12, |
1824 | class T13, |
1825 | class T14, |
1826 | class T15, |
1827 | class T16, |
1828 | class T17, |
1829 | class T18, |
1830 | class T19, |
1831 | class T20, |
1832 | class T21, |
1833 | class T22, |
1834 | class T23, |
1835 | class T24, |
1836 | class T25, |
1837 | class T26, |
1838 | class T27, |
1839 | class T28, |
1840 | class T29, |
1841 | class T30, |
1842 | class T31, |
1843 | class T32, |
1844 | class T33, |
1845 | class T34, |
1846 | class T35> |
1847 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,NullTypeList>: |
1848 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35> |
1849 | { |
1850 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35> TupleType; |
1851 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35>::Type Type; |
1852 | typedef std::vector<std::string> NameVec; |
1853 | typedef SharedPtr<NameVec> NameVecPtr; |
1854 | |
1855 | NamedTuple(): _pNames(0) |
1856 | { |
1857 | init(); |
1858 | } |
1859 | |
1860 | NamedTuple(const NameVecPtr& rNames) |
1861 | { |
1862 | if (rNames->size() != TupleType::length) |
1863 | throw InvalidArgumentException("Wrong names vector length." ); |
1864 | |
1865 | _pNames = rNames; |
1866 | } |
1867 | |
1868 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
1869 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
1870 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
1871 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
1872 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
1873 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
1874 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
1875 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
1876 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
1877 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
1878 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
1879 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
1880 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
1881 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
1882 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
1883 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
1884 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
1885 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
1886 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
1887 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
1888 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
1889 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
1890 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
1891 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
1892 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
1893 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
1894 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
1895 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
1896 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
1897 | typename TypeWrapper<T29>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
1898 | typename TypeWrapper<T30>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
1899 | typename TypeWrapper<T31>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
1900 | typename TypeWrapper<T32>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32), |
1901 | typename TypeWrapper<T33>::CONSTTYPE& t33 = POCO_TYPEWRAPPER_DEFAULTVALUE(T33), |
1902 | typename TypeWrapper<T34>::CONSTTYPE& t34 = POCO_TYPEWRAPPER_DEFAULTVALUE(T34), |
1903 | typename TypeWrapper<T35>::CONSTTYPE& t35 = POCO_TYPEWRAPPER_DEFAULTVALUE(T35)): |
1904 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35), |
1905 | _pNames(0) |
1906 | { |
1907 | init(); |
1908 | } |
1909 | |
1910 | NamedTuple(const NameVecPtr& rNames, |
1911 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
1912 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
1913 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
1914 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
1915 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
1916 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
1917 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
1918 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
1919 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
1920 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
1921 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
1922 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
1923 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
1924 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
1925 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
1926 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
1927 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
1928 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
1929 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
1930 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
1931 | typename TypeWrapper<T0>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
1932 | typename TypeWrapper<T1>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
1933 | typename TypeWrapper<T2>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
1934 | typename TypeWrapper<T3>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
1935 | typename TypeWrapper<T4>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
1936 | typename TypeWrapper<T5>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
1937 | typename TypeWrapper<T6>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
1938 | typename TypeWrapper<T7>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
1939 | typename TypeWrapper<T8>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
1940 | typename TypeWrapper<T9>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
1941 | typename TypeWrapper<T10>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
1942 | typename TypeWrapper<T11>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
1943 | typename TypeWrapper<T12>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32), |
1944 | typename TypeWrapper<T13>::CONSTTYPE& t33 = POCO_TYPEWRAPPER_DEFAULTVALUE(T33), |
1945 | typename TypeWrapper<T14>::CONSTTYPE& t34 = POCO_TYPEWRAPPER_DEFAULTVALUE(T34), |
1946 | typename TypeWrapper<T15>::CONSTTYPE& t35 = POCO_TYPEWRAPPER_DEFAULTVALUE(T35)): |
1947 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35) |
1948 | { |
1949 | if (rNames->size() != TupleType::length) |
1950 | throw InvalidArgumentException("Wrong names vector length." ); |
1951 | |
1952 | _pNames = rNames; |
1953 | } |
1954 | |
1955 | NamedTuple(const std::string& n0, |
1956 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
1957 | const std::string& n1 = "B" , |
1958 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
1959 | const std::string& n2 = "C" , |
1960 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
1961 | const std::string& n3 = "D" , |
1962 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
1963 | const std::string& n4 = "E" , |
1964 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
1965 | const std::string& n5 = "F" , |
1966 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
1967 | const std::string& n6 = "G" , |
1968 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
1969 | const std::string& n7 = "H" , |
1970 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
1971 | const std::string& n8 = "I" , |
1972 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
1973 | const std::string& n9 = "J" , |
1974 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
1975 | const std::string& n10 = "K" , |
1976 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
1977 | const std::string& n11 = "L" , |
1978 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
1979 | const std::string& n12 = "M" , |
1980 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
1981 | const std::string& n13 = "N" , |
1982 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
1983 | const std::string& n14 = "O" , |
1984 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
1985 | const std::string& n15 = "P" , |
1986 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
1987 | const std::string& n16 = "Q" , |
1988 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
1989 | const std::string& n17 = "R" , |
1990 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
1991 | const std::string& n18 = "S" , |
1992 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
1993 | const std::string& n19 = "T" , |
1994 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
1995 | const std::string& n20 = "U" , |
1996 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
1997 | const std::string& n21 = "V" , |
1998 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
1999 | const std::string& n22 = "W" , |
2000 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
2001 | const std::string& n23 = "X" , |
2002 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
2003 | const std::string& n24 = "Y" , |
2004 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
2005 | const std::string& n25 = "Z" , |
2006 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
2007 | const std::string& n26 = "A1" , |
2008 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
2009 | const std::string& n27 = "B1" , |
2010 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
2011 | const std::string& n28 = "C1" , |
2012 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
2013 | const std::string& n29 = "D1" , |
2014 | typename TypeWrapper<T29>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
2015 | const std::string& n30 = "E1" , |
2016 | typename TypeWrapper<T30>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
2017 | const std::string& n31 = "F1" , |
2018 | typename TypeWrapper<T31>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
2019 | const std::string& n32 = "G1" , |
2020 | typename TypeWrapper<T32>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32), |
2021 | const std::string& n33 = "H1" , |
2022 | typename TypeWrapper<T33>::CONSTTYPE& t33 = POCO_TYPEWRAPPER_DEFAULTVALUE(T33), |
2023 | const std::string& n34 = "I1" , |
2024 | typename TypeWrapper<T34>::CONSTTYPE& t34 = POCO_TYPEWRAPPER_DEFAULTVALUE(T34), |
2025 | const std::string& n35 = "J1" , |
2026 | typename TypeWrapper<T35>::CONSTTYPE& t35 = POCO_TYPEWRAPPER_DEFAULTVALUE(T35)): |
2027 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35), |
2028 | _pNames(0) |
2029 | { |
2030 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31,n32,n33,n34,n35); |
2031 | } |
2032 | |
2033 | const DynamicAny get(const std::string& name) const |
2034 | { |
2035 | NameVec::const_iterator it = _pNames->begin(); |
2036 | NameVec::const_iterator itEnd = _pNames->end(); |
2037 | |
2038 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
2039 | { |
2040 | if (name == *it) |
2041 | { |
2042 | switch (counter) |
2043 | { |
2044 | case 0: return TupleType::template get<0>(); |
2045 | case 1: return TupleType::template get<1>(); |
2046 | case 2: return TupleType::template get<2>(); |
2047 | case 3: return TupleType::template get<3>(); |
2048 | case 4: return TupleType::template get<4>(); |
2049 | case 5: return TupleType::template get<5>(); |
2050 | case 6: return TupleType::template get<6>(); |
2051 | case 7: return TupleType::template get<7>(); |
2052 | case 8: return TupleType::template get<8>(); |
2053 | case 9: return TupleType::template get<9>(); |
2054 | case 10: return TupleType::template get<10>(); |
2055 | case 11: return TupleType::template get<11>(); |
2056 | case 12: return TupleType::template get<12>(); |
2057 | case 13: return TupleType::template get<13>(); |
2058 | case 14: return TupleType::template get<14>(); |
2059 | case 15: return TupleType::template get<15>(); |
2060 | case 16: return TupleType::template get<16>(); |
2061 | case 17: return TupleType::template get<17>(); |
2062 | case 18: return TupleType::template get<18>(); |
2063 | case 19: return TupleType::template get<19>(); |
2064 | case 20: return TupleType::template get<20>(); |
2065 | case 21: return TupleType::template get<21>(); |
2066 | case 22: return TupleType::template get<22>(); |
2067 | case 23: return TupleType::template get<23>(); |
2068 | case 24: return TupleType::template get<24>(); |
2069 | case 25: return TupleType::template get<25>(); |
2070 | case 26: return TupleType::template get<26>(); |
2071 | case 27: return TupleType::template get<27>(); |
2072 | case 28: return TupleType::template get<28>(); |
2073 | case 29: return TupleType::template get<29>(); |
2074 | case 30: return TupleType::template get<30>(); |
2075 | case 31: return TupleType::template get<31>(); |
2076 | case 32: return TupleType::template get<32>(); |
2077 | case 33: return TupleType::template get<33>(); |
2078 | case 34: return TupleType::template get<34>(); |
2079 | case 35: return TupleType::template get<35>(); |
2080 | default: throw RangeException(); |
2081 | } |
2082 | } |
2083 | } |
2084 | |
2085 | throw NotFoundException("Name not found: " + name); |
2086 | } |
2087 | |
2088 | const DynamicAny operator [] (const std::string& name) const |
2089 | { |
2090 | return get(name); |
2091 | } |
2092 | |
2093 | template<int N> |
2094 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
2095 | { |
2096 | return TupleType::template get<N>(); |
2097 | } |
2098 | |
2099 | template<int N> |
2100 | typename TypeGetter<N, Type>::HeadType& get() |
2101 | { |
2102 | return TupleType::template get<N>(); |
2103 | } |
2104 | |
2105 | template<int N> |
2106 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
2107 | { |
2108 | return TupleType::template set<N>(val); |
2109 | } |
2110 | |
2111 | const NameVecPtr& names() |
2112 | { |
2113 | return _pNames; |
2114 | } |
2115 | |
2116 | void setName(std::size_t index, const std::string& name) |
2117 | { |
2118 | if (index >= _pNames->size()) |
2119 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
2120 | |
2121 | (*_pNames)[index] = name; |
2122 | } |
2123 | |
2124 | const std::string& getName(std::size_t index) |
2125 | { |
2126 | if (index >= _pNames->size()) |
2127 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
2128 | |
2129 | return (*_pNames)[index]; |
2130 | } |
2131 | |
2132 | bool operator == (const NamedTuple& other) const |
2133 | { |
2134 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
2135 | } |
2136 | |
2137 | bool operator != (const NamedTuple& other) const |
2138 | { |
2139 | return !(*this == other); |
2140 | } |
2141 | |
2142 | bool operator < (const NamedTuple& other) const |
2143 | { |
2144 | TupleType th(*this); |
2145 | TupleType oth(other); |
2146 | |
2147 | return (th < oth && _pNames == other._pNames) || |
2148 | (th == oth && _pNames < other._pNames) || |
2149 | (th < oth && _pNames < other._pNames); |
2150 | } |
2151 | |
2152 | private: |
2153 | void init(const std::string& n0 = "A" , |
2154 | const std::string& n1 = "B" , |
2155 | const std::string& n2 = "C" , |
2156 | const std::string& n3 = "D" , |
2157 | const std::string& n4 = "E" , |
2158 | const std::string& n5 = "F" , |
2159 | const std::string& n6 = "G" , |
2160 | const std::string& n7 = "H" , |
2161 | const std::string& n8 = "I" , |
2162 | const std::string& n9 = "J" , |
2163 | const std::string& n10 = "K" , |
2164 | const std::string& n11 = "L" , |
2165 | const std::string& n12 = "M" , |
2166 | const std::string& n13 = "N" , |
2167 | const std::string& n14 = "O" , |
2168 | const std::string& n15 = "P" , |
2169 | const std::string& n16 = "Q" , |
2170 | const std::string& n17 = "R" , |
2171 | const std::string& n18 = "S" , |
2172 | const std::string& n19 = "T" , |
2173 | const std::string& n20 = "U" , |
2174 | const std::string& n21 = "V" , |
2175 | const std::string& n22 = "W" , |
2176 | const std::string& n23 = "X" , |
2177 | const std::string& n24 = "Y" , |
2178 | const std::string& n25 = "Z" , |
2179 | const std::string& n26 = "A1" , |
2180 | const std::string& n27 = "B1" , |
2181 | const std::string& n28 = "C1" , |
2182 | const std::string& n29 = "D1" , |
2183 | const std::string& n30 = "E1" , |
2184 | const std::string& n31 = "F1" , |
2185 | const std::string& n32 = "G1" , |
2186 | const std::string& n33 = "H1" , |
2187 | const std::string& n34 = "I1" , |
2188 | const std::string& n35 = "J1" ) |
2189 | { |
2190 | if (!_pNames) |
2191 | { |
2192 | _pNames = new NameVec; |
2193 | _pNames->push_back(n0); |
2194 | _pNames->push_back(n1); |
2195 | _pNames->push_back(n2); |
2196 | _pNames->push_back(n3); |
2197 | _pNames->push_back(n4); |
2198 | _pNames->push_back(n5); |
2199 | _pNames->push_back(n6); |
2200 | _pNames->push_back(n7); |
2201 | _pNames->push_back(n8); |
2202 | _pNames->push_back(n9); |
2203 | _pNames->push_back(n10); |
2204 | _pNames->push_back(n11); |
2205 | _pNames->push_back(n12); |
2206 | _pNames->push_back(n13); |
2207 | _pNames->push_back(n14); |
2208 | _pNames->push_back(n15); |
2209 | _pNames->push_back(n16); |
2210 | _pNames->push_back(n17); |
2211 | _pNames->push_back(n18); |
2212 | _pNames->push_back(n19); |
2213 | _pNames->push_back(n20); |
2214 | _pNames->push_back(n21); |
2215 | _pNames->push_back(n22); |
2216 | _pNames->push_back(n23); |
2217 | _pNames->push_back(n24); |
2218 | _pNames->push_back(n25); |
2219 | _pNames->push_back(n26); |
2220 | _pNames->push_back(n27); |
2221 | _pNames->push_back(n28); |
2222 | _pNames->push_back(n29); |
2223 | _pNames->push_back(n30); |
2224 | _pNames->push_back(n31); |
2225 | _pNames->push_back(n32); |
2226 | _pNames->push_back(n33); |
2227 | _pNames->push_back(n34); |
2228 | _pNames->push_back(n35); |
2229 | } |
2230 | } |
2231 | |
2232 | NameVecPtr _pNames; |
2233 | }; |
2234 | |
2235 | |
2236 | template<class T0, |
2237 | class T1, |
2238 | class T2, |
2239 | class T3, |
2240 | class T4, |
2241 | class T5, |
2242 | class T6, |
2243 | class T7, |
2244 | class T8, |
2245 | class T9, |
2246 | class T10, |
2247 | class T11, |
2248 | class T12, |
2249 | class T13, |
2250 | class T14, |
2251 | class T15, |
2252 | class T16, |
2253 | class T17, |
2254 | class T18, |
2255 | class T19, |
2256 | class T20, |
2257 | class T21, |
2258 | class T22, |
2259 | class T23, |
2260 | class T24, |
2261 | class T25, |
2262 | class T26, |
2263 | class T27, |
2264 | class T28, |
2265 | class T29, |
2266 | class T30, |
2267 | class T31, |
2268 | class T32, |
2269 | class T33, |
2270 | class T34> |
2271 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,NullTypeList>: |
2272 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34> |
2273 | { |
2274 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34> TupleType; |
2275 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34>::Type Type; |
2276 | typedef std::vector<std::string> NameVec; |
2277 | typedef SharedPtr<NameVec> NameVecPtr; |
2278 | |
2279 | NamedTuple(): _pNames(0) |
2280 | { |
2281 | init(); |
2282 | } |
2283 | |
2284 | NamedTuple(const NameVecPtr& rNames) |
2285 | { |
2286 | if (rNames->size() != TupleType::length) |
2287 | throw InvalidArgumentException("Wrong names vector length." ); |
2288 | |
2289 | _pNames = rNames; |
2290 | } |
2291 | |
2292 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
2293 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
2294 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
2295 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
2296 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
2297 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
2298 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
2299 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
2300 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
2301 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
2302 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
2303 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
2304 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
2305 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
2306 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
2307 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
2308 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
2309 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
2310 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
2311 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
2312 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
2313 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
2314 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
2315 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
2316 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
2317 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
2318 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
2319 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
2320 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
2321 | typename TypeWrapper<T29>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
2322 | typename TypeWrapper<T30>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
2323 | typename TypeWrapper<T31>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
2324 | typename TypeWrapper<T32>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32), |
2325 | typename TypeWrapper<T33>::CONSTTYPE& t33 = POCO_TYPEWRAPPER_DEFAULTVALUE(T33), |
2326 | typename TypeWrapper<T34>::CONSTTYPE& t34 = POCO_TYPEWRAPPER_DEFAULTVALUE(T34)): |
2327 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34), |
2328 | _pNames(0) |
2329 | { |
2330 | init(); |
2331 | } |
2332 | |
2333 | NamedTuple(const NameVecPtr& rNames, |
2334 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
2335 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
2336 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
2337 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
2338 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
2339 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
2340 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
2341 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
2342 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
2343 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
2344 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
2345 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
2346 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
2347 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
2348 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
2349 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
2350 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
2351 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
2352 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
2353 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
2354 | typename TypeWrapper<T0>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
2355 | typename TypeWrapper<T1>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
2356 | typename TypeWrapper<T2>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
2357 | typename TypeWrapper<T3>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
2358 | typename TypeWrapper<T4>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
2359 | typename TypeWrapper<T5>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
2360 | typename TypeWrapper<T6>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
2361 | typename TypeWrapper<T7>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
2362 | typename TypeWrapper<T8>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
2363 | typename TypeWrapper<T9>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
2364 | typename TypeWrapper<T10>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
2365 | typename TypeWrapper<T11>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
2366 | typename TypeWrapper<T12>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32), |
2367 | typename TypeWrapper<T13>::CONSTTYPE& t33 = POCO_TYPEWRAPPER_DEFAULTVALUE(T33), |
2368 | typename TypeWrapper<T14>::CONSTTYPE& t34 = POCO_TYPEWRAPPER_DEFAULTVALUE(T34)): |
2369 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34) |
2370 | { |
2371 | if (rNames->size() != TupleType::length) |
2372 | throw InvalidArgumentException("Wrong names vector length." ); |
2373 | |
2374 | _pNames = rNames; |
2375 | } |
2376 | |
2377 | NamedTuple(const std::string& n0, |
2378 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
2379 | const std::string& n1 = "B" , |
2380 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
2381 | const std::string& n2 = "C" , |
2382 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
2383 | const std::string& n3 = "D" , |
2384 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
2385 | const std::string& n4 = "E" , |
2386 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
2387 | const std::string& n5 = "F" , |
2388 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
2389 | const std::string& n6 = "G" , |
2390 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
2391 | const std::string& n7 = "H" , |
2392 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
2393 | const std::string& n8 = "I" , |
2394 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
2395 | const std::string& n9 = "J" , |
2396 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
2397 | const std::string& n10 = "K" , |
2398 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
2399 | const std::string& n11 = "L" , |
2400 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
2401 | const std::string& n12 = "M" , |
2402 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
2403 | const std::string& n13 = "N" , |
2404 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
2405 | const std::string& n14 = "O" , |
2406 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
2407 | const std::string& n15 = "P" , |
2408 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
2409 | const std::string& n16 = "Q" , |
2410 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
2411 | const std::string& n17 = "R" , |
2412 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
2413 | const std::string& n18 = "S" , |
2414 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
2415 | const std::string& n19 = "T" , |
2416 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
2417 | const std::string& n20 = "U" , |
2418 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
2419 | const std::string& n21 = "V" , |
2420 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
2421 | const std::string& n22 = "W" , |
2422 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
2423 | const std::string& n23 = "X" , |
2424 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
2425 | const std::string& n24 = "Y" , |
2426 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
2427 | const std::string& n25 = "Z" , |
2428 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
2429 | const std::string& n26 = "A1" , |
2430 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
2431 | const std::string& n27 = "B1" , |
2432 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
2433 | const std::string& n28 = "C1" , |
2434 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
2435 | const std::string& n29 = "D1" , |
2436 | typename TypeWrapper<T29>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
2437 | const std::string& n30 = "E1" , |
2438 | typename TypeWrapper<T30>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
2439 | const std::string& n31 = "F1" , |
2440 | typename TypeWrapper<T31>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
2441 | const std::string& n32 = "G1" , |
2442 | typename TypeWrapper<T32>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32), |
2443 | const std::string& n33 = "H1" , |
2444 | typename TypeWrapper<T33>::CONSTTYPE& t33 = POCO_TYPEWRAPPER_DEFAULTVALUE(T33), |
2445 | const std::string& n34 = "I1" , |
2446 | typename TypeWrapper<T34>::CONSTTYPE& t34 = POCO_TYPEWRAPPER_DEFAULTVALUE(T34)): |
2447 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34), |
2448 | _pNames(0) |
2449 | { |
2450 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31,n32,n33,n34); |
2451 | } |
2452 | |
2453 | const DynamicAny get(const std::string& name) const |
2454 | { |
2455 | NameVec::const_iterator it = _pNames->begin(); |
2456 | NameVec::const_iterator itEnd = _pNames->end(); |
2457 | |
2458 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
2459 | { |
2460 | if (name == *it) |
2461 | { |
2462 | switch (counter) |
2463 | { |
2464 | case 0: return TupleType::template get<0>(); |
2465 | case 1: return TupleType::template get<1>(); |
2466 | case 2: return TupleType::template get<2>(); |
2467 | case 3: return TupleType::template get<3>(); |
2468 | case 4: return TupleType::template get<4>(); |
2469 | case 5: return TupleType::template get<5>(); |
2470 | case 6: return TupleType::template get<6>(); |
2471 | case 7: return TupleType::template get<7>(); |
2472 | case 8: return TupleType::template get<8>(); |
2473 | case 9: return TupleType::template get<9>(); |
2474 | case 10: return TupleType::template get<10>(); |
2475 | case 11: return TupleType::template get<11>(); |
2476 | case 12: return TupleType::template get<12>(); |
2477 | case 13: return TupleType::template get<13>(); |
2478 | case 14: return TupleType::template get<14>(); |
2479 | case 15: return TupleType::template get<15>(); |
2480 | case 16: return TupleType::template get<16>(); |
2481 | case 17: return TupleType::template get<17>(); |
2482 | case 18: return TupleType::template get<18>(); |
2483 | case 19: return TupleType::template get<19>(); |
2484 | case 20: return TupleType::template get<20>(); |
2485 | case 21: return TupleType::template get<21>(); |
2486 | case 22: return TupleType::template get<22>(); |
2487 | case 23: return TupleType::template get<23>(); |
2488 | case 24: return TupleType::template get<24>(); |
2489 | case 25: return TupleType::template get<25>(); |
2490 | case 26: return TupleType::template get<26>(); |
2491 | case 27: return TupleType::template get<27>(); |
2492 | case 28: return TupleType::template get<28>(); |
2493 | case 29: return TupleType::template get<29>(); |
2494 | case 30: return TupleType::template get<30>(); |
2495 | case 31: return TupleType::template get<31>(); |
2496 | case 32: return TupleType::template get<32>(); |
2497 | case 33: return TupleType::template get<33>(); |
2498 | case 34: return TupleType::template get<34>(); |
2499 | default: throw RangeException(); |
2500 | } |
2501 | } |
2502 | } |
2503 | |
2504 | throw NotFoundException("Name not found: " + name); |
2505 | } |
2506 | |
2507 | const DynamicAny operator [] (const std::string& name) const |
2508 | { |
2509 | return get(name); |
2510 | } |
2511 | |
2512 | template<int N> |
2513 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
2514 | { |
2515 | return TupleType::template get<N>(); |
2516 | } |
2517 | |
2518 | template<int N> |
2519 | typename TypeGetter<N, Type>::HeadType& get() |
2520 | { |
2521 | return TupleType::template get<N>(); |
2522 | } |
2523 | |
2524 | template<int N> |
2525 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
2526 | { |
2527 | return TupleType::template set<N>(val); |
2528 | } |
2529 | |
2530 | const NameVecPtr& names() |
2531 | { |
2532 | return _pNames; |
2533 | } |
2534 | |
2535 | void setName(std::size_t index, const std::string& name) |
2536 | { |
2537 | if (index >= _pNames->size()) |
2538 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
2539 | |
2540 | (*_pNames)[index] = name; |
2541 | } |
2542 | |
2543 | const std::string& getName(std::size_t index) |
2544 | { |
2545 | if (index >= _pNames->size()) |
2546 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
2547 | |
2548 | return (*_pNames)[index]; |
2549 | } |
2550 | |
2551 | bool operator == (const NamedTuple& other) const |
2552 | { |
2553 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
2554 | } |
2555 | |
2556 | bool operator != (const NamedTuple& other) const |
2557 | { |
2558 | return !(*this == other); |
2559 | } |
2560 | |
2561 | bool operator < (const NamedTuple& other) const |
2562 | { |
2563 | TupleType th(*this); |
2564 | TupleType oth(other); |
2565 | |
2566 | return (th < oth && _pNames == other._pNames) || |
2567 | (th == oth && _pNames < other._pNames) || |
2568 | (th < oth && _pNames < other._pNames); |
2569 | } |
2570 | |
2571 | private: |
2572 | void init(const std::string& n0 = "A" , |
2573 | const std::string& n1 = "B" , |
2574 | const std::string& n2 = "C" , |
2575 | const std::string& n3 = "D" , |
2576 | const std::string& n4 = "E" , |
2577 | const std::string& n5 = "F" , |
2578 | const std::string& n6 = "G" , |
2579 | const std::string& n7 = "H" , |
2580 | const std::string& n8 = "I" , |
2581 | const std::string& n9 = "J" , |
2582 | const std::string& n10 = "K" , |
2583 | const std::string& n11 = "L" , |
2584 | const std::string& n12 = "M" , |
2585 | const std::string& n13 = "N" , |
2586 | const std::string& n14 = "O" , |
2587 | const std::string& n15 = "P" , |
2588 | const std::string& n16 = "Q" , |
2589 | const std::string& n17 = "R" , |
2590 | const std::string& n18 = "S" , |
2591 | const std::string& n19 = "T" , |
2592 | const std::string& n20 = "U" , |
2593 | const std::string& n21 = "V" , |
2594 | const std::string& n22 = "W" , |
2595 | const std::string& n23 = "X" , |
2596 | const std::string& n24 = "Y" , |
2597 | const std::string& n25 = "Z" , |
2598 | const std::string& n26 = "A1" , |
2599 | const std::string& n27 = "B1" , |
2600 | const std::string& n28 = "C1" , |
2601 | const std::string& n29 = "D1" , |
2602 | const std::string& n30 = "E1" , |
2603 | const std::string& n31 = "F1" , |
2604 | const std::string& n32 = "G1" , |
2605 | const std::string& n33 = "H1" , |
2606 | const std::string& n34 = "I1" ) |
2607 | { |
2608 | if (!_pNames) |
2609 | { |
2610 | _pNames = new NameVec; |
2611 | _pNames->push_back(n0); |
2612 | _pNames->push_back(n1); |
2613 | _pNames->push_back(n2); |
2614 | _pNames->push_back(n3); |
2615 | _pNames->push_back(n4); |
2616 | _pNames->push_back(n5); |
2617 | _pNames->push_back(n6); |
2618 | _pNames->push_back(n7); |
2619 | _pNames->push_back(n8); |
2620 | _pNames->push_back(n9); |
2621 | _pNames->push_back(n10); |
2622 | _pNames->push_back(n11); |
2623 | _pNames->push_back(n12); |
2624 | _pNames->push_back(n13); |
2625 | _pNames->push_back(n14); |
2626 | _pNames->push_back(n15); |
2627 | _pNames->push_back(n16); |
2628 | _pNames->push_back(n17); |
2629 | _pNames->push_back(n18); |
2630 | _pNames->push_back(n19); |
2631 | _pNames->push_back(n20); |
2632 | _pNames->push_back(n21); |
2633 | _pNames->push_back(n22); |
2634 | _pNames->push_back(n23); |
2635 | _pNames->push_back(n24); |
2636 | _pNames->push_back(n25); |
2637 | _pNames->push_back(n26); |
2638 | _pNames->push_back(n27); |
2639 | _pNames->push_back(n28); |
2640 | _pNames->push_back(n29); |
2641 | _pNames->push_back(n30); |
2642 | _pNames->push_back(n31); |
2643 | _pNames->push_back(n32); |
2644 | _pNames->push_back(n33); |
2645 | _pNames->push_back(n34); |
2646 | } |
2647 | } |
2648 | |
2649 | NameVecPtr _pNames; |
2650 | }; |
2651 | |
2652 | |
2653 | template<class T0, |
2654 | class T1, |
2655 | class T2, |
2656 | class T3, |
2657 | class T4, |
2658 | class T5, |
2659 | class T6, |
2660 | class T7, |
2661 | class T8, |
2662 | class T9, |
2663 | class T10, |
2664 | class T11, |
2665 | class T12, |
2666 | class T13, |
2667 | class T14, |
2668 | class T15, |
2669 | class T16, |
2670 | class T17, |
2671 | class T18, |
2672 | class T19, |
2673 | class T20, |
2674 | class T21, |
2675 | class T22, |
2676 | class T23, |
2677 | class T24, |
2678 | class T25, |
2679 | class T26, |
2680 | class T27, |
2681 | class T28, |
2682 | class T29, |
2683 | class T30, |
2684 | class T31, |
2685 | class T32, |
2686 | class T33> |
2687 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,NullTypeList>: |
2688 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33> |
2689 | { |
2690 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33> TupleType; |
2691 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33>::Type Type; |
2692 | typedef std::vector<std::string> NameVec; |
2693 | typedef SharedPtr<NameVec> NameVecPtr; |
2694 | |
2695 | NamedTuple(): _pNames(0) |
2696 | { |
2697 | init(); |
2698 | } |
2699 | |
2700 | NamedTuple(const NameVecPtr& rNames) |
2701 | { |
2702 | if (rNames->size() != TupleType::length) |
2703 | throw InvalidArgumentException("Wrong names vector length." ); |
2704 | |
2705 | _pNames = rNames; |
2706 | } |
2707 | |
2708 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
2709 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
2710 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
2711 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
2712 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
2713 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
2714 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
2715 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
2716 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
2717 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
2718 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
2719 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
2720 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
2721 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
2722 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
2723 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
2724 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
2725 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
2726 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
2727 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
2728 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
2729 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
2730 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
2731 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
2732 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
2733 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
2734 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
2735 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
2736 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
2737 | typename TypeWrapper<T29>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
2738 | typename TypeWrapper<T30>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
2739 | typename TypeWrapper<T31>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
2740 | typename TypeWrapper<T32>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32), |
2741 | typename TypeWrapper<T33>::CONSTTYPE& t33 = POCO_TYPEWRAPPER_DEFAULTVALUE(T33)): |
2742 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33), |
2743 | _pNames(0) |
2744 | { |
2745 | init(); |
2746 | } |
2747 | |
2748 | NamedTuple(const NameVecPtr& rNames, |
2749 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
2750 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
2751 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
2752 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
2753 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
2754 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
2755 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
2756 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
2757 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
2758 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
2759 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
2760 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
2761 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
2762 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
2763 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
2764 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
2765 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
2766 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
2767 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
2768 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
2769 | typename TypeWrapper<T0>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
2770 | typename TypeWrapper<T1>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
2771 | typename TypeWrapper<T2>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
2772 | typename TypeWrapper<T3>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
2773 | typename TypeWrapper<T4>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
2774 | typename TypeWrapper<T5>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
2775 | typename TypeWrapper<T6>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
2776 | typename TypeWrapper<T7>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
2777 | typename TypeWrapper<T8>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
2778 | typename TypeWrapper<T9>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
2779 | typename TypeWrapper<T10>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
2780 | typename TypeWrapper<T11>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
2781 | typename TypeWrapper<T12>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32), |
2782 | typename TypeWrapper<T13>::CONSTTYPE& t33 = POCO_TYPEWRAPPER_DEFAULTVALUE(T33)): |
2783 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33) |
2784 | { |
2785 | if (rNames->size() != TupleType::length) |
2786 | throw InvalidArgumentException("Wrong names vector length." ); |
2787 | |
2788 | _pNames = rNames; |
2789 | } |
2790 | |
2791 | NamedTuple(const std::string& n0, |
2792 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
2793 | const std::string& n1 = "B" , |
2794 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
2795 | const std::string& n2 = "C" , |
2796 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
2797 | const std::string& n3 = "D" , |
2798 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
2799 | const std::string& n4 = "E" , |
2800 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
2801 | const std::string& n5 = "F" , |
2802 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
2803 | const std::string& n6 = "G" , |
2804 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
2805 | const std::string& n7 = "H" , |
2806 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
2807 | const std::string& n8 = "I" , |
2808 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
2809 | const std::string& n9 = "J" , |
2810 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
2811 | const std::string& n10 = "K" , |
2812 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
2813 | const std::string& n11 = "L" , |
2814 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
2815 | const std::string& n12 = "M" , |
2816 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
2817 | const std::string& n13 = "N" , |
2818 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
2819 | const std::string& n14 = "O" , |
2820 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
2821 | const std::string& n15 = "P" , |
2822 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
2823 | const std::string& n16 = "Q" , |
2824 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
2825 | const std::string& n17 = "R" , |
2826 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
2827 | const std::string& n18 = "S" , |
2828 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
2829 | const std::string& n19 = "T" , |
2830 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
2831 | const std::string& n20 = "U" , |
2832 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
2833 | const std::string& n21 = "V" , |
2834 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
2835 | const std::string& n22 = "W" , |
2836 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
2837 | const std::string& n23 = "X" , |
2838 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
2839 | const std::string& n24 = "Y" , |
2840 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
2841 | const std::string& n25 = "Z" , |
2842 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
2843 | const std::string& n26 = "A1" , |
2844 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
2845 | const std::string& n27 = "B1" , |
2846 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
2847 | const std::string& n28 = "C1" , |
2848 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
2849 | const std::string& n29 = "D1" , |
2850 | typename TypeWrapper<T29>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
2851 | const std::string& n30 = "E1" , |
2852 | typename TypeWrapper<T30>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
2853 | const std::string& n31 = "F1" , |
2854 | typename TypeWrapper<T31>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
2855 | const std::string& n32 = "G1" , |
2856 | typename TypeWrapper<T32>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32), |
2857 | const std::string& n33 = "H1" , |
2858 | typename TypeWrapper<T33>::CONSTTYPE& t33 = POCO_TYPEWRAPPER_DEFAULTVALUE(T33)): |
2859 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33), |
2860 | _pNames(0) |
2861 | { |
2862 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31,n32,n33); |
2863 | } |
2864 | |
2865 | const DynamicAny get(const std::string& name) const |
2866 | { |
2867 | NameVec::const_iterator it = _pNames->begin(); |
2868 | NameVec::const_iterator itEnd = _pNames->end(); |
2869 | |
2870 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
2871 | { |
2872 | if (name == *it) |
2873 | { |
2874 | switch (counter) |
2875 | { |
2876 | case 0: return TupleType::template get<0>(); |
2877 | case 1: return TupleType::template get<1>(); |
2878 | case 2: return TupleType::template get<2>(); |
2879 | case 3: return TupleType::template get<3>(); |
2880 | case 4: return TupleType::template get<4>(); |
2881 | case 5: return TupleType::template get<5>(); |
2882 | case 6: return TupleType::template get<6>(); |
2883 | case 7: return TupleType::template get<7>(); |
2884 | case 8: return TupleType::template get<8>(); |
2885 | case 9: return TupleType::template get<9>(); |
2886 | case 10: return TupleType::template get<10>(); |
2887 | case 11: return TupleType::template get<11>(); |
2888 | case 12: return TupleType::template get<12>(); |
2889 | case 13: return TupleType::template get<13>(); |
2890 | case 14: return TupleType::template get<14>(); |
2891 | case 15: return TupleType::template get<15>(); |
2892 | case 16: return TupleType::template get<16>(); |
2893 | case 17: return TupleType::template get<17>(); |
2894 | case 18: return TupleType::template get<18>(); |
2895 | case 19: return TupleType::template get<19>(); |
2896 | case 20: return TupleType::template get<20>(); |
2897 | case 21: return TupleType::template get<21>(); |
2898 | case 22: return TupleType::template get<22>(); |
2899 | case 23: return TupleType::template get<23>(); |
2900 | case 24: return TupleType::template get<24>(); |
2901 | case 25: return TupleType::template get<25>(); |
2902 | case 26: return TupleType::template get<26>(); |
2903 | case 27: return TupleType::template get<27>(); |
2904 | case 28: return TupleType::template get<28>(); |
2905 | case 29: return TupleType::template get<29>(); |
2906 | case 30: return TupleType::template get<30>(); |
2907 | case 31: return TupleType::template get<31>(); |
2908 | case 32: return TupleType::template get<32>(); |
2909 | case 33: return TupleType::template get<33>(); |
2910 | default: throw RangeException(); |
2911 | } |
2912 | } |
2913 | } |
2914 | |
2915 | throw NotFoundException("Name not found: " + name); |
2916 | } |
2917 | |
2918 | const DynamicAny operator [] (const std::string& name) const |
2919 | { |
2920 | return get(name); |
2921 | } |
2922 | |
2923 | template<int N> |
2924 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
2925 | { |
2926 | return TupleType::template get<N>(); |
2927 | } |
2928 | |
2929 | template<int N> |
2930 | typename TypeGetter<N, Type>::HeadType& get() |
2931 | { |
2932 | return TupleType::template get<N>(); |
2933 | } |
2934 | |
2935 | template<int N> |
2936 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
2937 | { |
2938 | return TupleType::template set<N>(val); |
2939 | } |
2940 | |
2941 | const NameVecPtr& names() |
2942 | { |
2943 | return _pNames; |
2944 | } |
2945 | |
2946 | void setName(std::size_t index, const std::string& name) |
2947 | { |
2948 | if (index >= _pNames->size()) |
2949 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
2950 | |
2951 | (*_pNames)[index] = name; |
2952 | } |
2953 | |
2954 | const std::string& getName(std::size_t index) |
2955 | { |
2956 | if (index >= _pNames->size()) |
2957 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
2958 | |
2959 | return (*_pNames)[index]; |
2960 | } |
2961 | |
2962 | bool operator == (const NamedTuple& other) const |
2963 | { |
2964 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
2965 | } |
2966 | |
2967 | bool operator != (const NamedTuple& other) const |
2968 | { |
2969 | return !(*this == other); |
2970 | } |
2971 | |
2972 | bool operator < (const NamedTuple& other) const |
2973 | { |
2974 | TupleType th(*this); |
2975 | TupleType oth(other); |
2976 | |
2977 | return (th < oth && _pNames == other._pNames) || |
2978 | (th == oth && _pNames < other._pNames) || |
2979 | (th < oth && _pNames < other._pNames); |
2980 | } |
2981 | |
2982 | private: |
2983 | void init(const std::string& n0 = "A" , |
2984 | const std::string& n1 = "B" , |
2985 | const std::string& n2 = "C" , |
2986 | const std::string& n3 = "D" , |
2987 | const std::string& n4 = "E" , |
2988 | const std::string& n5 = "F" , |
2989 | const std::string& n6 = "G" , |
2990 | const std::string& n7 = "H" , |
2991 | const std::string& n8 = "I" , |
2992 | const std::string& n9 = "J" , |
2993 | const std::string& n10 = "K" , |
2994 | const std::string& n11 = "L" , |
2995 | const std::string& n12 = "M" , |
2996 | const std::string& n13 = "N" , |
2997 | const std::string& n14 = "O" , |
2998 | const std::string& n15 = "P" , |
2999 | const std::string& n16 = "Q" , |
3000 | const std::string& n17 = "R" , |
3001 | const std::string& n18 = "S" , |
3002 | const std::string& n19 = "T" , |
3003 | const std::string& n20 = "U" , |
3004 | const std::string& n21 = "V" , |
3005 | const std::string& n22 = "W" , |
3006 | const std::string& n23 = "X" , |
3007 | const std::string& n24 = "Y" , |
3008 | const std::string& n25 = "Z" , |
3009 | const std::string& n26 = "A1" , |
3010 | const std::string& n27 = "B1" , |
3011 | const std::string& n28 = "C1" , |
3012 | const std::string& n29 = "D1" , |
3013 | const std::string& n30 = "E1" , |
3014 | const std::string& n31 = "F1" , |
3015 | const std::string& n32 = "G1" , |
3016 | const std::string& n33 = "H1" ) |
3017 | { |
3018 | if (!_pNames) |
3019 | { |
3020 | _pNames = new NameVec; |
3021 | _pNames->push_back(n0); |
3022 | _pNames->push_back(n1); |
3023 | _pNames->push_back(n2); |
3024 | _pNames->push_back(n3); |
3025 | _pNames->push_back(n4); |
3026 | _pNames->push_back(n5); |
3027 | _pNames->push_back(n6); |
3028 | _pNames->push_back(n7); |
3029 | _pNames->push_back(n8); |
3030 | _pNames->push_back(n9); |
3031 | _pNames->push_back(n10); |
3032 | _pNames->push_back(n11); |
3033 | _pNames->push_back(n12); |
3034 | _pNames->push_back(n13); |
3035 | _pNames->push_back(n14); |
3036 | _pNames->push_back(n15); |
3037 | _pNames->push_back(n16); |
3038 | _pNames->push_back(n17); |
3039 | _pNames->push_back(n18); |
3040 | _pNames->push_back(n19); |
3041 | _pNames->push_back(n20); |
3042 | _pNames->push_back(n21); |
3043 | _pNames->push_back(n22); |
3044 | _pNames->push_back(n23); |
3045 | _pNames->push_back(n24); |
3046 | _pNames->push_back(n25); |
3047 | _pNames->push_back(n26); |
3048 | _pNames->push_back(n27); |
3049 | _pNames->push_back(n28); |
3050 | _pNames->push_back(n29); |
3051 | _pNames->push_back(n30); |
3052 | _pNames->push_back(n31); |
3053 | _pNames->push_back(n32); |
3054 | _pNames->push_back(n33); |
3055 | } |
3056 | } |
3057 | |
3058 | NameVecPtr _pNames; |
3059 | }; |
3060 | |
3061 | |
3062 | template<class T0, |
3063 | class T1, |
3064 | class T2, |
3065 | class T3, |
3066 | class T4, |
3067 | class T5, |
3068 | class T6, |
3069 | class T7, |
3070 | class T8, |
3071 | class T9, |
3072 | class T10, |
3073 | class T11, |
3074 | class T12, |
3075 | class T13, |
3076 | class T14, |
3077 | class T15, |
3078 | class T16, |
3079 | class T17, |
3080 | class T18, |
3081 | class T19, |
3082 | class T20, |
3083 | class T21, |
3084 | class T22, |
3085 | class T23, |
3086 | class T24, |
3087 | class T25, |
3088 | class T26, |
3089 | class T27, |
3090 | class T28, |
3091 | class T29, |
3092 | class T30, |
3093 | class T31, |
3094 | class T32> |
3095 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,NullTypeList>: |
3096 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32> |
3097 | { |
3098 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32> TupleType; |
3099 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32>::Type Type; |
3100 | typedef std::vector<std::string> NameVec; |
3101 | typedef SharedPtr<NameVec> NameVecPtr; |
3102 | |
3103 | NamedTuple(): _pNames(0) |
3104 | { |
3105 | init(); |
3106 | } |
3107 | |
3108 | NamedTuple(const NameVecPtr& rNames) |
3109 | { |
3110 | if (rNames->size() != TupleType::length) |
3111 | throw InvalidArgumentException("Wrong names vector length." ); |
3112 | |
3113 | _pNames = rNames; |
3114 | } |
3115 | |
3116 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
3117 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
3118 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
3119 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
3120 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
3121 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
3122 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
3123 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
3124 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
3125 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
3126 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
3127 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
3128 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
3129 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
3130 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
3131 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
3132 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
3133 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
3134 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
3135 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
3136 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
3137 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
3138 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
3139 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
3140 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
3141 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
3142 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
3143 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
3144 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
3145 | typename TypeWrapper<T29>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
3146 | typename TypeWrapper<T30>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
3147 | typename TypeWrapper<T31>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
3148 | typename TypeWrapper<T32>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32)): |
3149 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32), |
3150 | _pNames(0) |
3151 | { |
3152 | init(); |
3153 | } |
3154 | |
3155 | NamedTuple(const NameVecPtr& rNames, |
3156 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
3157 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
3158 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
3159 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
3160 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
3161 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
3162 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
3163 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
3164 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
3165 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
3166 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
3167 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
3168 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
3169 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
3170 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
3171 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
3172 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
3173 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
3174 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
3175 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
3176 | typename TypeWrapper<T0>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
3177 | typename TypeWrapper<T1>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
3178 | typename TypeWrapper<T2>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
3179 | typename TypeWrapper<T3>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
3180 | typename TypeWrapper<T4>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
3181 | typename TypeWrapper<T5>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
3182 | typename TypeWrapper<T6>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
3183 | typename TypeWrapper<T7>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
3184 | typename TypeWrapper<T8>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
3185 | typename TypeWrapper<T9>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
3186 | typename TypeWrapper<T10>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
3187 | typename TypeWrapper<T11>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
3188 | typename TypeWrapper<T12>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32)): |
3189 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32) |
3190 | { |
3191 | if (rNames->size() != TupleType::length) |
3192 | throw InvalidArgumentException("Wrong names vector length." ); |
3193 | |
3194 | _pNames = rNames; |
3195 | } |
3196 | |
3197 | NamedTuple(const std::string& n0, |
3198 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
3199 | const std::string& n1 = "B" , |
3200 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
3201 | const std::string& n2 = "C" , |
3202 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
3203 | const std::string& n3 = "D" , |
3204 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
3205 | const std::string& n4 = "E" , |
3206 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
3207 | const std::string& n5 = "F" , |
3208 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
3209 | const std::string& n6 = "G" , |
3210 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
3211 | const std::string& n7 = "H" , |
3212 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
3213 | const std::string& n8 = "I" , |
3214 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
3215 | const std::string& n9 = "J" , |
3216 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
3217 | const std::string& n10 = "K" , |
3218 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
3219 | const std::string& n11 = "L" , |
3220 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
3221 | const std::string& n12 = "M" , |
3222 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
3223 | const std::string& n13 = "N" , |
3224 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
3225 | const std::string& n14 = "O" , |
3226 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
3227 | const std::string& n15 = "P" , |
3228 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
3229 | const std::string& n16 = "Q" , |
3230 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
3231 | const std::string& n17 = "R" , |
3232 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
3233 | const std::string& n18 = "S" , |
3234 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
3235 | const std::string& n19 = "T" , |
3236 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
3237 | const std::string& n20 = "U" , |
3238 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
3239 | const std::string& n21 = "V" , |
3240 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
3241 | const std::string& n22 = "W" , |
3242 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
3243 | const std::string& n23 = "X" , |
3244 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
3245 | const std::string& n24 = "Y" , |
3246 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
3247 | const std::string& n25 = "Z" , |
3248 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
3249 | const std::string& n26 = "A1" , |
3250 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
3251 | const std::string& n27 = "B1" , |
3252 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
3253 | const std::string& n28 = "C1" , |
3254 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
3255 | const std::string& n29 = "D1" , |
3256 | typename TypeWrapper<T29>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
3257 | const std::string& n30 = "E1" , |
3258 | typename TypeWrapper<T30>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
3259 | const std::string& n31 = "F1" , |
3260 | typename TypeWrapper<T31>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31), |
3261 | const std::string& n32 = "G1" , |
3262 | typename TypeWrapper<T32>::CONSTTYPE& t32 = POCO_TYPEWRAPPER_DEFAULTVALUE(T32)): |
3263 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32), |
3264 | _pNames(0) |
3265 | { |
3266 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31,n32); |
3267 | } |
3268 | |
3269 | const DynamicAny get(const std::string& name) const |
3270 | { |
3271 | NameVec::const_iterator it = _pNames->begin(); |
3272 | NameVec::const_iterator itEnd = _pNames->end(); |
3273 | |
3274 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
3275 | { |
3276 | if (name == *it) |
3277 | { |
3278 | switch (counter) |
3279 | { |
3280 | case 0: return TupleType::template get<0>(); |
3281 | case 1: return TupleType::template get<1>(); |
3282 | case 2: return TupleType::template get<2>(); |
3283 | case 3: return TupleType::template get<3>(); |
3284 | case 4: return TupleType::template get<4>(); |
3285 | case 5: return TupleType::template get<5>(); |
3286 | case 6: return TupleType::template get<6>(); |
3287 | case 7: return TupleType::template get<7>(); |
3288 | case 8: return TupleType::template get<8>(); |
3289 | case 9: return TupleType::template get<9>(); |
3290 | case 10: return TupleType::template get<10>(); |
3291 | case 11: return TupleType::template get<11>(); |
3292 | case 12: return TupleType::template get<12>(); |
3293 | case 13: return TupleType::template get<13>(); |
3294 | case 14: return TupleType::template get<14>(); |
3295 | case 15: return TupleType::template get<15>(); |
3296 | case 16: return TupleType::template get<16>(); |
3297 | case 17: return TupleType::template get<17>(); |
3298 | case 18: return TupleType::template get<18>(); |
3299 | case 19: return TupleType::template get<19>(); |
3300 | case 20: return TupleType::template get<20>(); |
3301 | case 21: return TupleType::template get<21>(); |
3302 | case 22: return TupleType::template get<22>(); |
3303 | case 23: return TupleType::template get<23>(); |
3304 | case 24: return TupleType::template get<24>(); |
3305 | case 25: return TupleType::template get<25>(); |
3306 | case 26: return TupleType::template get<26>(); |
3307 | case 27: return TupleType::template get<27>(); |
3308 | case 28: return TupleType::template get<28>(); |
3309 | case 29: return TupleType::template get<29>(); |
3310 | case 30: return TupleType::template get<30>(); |
3311 | case 31: return TupleType::template get<31>(); |
3312 | case 32: return TupleType::template get<32>(); |
3313 | default: throw RangeException(); |
3314 | } |
3315 | } |
3316 | } |
3317 | |
3318 | throw NotFoundException("Name not found: " + name); |
3319 | } |
3320 | |
3321 | const DynamicAny operator [] (const std::string& name) const |
3322 | { |
3323 | return get(name); |
3324 | } |
3325 | |
3326 | template<int N> |
3327 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
3328 | { |
3329 | return TupleType::template get<N>(); |
3330 | } |
3331 | |
3332 | template<int N> |
3333 | typename TypeGetter<N, Type>::HeadType& get() |
3334 | { |
3335 | return TupleType::template get<N>(); |
3336 | } |
3337 | |
3338 | template<int N> |
3339 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
3340 | { |
3341 | return TupleType::template set<N>(val); |
3342 | } |
3343 | |
3344 | const NameVecPtr& names() |
3345 | { |
3346 | return _pNames; |
3347 | } |
3348 | |
3349 | void setName(std::size_t index, const std::string& name) |
3350 | { |
3351 | if (index >= _pNames->size()) |
3352 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
3353 | |
3354 | (*_pNames)[index] = name; |
3355 | } |
3356 | |
3357 | const std::string& getName(std::size_t index) |
3358 | { |
3359 | if (index >= _pNames->size()) |
3360 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
3361 | |
3362 | return (*_pNames)[index]; |
3363 | } |
3364 | |
3365 | bool operator == (const NamedTuple& other) const |
3366 | { |
3367 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
3368 | } |
3369 | |
3370 | bool operator != (const NamedTuple& other) const |
3371 | { |
3372 | return !(*this == other); |
3373 | } |
3374 | |
3375 | bool operator < (const NamedTuple& other) const |
3376 | { |
3377 | TupleType th(*this); |
3378 | TupleType oth(other); |
3379 | |
3380 | return (th < oth && _pNames == other._pNames) || |
3381 | (th == oth && _pNames < other._pNames) || |
3382 | (th < oth && _pNames < other._pNames); |
3383 | } |
3384 | |
3385 | private: |
3386 | void init(const std::string& n0 = "A" , |
3387 | const std::string& n1 = "B" , |
3388 | const std::string& n2 = "C" , |
3389 | const std::string& n3 = "D" , |
3390 | const std::string& n4 = "E" , |
3391 | const std::string& n5 = "F" , |
3392 | const std::string& n6 = "G" , |
3393 | const std::string& n7 = "H" , |
3394 | const std::string& n8 = "I" , |
3395 | const std::string& n9 = "J" , |
3396 | const std::string& n10 = "K" , |
3397 | const std::string& n11 = "L" , |
3398 | const std::string& n12 = "M" , |
3399 | const std::string& n13 = "N" , |
3400 | const std::string& n14 = "O" , |
3401 | const std::string& n15 = "P" , |
3402 | const std::string& n16 = "Q" , |
3403 | const std::string& n17 = "R" , |
3404 | const std::string& n18 = "S" , |
3405 | const std::string& n19 = "T" , |
3406 | const std::string& n20 = "U" , |
3407 | const std::string& n21 = "V" , |
3408 | const std::string& n22 = "W" , |
3409 | const std::string& n23 = "X" , |
3410 | const std::string& n24 = "Y" , |
3411 | const std::string& n25 = "Z" , |
3412 | const std::string& n26 = "A1" , |
3413 | const std::string& n27 = "B1" , |
3414 | const std::string& n28 = "C1" , |
3415 | const std::string& n29 = "D1" , |
3416 | const std::string& n30 = "E1" , |
3417 | const std::string& n31 = "F1" , |
3418 | const std::string& n32 = "G1" ) |
3419 | { |
3420 | if (!_pNames) |
3421 | { |
3422 | _pNames = new NameVec; |
3423 | _pNames->push_back(n0); |
3424 | _pNames->push_back(n1); |
3425 | _pNames->push_back(n2); |
3426 | _pNames->push_back(n3); |
3427 | _pNames->push_back(n4); |
3428 | _pNames->push_back(n5); |
3429 | _pNames->push_back(n6); |
3430 | _pNames->push_back(n7); |
3431 | _pNames->push_back(n8); |
3432 | _pNames->push_back(n9); |
3433 | _pNames->push_back(n10); |
3434 | _pNames->push_back(n11); |
3435 | _pNames->push_back(n12); |
3436 | _pNames->push_back(n13); |
3437 | _pNames->push_back(n14); |
3438 | _pNames->push_back(n15); |
3439 | _pNames->push_back(n16); |
3440 | _pNames->push_back(n17); |
3441 | _pNames->push_back(n18); |
3442 | _pNames->push_back(n19); |
3443 | _pNames->push_back(n20); |
3444 | _pNames->push_back(n21); |
3445 | _pNames->push_back(n22); |
3446 | _pNames->push_back(n23); |
3447 | _pNames->push_back(n24); |
3448 | _pNames->push_back(n25); |
3449 | _pNames->push_back(n26); |
3450 | _pNames->push_back(n27); |
3451 | _pNames->push_back(n28); |
3452 | _pNames->push_back(n29); |
3453 | _pNames->push_back(n30); |
3454 | _pNames->push_back(n31); |
3455 | _pNames->push_back(n32); |
3456 | } |
3457 | } |
3458 | |
3459 | NameVecPtr _pNames; |
3460 | }; |
3461 | |
3462 | |
3463 | template<class T0, |
3464 | class T1, |
3465 | class T2, |
3466 | class T3, |
3467 | class T4, |
3468 | class T5, |
3469 | class T6, |
3470 | class T7, |
3471 | class T8, |
3472 | class T9, |
3473 | class T10, |
3474 | class T11, |
3475 | class T12, |
3476 | class T13, |
3477 | class T14, |
3478 | class T15, |
3479 | class T16, |
3480 | class T17, |
3481 | class T18, |
3482 | class T19, |
3483 | class T20, |
3484 | class T21, |
3485 | class T22, |
3486 | class T23, |
3487 | class T24, |
3488 | class T25, |
3489 | class T26, |
3490 | class T27, |
3491 | class T28, |
3492 | class T29, |
3493 | class T30, |
3494 | class T31> |
3495 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,NullTypeList>: |
3496 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31> |
3497 | { |
3498 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31> TupleType; |
3499 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31>::Type Type; |
3500 | typedef std::vector<std::string> NameVec; |
3501 | typedef SharedPtr<NameVec> NameVecPtr; |
3502 | |
3503 | NamedTuple(): _pNames(0) |
3504 | { |
3505 | init(); |
3506 | } |
3507 | |
3508 | NamedTuple(const NameVecPtr& rNames) |
3509 | { |
3510 | if (rNames->size() != TupleType::length) |
3511 | throw InvalidArgumentException("Wrong names vector length." ); |
3512 | |
3513 | _pNames = rNames; |
3514 | } |
3515 | |
3516 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
3517 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
3518 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
3519 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
3520 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
3521 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
3522 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
3523 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
3524 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
3525 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
3526 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
3527 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
3528 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
3529 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
3530 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
3531 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
3532 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
3533 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
3534 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
3535 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
3536 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
3537 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
3538 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
3539 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
3540 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
3541 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
3542 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
3543 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
3544 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
3545 | typename TypeWrapper<T29>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
3546 | typename TypeWrapper<T30>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
3547 | typename TypeWrapper<T31>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31)): |
3548 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31), |
3549 | _pNames(0) |
3550 | { |
3551 | init(); |
3552 | } |
3553 | |
3554 | NamedTuple(const NameVecPtr& rNames, |
3555 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
3556 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
3557 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
3558 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
3559 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
3560 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
3561 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
3562 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
3563 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
3564 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
3565 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
3566 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
3567 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
3568 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
3569 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
3570 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
3571 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
3572 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
3573 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
3574 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
3575 | typename TypeWrapper<T0>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
3576 | typename TypeWrapper<T1>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
3577 | typename TypeWrapper<T2>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
3578 | typename TypeWrapper<T3>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
3579 | typename TypeWrapper<T4>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
3580 | typename TypeWrapper<T5>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
3581 | typename TypeWrapper<T6>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
3582 | typename TypeWrapper<T7>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
3583 | typename TypeWrapper<T8>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
3584 | typename TypeWrapper<T9>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
3585 | typename TypeWrapper<T10>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
3586 | typename TypeWrapper<T11>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31)): |
3587 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31) |
3588 | { |
3589 | if (rNames->size() != TupleType::length) |
3590 | throw InvalidArgumentException("Wrong names vector length." ); |
3591 | |
3592 | _pNames = rNames; |
3593 | } |
3594 | |
3595 | NamedTuple(const std::string& n0, |
3596 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
3597 | const std::string& n1 = "B" , |
3598 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
3599 | const std::string& n2 = "C" , |
3600 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
3601 | const std::string& n3 = "D" , |
3602 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
3603 | const std::string& n4 = "E" , |
3604 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
3605 | const std::string& n5 = "F" , |
3606 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
3607 | const std::string& n6 = "G" , |
3608 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
3609 | const std::string& n7 = "H" , |
3610 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
3611 | const std::string& n8 = "I" , |
3612 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
3613 | const std::string& n9 = "J" , |
3614 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
3615 | const std::string& n10 = "K" , |
3616 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
3617 | const std::string& n11 = "L" , |
3618 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
3619 | const std::string& n12 = "M" , |
3620 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
3621 | const std::string& n13 = "N" , |
3622 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
3623 | const std::string& n14 = "O" , |
3624 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
3625 | const std::string& n15 = "P" , |
3626 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
3627 | const std::string& n16 = "Q" , |
3628 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
3629 | const std::string& n17 = "R" , |
3630 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
3631 | const std::string& n18 = "S" , |
3632 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
3633 | const std::string& n19 = "T" , |
3634 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
3635 | const std::string& n20 = "U" , |
3636 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
3637 | const std::string& n21 = "V" , |
3638 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
3639 | const std::string& n22 = "W" , |
3640 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
3641 | const std::string& n23 = "X" , |
3642 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
3643 | const std::string& n24 = "Y" , |
3644 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
3645 | const std::string& n25 = "Z" , |
3646 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
3647 | const std::string& n26 = "A1" , |
3648 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
3649 | const std::string& n27 = "B1" , |
3650 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
3651 | const std::string& n28 = "C1" , |
3652 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
3653 | const std::string& n29 = "D1" , |
3654 | typename TypeWrapper<T29>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
3655 | const std::string& n30 = "E1" , |
3656 | typename TypeWrapper<T30>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30), |
3657 | const std::string& n31 = "F1" , |
3658 | typename TypeWrapper<T31>::CONSTTYPE& t31 = POCO_TYPEWRAPPER_DEFAULTVALUE(T31)): |
3659 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31), |
3660 | _pNames(0) |
3661 | { |
3662 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31); |
3663 | } |
3664 | |
3665 | const DynamicAny get(const std::string& name) const |
3666 | { |
3667 | NameVec::const_iterator it = _pNames->begin(); |
3668 | NameVec::const_iterator itEnd = _pNames->end(); |
3669 | |
3670 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
3671 | { |
3672 | if (name == *it) |
3673 | { |
3674 | switch (counter) |
3675 | { |
3676 | case 0: return TupleType::template get<0>(); |
3677 | case 1: return TupleType::template get<1>(); |
3678 | case 2: return TupleType::template get<2>(); |
3679 | case 3: return TupleType::template get<3>(); |
3680 | case 4: return TupleType::template get<4>(); |
3681 | case 5: return TupleType::template get<5>(); |
3682 | case 6: return TupleType::template get<6>(); |
3683 | case 7: return TupleType::template get<7>(); |
3684 | case 8: return TupleType::template get<8>(); |
3685 | case 9: return TupleType::template get<9>(); |
3686 | case 10: return TupleType::template get<10>(); |
3687 | case 11: return TupleType::template get<11>(); |
3688 | case 12: return TupleType::template get<12>(); |
3689 | case 13: return TupleType::template get<13>(); |
3690 | case 14: return TupleType::template get<14>(); |
3691 | case 15: return TupleType::template get<15>(); |
3692 | case 16: return TupleType::template get<16>(); |
3693 | case 17: return TupleType::template get<17>(); |
3694 | case 18: return TupleType::template get<18>(); |
3695 | case 19: return TupleType::template get<19>(); |
3696 | case 20: return TupleType::template get<20>(); |
3697 | case 21: return TupleType::template get<21>(); |
3698 | case 22: return TupleType::template get<22>(); |
3699 | case 23: return TupleType::template get<23>(); |
3700 | case 24: return TupleType::template get<24>(); |
3701 | case 25: return TupleType::template get<25>(); |
3702 | case 26: return TupleType::template get<26>(); |
3703 | case 27: return TupleType::template get<27>(); |
3704 | case 28: return TupleType::template get<28>(); |
3705 | case 29: return TupleType::template get<29>(); |
3706 | case 30: return TupleType::template get<30>(); |
3707 | case 31: return TupleType::template get<31>(); |
3708 | default: throw RangeException(); |
3709 | } |
3710 | } |
3711 | } |
3712 | |
3713 | throw NotFoundException("Name not found: " + name); |
3714 | } |
3715 | |
3716 | const DynamicAny operator [] (const std::string& name) const |
3717 | { |
3718 | return get(name); |
3719 | } |
3720 | |
3721 | template<int N> |
3722 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
3723 | { |
3724 | return TupleType::template get<N>(); |
3725 | } |
3726 | |
3727 | template<int N> |
3728 | typename TypeGetter<N, Type>::HeadType& get() |
3729 | { |
3730 | return TupleType::template get<N>(); |
3731 | } |
3732 | |
3733 | template<int N> |
3734 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
3735 | { |
3736 | return TupleType::template set<N>(val); |
3737 | } |
3738 | |
3739 | const NameVecPtr& names() |
3740 | { |
3741 | return _pNames; |
3742 | } |
3743 | |
3744 | void setName(std::size_t index, const std::string& name) |
3745 | { |
3746 | if (index >= _pNames->size()) |
3747 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
3748 | |
3749 | (*_pNames)[index] = name; |
3750 | } |
3751 | |
3752 | const std::string& getName(std::size_t index) |
3753 | { |
3754 | if (index >= _pNames->size()) |
3755 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
3756 | |
3757 | return (*_pNames)[index]; |
3758 | } |
3759 | |
3760 | bool operator == (const NamedTuple& other) const |
3761 | { |
3762 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
3763 | } |
3764 | |
3765 | bool operator != (const NamedTuple& other) const |
3766 | { |
3767 | return !(*this == other); |
3768 | } |
3769 | |
3770 | bool operator < (const NamedTuple& other) const |
3771 | { |
3772 | TupleType th(*this); |
3773 | TupleType oth(other); |
3774 | |
3775 | return (th < oth && _pNames == other._pNames) || |
3776 | (th == oth && _pNames < other._pNames) || |
3777 | (th < oth && _pNames < other._pNames); |
3778 | } |
3779 | |
3780 | private: |
3781 | void init(const std::string& n0 = "A" , |
3782 | const std::string& n1 = "B" , |
3783 | const std::string& n2 = "C" , |
3784 | const std::string& n3 = "D" , |
3785 | const std::string& n4 = "E" , |
3786 | const std::string& n5 = "F" , |
3787 | const std::string& n6 = "G" , |
3788 | const std::string& n7 = "H" , |
3789 | const std::string& n8 = "I" , |
3790 | const std::string& n9 = "J" , |
3791 | const std::string& n10 = "K" , |
3792 | const std::string& n11 = "L" , |
3793 | const std::string& n12 = "M" , |
3794 | const std::string& n13 = "N" , |
3795 | const std::string& n14 = "O" , |
3796 | const std::string& n15 = "P" , |
3797 | const std::string& n16 = "Q" , |
3798 | const std::string& n17 = "R" , |
3799 | const std::string& n18 = "S" , |
3800 | const std::string& n19 = "T" , |
3801 | const std::string& n20 = "U" , |
3802 | const std::string& n21 = "V" , |
3803 | const std::string& n22 = "W" , |
3804 | const std::string& n23 = "X" , |
3805 | const std::string& n24 = "Y" , |
3806 | const std::string& n25 = "Z" , |
3807 | const std::string& n26 = "A1" , |
3808 | const std::string& n27 = "B1" , |
3809 | const std::string& n28 = "C1" , |
3810 | const std::string& n29 = "D1" , |
3811 | const std::string& n30 = "E1" , |
3812 | const std::string& n31 = "F1" ) |
3813 | { |
3814 | if (!_pNames) |
3815 | { |
3816 | _pNames = new NameVec; |
3817 | _pNames->push_back(n0); |
3818 | _pNames->push_back(n1); |
3819 | _pNames->push_back(n2); |
3820 | _pNames->push_back(n3); |
3821 | _pNames->push_back(n4); |
3822 | _pNames->push_back(n5); |
3823 | _pNames->push_back(n6); |
3824 | _pNames->push_back(n7); |
3825 | _pNames->push_back(n8); |
3826 | _pNames->push_back(n9); |
3827 | _pNames->push_back(n10); |
3828 | _pNames->push_back(n11); |
3829 | _pNames->push_back(n12); |
3830 | _pNames->push_back(n13); |
3831 | _pNames->push_back(n14); |
3832 | _pNames->push_back(n15); |
3833 | _pNames->push_back(n16); |
3834 | _pNames->push_back(n17); |
3835 | _pNames->push_back(n18); |
3836 | _pNames->push_back(n19); |
3837 | _pNames->push_back(n20); |
3838 | _pNames->push_back(n21); |
3839 | _pNames->push_back(n22); |
3840 | _pNames->push_back(n23); |
3841 | _pNames->push_back(n24); |
3842 | _pNames->push_back(n25); |
3843 | _pNames->push_back(n26); |
3844 | _pNames->push_back(n27); |
3845 | _pNames->push_back(n28); |
3846 | _pNames->push_back(n29); |
3847 | _pNames->push_back(n30); |
3848 | _pNames->push_back(n31); |
3849 | } |
3850 | } |
3851 | |
3852 | NameVecPtr _pNames; |
3853 | }; |
3854 | |
3855 | |
3856 | template<class T0, |
3857 | class T1, |
3858 | class T2, |
3859 | class T3, |
3860 | class T4, |
3861 | class T5, |
3862 | class T6, |
3863 | class T7, |
3864 | class T8, |
3865 | class T9, |
3866 | class T10, |
3867 | class T11, |
3868 | class T12, |
3869 | class T13, |
3870 | class T14, |
3871 | class T15, |
3872 | class T16, |
3873 | class T17, |
3874 | class T18, |
3875 | class T19, |
3876 | class T20, |
3877 | class T21, |
3878 | class T22, |
3879 | class T23, |
3880 | class T24, |
3881 | class T25, |
3882 | class T26, |
3883 | class T27, |
3884 | class T28, |
3885 | class T29, |
3886 | class T30> |
3887 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,NullTypeList>: |
3888 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30> |
3889 | { |
3890 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30> TupleType; |
3891 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30>::Type Type; |
3892 | typedef std::vector<std::string> NameVec; |
3893 | typedef SharedPtr<NameVec> NameVecPtr; |
3894 | |
3895 | NamedTuple(): _pNames(0) |
3896 | { |
3897 | init(); |
3898 | } |
3899 | |
3900 | NamedTuple(const NameVecPtr& rNames) |
3901 | { |
3902 | if (rNames->size() != TupleType::length) |
3903 | throw InvalidArgumentException("Wrong names vector length." ); |
3904 | |
3905 | _pNames = rNames; |
3906 | } |
3907 | |
3908 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
3909 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
3910 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
3911 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
3912 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
3913 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
3914 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
3915 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
3916 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
3917 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
3918 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
3919 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
3920 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
3921 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
3922 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
3923 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
3924 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
3925 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
3926 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
3927 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
3928 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
3929 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
3930 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
3931 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
3932 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
3933 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
3934 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
3935 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
3936 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
3937 | typename TypeWrapper<T29>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
3938 | typename TypeWrapper<T30>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30)): |
3939 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30), |
3940 | _pNames(0) |
3941 | { |
3942 | init(); |
3943 | } |
3944 | |
3945 | NamedTuple(const NameVecPtr& rNames, |
3946 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
3947 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
3948 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
3949 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
3950 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
3951 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
3952 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
3953 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
3954 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
3955 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
3956 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
3957 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
3958 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
3959 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
3960 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
3961 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
3962 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
3963 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
3964 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
3965 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
3966 | typename TypeWrapper<T0>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
3967 | typename TypeWrapper<T1>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
3968 | typename TypeWrapper<T2>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
3969 | typename TypeWrapper<T3>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
3970 | typename TypeWrapper<T4>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
3971 | typename TypeWrapper<T5>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
3972 | typename TypeWrapper<T6>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
3973 | typename TypeWrapper<T7>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
3974 | typename TypeWrapper<T8>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
3975 | typename TypeWrapper<T9>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
3976 | typename TypeWrapper<T10>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30)): |
3977 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30) |
3978 | { |
3979 | if (rNames->size() != TupleType::length) |
3980 | throw InvalidArgumentException("Wrong names vector length." ); |
3981 | |
3982 | _pNames = rNames; |
3983 | } |
3984 | |
3985 | NamedTuple(const std::string& n0, |
3986 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
3987 | const std::string& n1 = "B" , |
3988 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
3989 | const std::string& n2 = "C" , |
3990 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
3991 | const std::string& n3 = "D" , |
3992 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
3993 | const std::string& n4 = "E" , |
3994 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
3995 | const std::string& n5 = "F" , |
3996 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
3997 | const std::string& n6 = "G" , |
3998 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
3999 | const std::string& n7 = "H" , |
4000 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
4001 | const std::string& n8 = "I" , |
4002 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
4003 | const std::string& n9 = "J" , |
4004 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
4005 | const std::string& n10 = "K" , |
4006 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
4007 | const std::string& n11 = "L" , |
4008 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
4009 | const std::string& n12 = "M" , |
4010 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
4011 | const std::string& n13 = "N" , |
4012 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
4013 | const std::string& n14 = "O" , |
4014 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
4015 | const std::string& n15 = "P" , |
4016 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
4017 | const std::string& n16 = "Q" , |
4018 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
4019 | const std::string& n17 = "R" , |
4020 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
4021 | const std::string& n18 = "S" , |
4022 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
4023 | const std::string& n19 = "T" , |
4024 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
4025 | const std::string& n20 = "U" , |
4026 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
4027 | const std::string& n21 = "V" , |
4028 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
4029 | const std::string& n22 = "W" , |
4030 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
4031 | const std::string& n23 = "X" , |
4032 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
4033 | const std::string& n24 = "Y" , |
4034 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
4035 | const std::string& n25 = "Z" , |
4036 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
4037 | const std::string& n26 = "A1" , |
4038 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
4039 | const std::string& n27 = "B1" , |
4040 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
4041 | const std::string& n28 = "C1" , |
4042 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
4043 | const std::string& n29 = "D1" , |
4044 | typename TypeWrapper<T29>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29), |
4045 | const std::string& n30 = "E1" , |
4046 | typename TypeWrapper<T30>::CONSTTYPE& t30 = POCO_TYPEWRAPPER_DEFAULTVALUE(T30)): |
4047 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30), |
4048 | _pNames(0) |
4049 | { |
4050 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30); |
4051 | } |
4052 | |
4053 | const DynamicAny get(const std::string& name) const |
4054 | { |
4055 | NameVec::const_iterator it = _pNames->begin(); |
4056 | NameVec::const_iterator itEnd = _pNames->end(); |
4057 | |
4058 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
4059 | { |
4060 | if (name == *it) |
4061 | { |
4062 | switch (counter) |
4063 | { |
4064 | case 0: return TupleType::template get<0>(); |
4065 | case 1: return TupleType::template get<1>(); |
4066 | case 2: return TupleType::template get<2>(); |
4067 | case 3: return TupleType::template get<3>(); |
4068 | case 4: return TupleType::template get<4>(); |
4069 | case 5: return TupleType::template get<5>(); |
4070 | case 6: return TupleType::template get<6>(); |
4071 | case 7: return TupleType::template get<7>(); |
4072 | case 8: return TupleType::template get<8>(); |
4073 | case 9: return TupleType::template get<9>(); |
4074 | case 10: return TupleType::template get<10>(); |
4075 | case 11: return TupleType::template get<11>(); |
4076 | case 12: return TupleType::template get<12>(); |
4077 | case 13: return TupleType::template get<13>(); |
4078 | case 14: return TupleType::template get<14>(); |
4079 | case 15: return TupleType::template get<15>(); |
4080 | case 16: return TupleType::template get<16>(); |
4081 | case 17: return TupleType::template get<17>(); |
4082 | case 18: return TupleType::template get<18>(); |
4083 | case 19: return TupleType::template get<19>(); |
4084 | case 20: return TupleType::template get<20>(); |
4085 | case 21: return TupleType::template get<21>(); |
4086 | case 22: return TupleType::template get<22>(); |
4087 | case 23: return TupleType::template get<23>(); |
4088 | case 24: return TupleType::template get<24>(); |
4089 | case 25: return TupleType::template get<25>(); |
4090 | case 26: return TupleType::template get<26>(); |
4091 | case 27: return TupleType::template get<27>(); |
4092 | case 28: return TupleType::template get<28>(); |
4093 | case 29: return TupleType::template get<29>(); |
4094 | case 30: return TupleType::template get<30>(); |
4095 | default: throw RangeException(); |
4096 | } |
4097 | } |
4098 | } |
4099 | |
4100 | throw NotFoundException("Name not found: " + name); |
4101 | } |
4102 | |
4103 | const DynamicAny operator [] (const std::string& name) const |
4104 | { |
4105 | return get(name); |
4106 | } |
4107 | |
4108 | template<int N> |
4109 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
4110 | { |
4111 | return TupleType::template get<N>(); |
4112 | } |
4113 | |
4114 | template<int N> |
4115 | typename TypeGetter<N, Type>::HeadType& get() |
4116 | { |
4117 | return TupleType::template get<N>(); |
4118 | } |
4119 | |
4120 | template<int N> |
4121 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
4122 | { |
4123 | return TupleType::template set<N>(val); |
4124 | } |
4125 | |
4126 | const NameVecPtr& names() |
4127 | { |
4128 | return _pNames; |
4129 | } |
4130 | |
4131 | void setName(std::size_t index, const std::string& name) |
4132 | { |
4133 | if (index >= _pNames->size()) |
4134 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
4135 | |
4136 | (*_pNames)[index] = name; |
4137 | } |
4138 | |
4139 | const std::string& getName(std::size_t index) |
4140 | { |
4141 | if (index >= _pNames->size()) |
4142 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
4143 | |
4144 | return (*_pNames)[index]; |
4145 | } |
4146 | |
4147 | bool operator == (const NamedTuple& other) const |
4148 | { |
4149 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
4150 | } |
4151 | |
4152 | bool operator != (const NamedTuple& other) const |
4153 | { |
4154 | return !(*this == other); |
4155 | } |
4156 | |
4157 | bool operator < (const NamedTuple& other) const |
4158 | { |
4159 | TupleType th(*this); |
4160 | TupleType oth(other); |
4161 | |
4162 | return (th < oth && _pNames == other._pNames) || |
4163 | (th == oth && _pNames < other._pNames) || |
4164 | (th < oth && _pNames < other._pNames); |
4165 | } |
4166 | |
4167 | private: |
4168 | void init(const std::string& n0 = "A" , |
4169 | const std::string& n1 = "B" , |
4170 | const std::string& n2 = "C" , |
4171 | const std::string& n3 = "D" , |
4172 | const std::string& n4 = "E" , |
4173 | const std::string& n5 = "F" , |
4174 | const std::string& n6 = "G" , |
4175 | const std::string& n7 = "H" , |
4176 | const std::string& n8 = "I" , |
4177 | const std::string& n9 = "J" , |
4178 | const std::string& n10 = "K" , |
4179 | const std::string& n11 = "L" , |
4180 | const std::string& n12 = "M" , |
4181 | const std::string& n13 = "N" , |
4182 | const std::string& n14 = "O" , |
4183 | const std::string& n15 = "P" , |
4184 | const std::string& n16 = "Q" , |
4185 | const std::string& n17 = "R" , |
4186 | const std::string& n18 = "S" , |
4187 | const std::string& n19 = "T" , |
4188 | const std::string& n20 = "U" , |
4189 | const std::string& n21 = "V" , |
4190 | const std::string& n22 = "W" , |
4191 | const std::string& n23 = "X" , |
4192 | const std::string& n24 = "Y" , |
4193 | const std::string& n25 = "Z" , |
4194 | const std::string& n26 = "A1" , |
4195 | const std::string& n27 = "B1" , |
4196 | const std::string& n28 = "C1" , |
4197 | const std::string& n29 = "D1" , |
4198 | const std::string& n30 = "E1" ) |
4199 | { |
4200 | if (!_pNames) |
4201 | { |
4202 | _pNames = new NameVec; |
4203 | _pNames->push_back(n0); |
4204 | _pNames->push_back(n1); |
4205 | _pNames->push_back(n2); |
4206 | _pNames->push_back(n3); |
4207 | _pNames->push_back(n4); |
4208 | _pNames->push_back(n5); |
4209 | _pNames->push_back(n6); |
4210 | _pNames->push_back(n7); |
4211 | _pNames->push_back(n8); |
4212 | _pNames->push_back(n9); |
4213 | _pNames->push_back(n10); |
4214 | _pNames->push_back(n11); |
4215 | _pNames->push_back(n12); |
4216 | _pNames->push_back(n13); |
4217 | _pNames->push_back(n14); |
4218 | _pNames->push_back(n15); |
4219 | _pNames->push_back(n16); |
4220 | _pNames->push_back(n17); |
4221 | _pNames->push_back(n18); |
4222 | _pNames->push_back(n19); |
4223 | _pNames->push_back(n20); |
4224 | _pNames->push_back(n21); |
4225 | _pNames->push_back(n22); |
4226 | _pNames->push_back(n23); |
4227 | _pNames->push_back(n24); |
4228 | _pNames->push_back(n25); |
4229 | _pNames->push_back(n26); |
4230 | _pNames->push_back(n27); |
4231 | _pNames->push_back(n28); |
4232 | _pNames->push_back(n29); |
4233 | _pNames->push_back(n30); |
4234 | } |
4235 | } |
4236 | |
4237 | NameVecPtr _pNames; |
4238 | }; |
4239 | |
4240 | |
4241 | template<class T0, |
4242 | class T1, |
4243 | class T2, |
4244 | class T3, |
4245 | class T4, |
4246 | class T5, |
4247 | class T6, |
4248 | class T7, |
4249 | class T8, |
4250 | class T9, |
4251 | class T10, |
4252 | class T11, |
4253 | class T12, |
4254 | class T13, |
4255 | class T14, |
4256 | class T15, |
4257 | class T16, |
4258 | class T17, |
4259 | class T18, |
4260 | class T19, |
4261 | class T20, |
4262 | class T21, |
4263 | class T22, |
4264 | class T23, |
4265 | class T24, |
4266 | class T25, |
4267 | class T26, |
4268 | class T27, |
4269 | class T28, |
4270 | class T29> |
4271 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,NullTypeList>: |
4272 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29> |
4273 | { |
4274 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29> TupleType; |
4275 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29>::Type Type; |
4276 | typedef std::vector<std::string> NameVec; |
4277 | typedef SharedPtr<NameVec> NameVecPtr; |
4278 | |
4279 | NamedTuple(): _pNames(0) |
4280 | { |
4281 | init(); |
4282 | } |
4283 | |
4284 | NamedTuple(const NameVecPtr& rNames) |
4285 | { |
4286 | if (rNames->size() != TupleType::length) |
4287 | throw InvalidArgumentException("Wrong names vector length." ); |
4288 | |
4289 | _pNames = rNames; |
4290 | } |
4291 | |
4292 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
4293 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
4294 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
4295 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
4296 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
4297 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
4298 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
4299 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
4300 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
4301 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
4302 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
4303 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
4304 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
4305 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
4306 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
4307 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
4308 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
4309 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
4310 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
4311 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
4312 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
4313 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
4314 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
4315 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
4316 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
4317 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
4318 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
4319 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
4320 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
4321 | typename TypeWrapper<T29>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29)): |
4322 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29), |
4323 | _pNames(0) |
4324 | { |
4325 | init(); |
4326 | } |
4327 | |
4328 | NamedTuple(const NameVecPtr& rNames, |
4329 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
4330 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
4331 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
4332 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
4333 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
4334 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
4335 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
4336 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
4337 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
4338 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
4339 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
4340 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
4341 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
4342 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
4343 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
4344 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
4345 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
4346 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
4347 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
4348 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
4349 | typename TypeWrapper<T0>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
4350 | typename TypeWrapper<T1>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
4351 | typename TypeWrapper<T2>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
4352 | typename TypeWrapper<T3>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
4353 | typename TypeWrapper<T4>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
4354 | typename TypeWrapper<T5>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
4355 | typename TypeWrapper<T6>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
4356 | typename TypeWrapper<T7>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
4357 | typename TypeWrapper<T8>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
4358 | typename TypeWrapper<T9>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29)): |
4359 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29) |
4360 | { |
4361 | if (rNames->size() != TupleType::length) |
4362 | throw InvalidArgumentException("Wrong names vector length." ); |
4363 | |
4364 | _pNames = rNames; |
4365 | } |
4366 | |
4367 | NamedTuple(const std::string& n0, |
4368 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
4369 | const std::string& n1 = "B" , |
4370 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
4371 | const std::string& n2 = "C" , |
4372 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
4373 | const std::string& n3 = "D" , |
4374 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
4375 | const std::string& n4 = "E" , |
4376 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
4377 | const std::string& n5 = "F" , |
4378 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
4379 | const std::string& n6 = "G" , |
4380 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
4381 | const std::string& n7 = "H" , |
4382 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
4383 | const std::string& n8 = "I" , |
4384 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
4385 | const std::string& n9 = "J" , |
4386 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
4387 | const std::string& n10 = "K" , |
4388 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
4389 | const std::string& n11 = "L" , |
4390 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
4391 | const std::string& n12 = "M" , |
4392 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
4393 | const std::string& n13 = "N" , |
4394 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
4395 | const std::string& n14 = "O" , |
4396 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
4397 | const std::string& n15 = "P" , |
4398 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
4399 | const std::string& n16 = "Q" , |
4400 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
4401 | const std::string& n17 = "R" , |
4402 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
4403 | const std::string& n18 = "S" , |
4404 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
4405 | const std::string& n19 = "T" , |
4406 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
4407 | const std::string& n20 = "U" , |
4408 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
4409 | const std::string& n21 = "V" , |
4410 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
4411 | const std::string& n22 = "W" , |
4412 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
4413 | const std::string& n23 = "X" , |
4414 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
4415 | const std::string& n24 = "Y" , |
4416 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
4417 | const std::string& n25 = "Z" , |
4418 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
4419 | const std::string& n26 = "A1" , |
4420 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
4421 | const std::string& n27 = "B1" , |
4422 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
4423 | const std::string& n28 = "C1" , |
4424 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28), |
4425 | const std::string& n29 = "D1" , |
4426 | typename TypeWrapper<T29>::CONSTTYPE& t29 = POCO_TYPEWRAPPER_DEFAULTVALUE(T29)): |
4427 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29), |
4428 | _pNames(0) |
4429 | { |
4430 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29); |
4431 | } |
4432 | |
4433 | const DynamicAny get(const std::string& name) const |
4434 | { |
4435 | NameVec::const_iterator it = _pNames->begin(); |
4436 | NameVec::const_iterator itEnd = _pNames->end(); |
4437 | |
4438 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
4439 | { |
4440 | if (name == *it) |
4441 | { |
4442 | switch (counter) |
4443 | { |
4444 | case 0: return TupleType::template get<0>(); |
4445 | case 1: return TupleType::template get<1>(); |
4446 | case 2: return TupleType::template get<2>(); |
4447 | case 3: return TupleType::template get<3>(); |
4448 | case 4: return TupleType::template get<4>(); |
4449 | case 5: return TupleType::template get<5>(); |
4450 | case 6: return TupleType::template get<6>(); |
4451 | case 7: return TupleType::template get<7>(); |
4452 | case 8: return TupleType::template get<8>(); |
4453 | case 9: return TupleType::template get<9>(); |
4454 | case 10: return TupleType::template get<10>(); |
4455 | case 11: return TupleType::template get<11>(); |
4456 | case 12: return TupleType::template get<12>(); |
4457 | case 13: return TupleType::template get<13>(); |
4458 | case 14: return TupleType::template get<14>(); |
4459 | case 15: return TupleType::template get<15>(); |
4460 | case 16: return TupleType::template get<16>(); |
4461 | case 17: return TupleType::template get<17>(); |
4462 | case 18: return TupleType::template get<18>(); |
4463 | case 19: return TupleType::template get<19>(); |
4464 | case 20: return TupleType::template get<20>(); |
4465 | case 21: return TupleType::template get<21>(); |
4466 | case 22: return TupleType::template get<22>(); |
4467 | case 23: return TupleType::template get<23>(); |
4468 | case 24: return TupleType::template get<24>(); |
4469 | case 25: return TupleType::template get<25>(); |
4470 | case 26: return TupleType::template get<26>(); |
4471 | case 27: return TupleType::template get<27>(); |
4472 | case 28: return TupleType::template get<28>(); |
4473 | case 29: return TupleType::template get<29>(); |
4474 | default: throw RangeException(); |
4475 | } |
4476 | } |
4477 | } |
4478 | |
4479 | throw NotFoundException("Name not found: " + name); |
4480 | } |
4481 | |
4482 | const DynamicAny operator [] (const std::string& name) const |
4483 | { |
4484 | return get(name); |
4485 | } |
4486 | |
4487 | template<int N> |
4488 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
4489 | { |
4490 | return TupleType::template get<N>(); |
4491 | } |
4492 | |
4493 | template<int N> |
4494 | typename TypeGetter<N, Type>::HeadType& get() |
4495 | { |
4496 | return TupleType::template get<N>(); |
4497 | } |
4498 | |
4499 | template<int N> |
4500 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
4501 | { |
4502 | return TupleType::template set<N>(val); |
4503 | } |
4504 | |
4505 | const NameVecPtr& names() |
4506 | { |
4507 | return _pNames; |
4508 | } |
4509 | |
4510 | void setName(std::size_t index, const std::string& name) |
4511 | { |
4512 | if (index >= _pNames->size()) |
4513 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
4514 | |
4515 | (*_pNames)[index] = name; |
4516 | } |
4517 | |
4518 | const std::string& getName(std::size_t index) |
4519 | { |
4520 | if (index >= _pNames->size()) |
4521 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
4522 | |
4523 | return (*_pNames)[index]; |
4524 | } |
4525 | |
4526 | bool operator == (const NamedTuple& other) const |
4527 | { |
4528 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
4529 | } |
4530 | |
4531 | bool operator != (const NamedTuple& other) const |
4532 | { |
4533 | return !(*this == other); |
4534 | } |
4535 | |
4536 | bool operator < (const NamedTuple& other) const |
4537 | { |
4538 | TupleType th(*this); |
4539 | TupleType oth(other); |
4540 | |
4541 | return (th < oth && _pNames == other._pNames) || |
4542 | (th == oth && _pNames < other._pNames) || |
4543 | (th < oth && _pNames < other._pNames); |
4544 | } |
4545 | |
4546 | private: |
4547 | void init(const std::string& n0 = "A" , |
4548 | const std::string& n1 = "B" , |
4549 | const std::string& n2 = "C" , |
4550 | const std::string& n3 = "D" , |
4551 | const std::string& n4 = "E" , |
4552 | const std::string& n5 = "F" , |
4553 | const std::string& n6 = "G" , |
4554 | const std::string& n7 = "H" , |
4555 | const std::string& n8 = "I" , |
4556 | const std::string& n9 = "J" , |
4557 | const std::string& n10 = "K" , |
4558 | const std::string& n11 = "L" , |
4559 | const std::string& n12 = "M" , |
4560 | const std::string& n13 = "N" , |
4561 | const std::string& n14 = "O" , |
4562 | const std::string& n15 = "P" , |
4563 | const std::string& n16 = "Q" , |
4564 | const std::string& n17 = "R" , |
4565 | const std::string& n18 = "S" , |
4566 | const std::string& n19 = "T" , |
4567 | const std::string& n20 = "U" , |
4568 | const std::string& n21 = "V" , |
4569 | const std::string& n22 = "W" , |
4570 | const std::string& n23 = "X" , |
4571 | const std::string& n24 = "Y" , |
4572 | const std::string& n25 = "Z" , |
4573 | const std::string& n26 = "A1" , |
4574 | const std::string& n27 = "B1" , |
4575 | const std::string& n28 = "C1" , |
4576 | const std::string& n29 = "D1" ) |
4577 | { |
4578 | if (!_pNames) |
4579 | { |
4580 | _pNames = new NameVec; |
4581 | _pNames->push_back(n0); |
4582 | _pNames->push_back(n1); |
4583 | _pNames->push_back(n2); |
4584 | _pNames->push_back(n3); |
4585 | _pNames->push_back(n4); |
4586 | _pNames->push_back(n5); |
4587 | _pNames->push_back(n6); |
4588 | _pNames->push_back(n7); |
4589 | _pNames->push_back(n8); |
4590 | _pNames->push_back(n9); |
4591 | _pNames->push_back(n10); |
4592 | _pNames->push_back(n11); |
4593 | _pNames->push_back(n12); |
4594 | _pNames->push_back(n13); |
4595 | _pNames->push_back(n14); |
4596 | _pNames->push_back(n15); |
4597 | _pNames->push_back(n16); |
4598 | _pNames->push_back(n17); |
4599 | _pNames->push_back(n18); |
4600 | _pNames->push_back(n19); |
4601 | _pNames->push_back(n20); |
4602 | _pNames->push_back(n21); |
4603 | _pNames->push_back(n22); |
4604 | _pNames->push_back(n23); |
4605 | _pNames->push_back(n24); |
4606 | _pNames->push_back(n25); |
4607 | _pNames->push_back(n26); |
4608 | _pNames->push_back(n27); |
4609 | _pNames->push_back(n28); |
4610 | _pNames->push_back(n29); |
4611 | } |
4612 | } |
4613 | |
4614 | NameVecPtr _pNames; |
4615 | }; |
4616 | |
4617 | |
4618 | template<class T0, |
4619 | class T1, |
4620 | class T2, |
4621 | class T3, |
4622 | class T4, |
4623 | class T5, |
4624 | class T6, |
4625 | class T7, |
4626 | class T8, |
4627 | class T9, |
4628 | class T10, |
4629 | class T11, |
4630 | class T12, |
4631 | class T13, |
4632 | class T14, |
4633 | class T15, |
4634 | class T16, |
4635 | class T17, |
4636 | class T18, |
4637 | class T19, |
4638 | class T20, |
4639 | class T21, |
4640 | class T22, |
4641 | class T23, |
4642 | class T24, |
4643 | class T25, |
4644 | class T26, |
4645 | class T27, |
4646 | class T28> |
4647 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,NullTypeList>: |
4648 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28> |
4649 | { |
4650 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28> TupleType; |
4651 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28>::Type Type; |
4652 | typedef std::vector<std::string> NameVec; |
4653 | typedef SharedPtr<NameVec> NameVecPtr; |
4654 | |
4655 | NamedTuple(): _pNames(0) |
4656 | { |
4657 | init(); |
4658 | } |
4659 | |
4660 | NamedTuple(const NameVecPtr& rNames) |
4661 | { |
4662 | if (rNames->size() != TupleType::length) |
4663 | throw InvalidArgumentException("Wrong names vector length." ); |
4664 | |
4665 | _pNames = rNames; |
4666 | } |
4667 | |
4668 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
4669 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
4670 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
4671 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
4672 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
4673 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
4674 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
4675 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
4676 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
4677 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
4678 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
4679 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
4680 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
4681 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
4682 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
4683 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
4684 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
4685 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
4686 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
4687 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
4688 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
4689 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
4690 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
4691 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
4692 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
4693 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
4694 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
4695 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
4696 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28)): |
4697 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28), |
4698 | _pNames(0) |
4699 | { |
4700 | init(); |
4701 | } |
4702 | |
4703 | NamedTuple(const NameVecPtr& rNames, |
4704 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
4705 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
4706 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
4707 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
4708 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
4709 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
4710 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
4711 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
4712 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
4713 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
4714 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
4715 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
4716 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
4717 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
4718 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
4719 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
4720 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
4721 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
4722 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
4723 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
4724 | typename TypeWrapper<T0>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
4725 | typename TypeWrapper<T1>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
4726 | typename TypeWrapper<T2>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
4727 | typename TypeWrapper<T3>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
4728 | typename TypeWrapper<T4>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
4729 | typename TypeWrapper<T5>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
4730 | typename TypeWrapper<T6>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
4731 | typename TypeWrapper<T7>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
4732 | typename TypeWrapper<T8>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28)): |
4733 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28) |
4734 | { |
4735 | if (rNames->size() != TupleType::length) |
4736 | throw InvalidArgumentException("Wrong names vector length." ); |
4737 | |
4738 | _pNames = rNames; |
4739 | } |
4740 | |
4741 | NamedTuple(const std::string& n0, |
4742 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
4743 | const std::string& n1 = "B" , |
4744 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
4745 | const std::string& n2 = "C" , |
4746 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
4747 | const std::string& n3 = "D" , |
4748 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
4749 | const std::string& n4 = "E" , |
4750 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
4751 | const std::string& n5 = "F" , |
4752 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
4753 | const std::string& n6 = "G" , |
4754 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
4755 | const std::string& n7 = "H" , |
4756 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
4757 | const std::string& n8 = "I" , |
4758 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
4759 | const std::string& n9 = "J" , |
4760 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
4761 | const std::string& n10 = "K" , |
4762 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
4763 | const std::string& n11 = "L" , |
4764 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
4765 | const std::string& n12 = "M" , |
4766 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
4767 | const std::string& n13 = "N" , |
4768 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
4769 | const std::string& n14 = "O" , |
4770 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
4771 | const std::string& n15 = "P" , |
4772 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
4773 | const std::string& n16 = "Q" , |
4774 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
4775 | const std::string& n17 = "R" , |
4776 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
4777 | const std::string& n18 = "S" , |
4778 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
4779 | const std::string& n19 = "T" , |
4780 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
4781 | const std::string& n20 = "U" , |
4782 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
4783 | const std::string& n21 = "V" , |
4784 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
4785 | const std::string& n22 = "W" , |
4786 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
4787 | const std::string& n23 = "X" , |
4788 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
4789 | const std::string& n24 = "Y" , |
4790 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
4791 | const std::string& n25 = "Z" , |
4792 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
4793 | const std::string& n26 = "A1" , |
4794 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
4795 | const std::string& n27 = "B1" , |
4796 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27), |
4797 | const std::string& n28 = "C1" , |
4798 | typename TypeWrapper<T28>::CONSTTYPE& t28 = POCO_TYPEWRAPPER_DEFAULTVALUE(T28)): |
4799 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28), |
4800 | _pNames(0) |
4801 | { |
4802 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28); |
4803 | } |
4804 | |
4805 | const DynamicAny get(const std::string& name) const |
4806 | { |
4807 | NameVec::const_iterator it = _pNames->begin(); |
4808 | NameVec::const_iterator itEnd = _pNames->end(); |
4809 | |
4810 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
4811 | { |
4812 | if (name == *it) |
4813 | { |
4814 | switch (counter) |
4815 | { |
4816 | case 0: return TupleType::template get<0>(); |
4817 | case 1: return TupleType::template get<1>(); |
4818 | case 2: return TupleType::template get<2>(); |
4819 | case 3: return TupleType::template get<3>(); |
4820 | case 4: return TupleType::template get<4>(); |
4821 | case 5: return TupleType::template get<5>(); |
4822 | case 6: return TupleType::template get<6>(); |
4823 | case 7: return TupleType::template get<7>(); |
4824 | case 8: return TupleType::template get<8>(); |
4825 | case 9: return TupleType::template get<9>(); |
4826 | case 10: return TupleType::template get<10>(); |
4827 | case 11: return TupleType::template get<11>(); |
4828 | case 12: return TupleType::template get<12>(); |
4829 | case 13: return TupleType::template get<13>(); |
4830 | case 14: return TupleType::template get<14>(); |
4831 | case 15: return TupleType::template get<15>(); |
4832 | case 16: return TupleType::template get<16>(); |
4833 | case 17: return TupleType::template get<17>(); |
4834 | case 18: return TupleType::template get<18>(); |
4835 | case 19: return TupleType::template get<19>(); |
4836 | case 20: return TupleType::template get<20>(); |
4837 | case 21: return TupleType::template get<21>(); |
4838 | case 22: return TupleType::template get<22>(); |
4839 | case 23: return TupleType::template get<23>(); |
4840 | case 24: return TupleType::template get<24>(); |
4841 | case 25: return TupleType::template get<25>(); |
4842 | case 26: return TupleType::template get<26>(); |
4843 | case 27: return TupleType::template get<27>(); |
4844 | case 28: return TupleType::template get<28>(); |
4845 | default: throw RangeException(); |
4846 | } |
4847 | } |
4848 | } |
4849 | |
4850 | throw NotFoundException("Name not found: " + name); |
4851 | } |
4852 | |
4853 | const DynamicAny operator [] (const std::string& name) const |
4854 | { |
4855 | return get(name); |
4856 | } |
4857 | |
4858 | template<int N> |
4859 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
4860 | { |
4861 | return TupleType::template get<N>(); |
4862 | } |
4863 | |
4864 | template<int N> |
4865 | typename TypeGetter<N, Type>::HeadType& get() |
4866 | { |
4867 | return TupleType::template get<N>(); |
4868 | } |
4869 | |
4870 | template<int N> |
4871 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
4872 | { |
4873 | return TupleType::template set<N>(val); |
4874 | } |
4875 | |
4876 | const NameVecPtr& names() |
4877 | { |
4878 | return _pNames; |
4879 | } |
4880 | |
4881 | void setName(std::size_t index, const std::string& name) |
4882 | { |
4883 | if (index >= _pNames->size()) |
4884 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
4885 | |
4886 | (*_pNames)[index] = name; |
4887 | } |
4888 | |
4889 | const std::string& getName(std::size_t index) |
4890 | { |
4891 | if (index >= _pNames->size()) |
4892 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
4893 | |
4894 | return (*_pNames)[index]; |
4895 | } |
4896 | |
4897 | bool operator == (const NamedTuple& other) const |
4898 | { |
4899 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
4900 | } |
4901 | |
4902 | bool operator != (const NamedTuple& other) const |
4903 | { |
4904 | return !(*this == other); |
4905 | } |
4906 | |
4907 | bool operator < (const NamedTuple& other) const |
4908 | { |
4909 | TupleType th(*this); |
4910 | TupleType oth(other); |
4911 | |
4912 | return (th < oth && _pNames == other._pNames) || |
4913 | (th == oth && _pNames < other._pNames) || |
4914 | (th < oth && _pNames < other._pNames); |
4915 | } |
4916 | |
4917 | private: |
4918 | void init(const std::string& n0 = "A" , |
4919 | const std::string& n1 = "B" , |
4920 | const std::string& n2 = "C" , |
4921 | const std::string& n3 = "D" , |
4922 | const std::string& n4 = "E" , |
4923 | const std::string& n5 = "F" , |
4924 | const std::string& n6 = "G" , |
4925 | const std::string& n7 = "H" , |
4926 | const std::string& n8 = "I" , |
4927 | const std::string& n9 = "J" , |
4928 | const std::string& n10 = "K" , |
4929 | const std::string& n11 = "L" , |
4930 | const std::string& n12 = "M" , |
4931 | const std::string& n13 = "N" , |
4932 | const std::string& n14 = "O" , |
4933 | const std::string& n15 = "P" , |
4934 | const std::string& n16 = "Q" , |
4935 | const std::string& n17 = "R" , |
4936 | const std::string& n18 = "S" , |
4937 | const std::string& n19 = "T" , |
4938 | const std::string& n20 = "U" , |
4939 | const std::string& n21 = "V" , |
4940 | const std::string& n22 = "W" , |
4941 | const std::string& n23 = "X" , |
4942 | const std::string& n24 = "Y" , |
4943 | const std::string& n25 = "Z" , |
4944 | const std::string& n26 = "A1" , |
4945 | const std::string& n27 = "B1" , |
4946 | const std::string& n28 = "C1" ) |
4947 | { |
4948 | if (!_pNames) |
4949 | { |
4950 | _pNames = new NameVec; |
4951 | _pNames->push_back(n0); |
4952 | _pNames->push_back(n1); |
4953 | _pNames->push_back(n2); |
4954 | _pNames->push_back(n3); |
4955 | _pNames->push_back(n4); |
4956 | _pNames->push_back(n5); |
4957 | _pNames->push_back(n6); |
4958 | _pNames->push_back(n7); |
4959 | _pNames->push_back(n8); |
4960 | _pNames->push_back(n9); |
4961 | _pNames->push_back(n10); |
4962 | _pNames->push_back(n11); |
4963 | _pNames->push_back(n12); |
4964 | _pNames->push_back(n13); |
4965 | _pNames->push_back(n14); |
4966 | _pNames->push_back(n15); |
4967 | _pNames->push_back(n16); |
4968 | _pNames->push_back(n17); |
4969 | _pNames->push_back(n18); |
4970 | _pNames->push_back(n19); |
4971 | _pNames->push_back(n20); |
4972 | _pNames->push_back(n21); |
4973 | _pNames->push_back(n22); |
4974 | _pNames->push_back(n23); |
4975 | _pNames->push_back(n24); |
4976 | _pNames->push_back(n25); |
4977 | _pNames->push_back(n26); |
4978 | _pNames->push_back(n27); |
4979 | _pNames->push_back(n28); |
4980 | } |
4981 | } |
4982 | |
4983 | NameVecPtr _pNames; |
4984 | }; |
4985 | |
4986 | |
4987 | template<class T0, |
4988 | class T1, |
4989 | class T2, |
4990 | class T3, |
4991 | class T4, |
4992 | class T5, |
4993 | class T6, |
4994 | class T7, |
4995 | class T8, |
4996 | class T9, |
4997 | class T10, |
4998 | class T11, |
4999 | class T12, |
5000 | class T13, |
5001 | class T14, |
5002 | class T15, |
5003 | class T16, |
5004 | class T17, |
5005 | class T18, |
5006 | class T19, |
5007 | class T20, |
5008 | class T21, |
5009 | class T22, |
5010 | class T23, |
5011 | class T24, |
5012 | class T25, |
5013 | class T26, |
5014 | class T27> |
5015 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,NullTypeList>: |
5016 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27> |
5017 | { |
5018 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27> TupleType; |
5019 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27>::Type Type; |
5020 | typedef std::vector<std::string> NameVec; |
5021 | typedef SharedPtr<NameVec> NameVecPtr; |
5022 | |
5023 | NamedTuple(): _pNames(0) |
5024 | { |
5025 | init(); |
5026 | } |
5027 | |
5028 | NamedTuple(const NameVecPtr& rNames) |
5029 | { |
5030 | if (rNames->size() != TupleType::length) |
5031 | throw InvalidArgumentException("Wrong names vector length." ); |
5032 | |
5033 | _pNames = rNames; |
5034 | } |
5035 | |
5036 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
5037 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
5038 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
5039 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
5040 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
5041 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
5042 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
5043 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
5044 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
5045 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
5046 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
5047 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
5048 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
5049 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
5050 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
5051 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
5052 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
5053 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
5054 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
5055 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
5056 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
5057 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
5058 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
5059 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
5060 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
5061 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
5062 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
5063 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27)): |
5064 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27), |
5065 | _pNames(0) |
5066 | { |
5067 | init(); |
5068 | } |
5069 | |
5070 | NamedTuple(const NameVecPtr& rNames, |
5071 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
5072 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
5073 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
5074 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
5075 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
5076 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
5077 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
5078 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
5079 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
5080 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
5081 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
5082 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
5083 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
5084 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
5085 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
5086 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
5087 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
5088 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
5089 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
5090 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
5091 | typename TypeWrapper<T0>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
5092 | typename TypeWrapper<T1>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
5093 | typename TypeWrapper<T2>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
5094 | typename TypeWrapper<T3>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
5095 | typename TypeWrapper<T4>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
5096 | typename TypeWrapper<T5>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
5097 | typename TypeWrapper<T6>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
5098 | typename TypeWrapper<T7>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27)): |
5099 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27) |
5100 | { |
5101 | if (rNames->size() != TupleType::length) |
5102 | throw InvalidArgumentException("Wrong names vector length." ); |
5103 | |
5104 | _pNames = rNames; |
5105 | } |
5106 | |
5107 | NamedTuple(const std::string& n0, |
5108 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
5109 | const std::string& n1 = "B" , |
5110 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
5111 | const std::string& n2 = "C" , |
5112 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
5113 | const std::string& n3 = "D" , |
5114 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
5115 | const std::string& n4 = "E" , |
5116 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
5117 | const std::string& n5 = "F" , |
5118 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
5119 | const std::string& n6 = "G" , |
5120 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
5121 | const std::string& n7 = "H" , |
5122 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
5123 | const std::string& n8 = "I" , |
5124 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
5125 | const std::string& n9 = "J" , |
5126 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
5127 | const std::string& n10 = "K" , |
5128 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
5129 | const std::string& n11 = "L" , |
5130 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
5131 | const std::string& n12 = "M" , |
5132 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
5133 | const std::string& n13 = "N" , |
5134 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
5135 | const std::string& n14 = "O" , |
5136 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
5137 | const std::string& n15 = "P" , |
5138 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
5139 | const std::string& n16 = "Q" , |
5140 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
5141 | const std::string& n17 = "R" , |
5142 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
5143 | const std::string& n18 = "S" , |
5144 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
5145 | const std::string& n19 = "T" , |
5146 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
5147 | const std::string& n20 = "U" , |
5148 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
5149 | const std::string& n21 = "V" , |
5150 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
5151 | const std::string& n22 = "W" , |
5152 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
5153 | const std::string& n23 = "X" , |
5154 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
5155 | const std::string& n24 = "Y" , |
5156 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
5157 | const std::string& n25 = "Z" , |
5158 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
5159 | const std::string& n26 = "A1" , |
5160 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26), |
5161 | const std::string& n27 = "B1" , |
5162 | typename TypeWrapper<T27>::CONSTTYPE& t27 = POCO_TYPEWRAPPER_DEFAULTVALUE(T27)): |
5163 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27), |
5164 | _pNames(0) |
5165 | { |
5166 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27); |
5167 | } |
5168 | |
5169 | const DynamicAny get(const std::string& name) const |
5170 | { |
5171 | NameVec::const_iterator it = _pNames->begin(); |
5172 | NameVec::const_iterator itEnd = _pNames->end(); |
5173 | |
5174 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
5175 | { |
5176 | if (name == *it) |
5177 | { |
5178 | switch (counter) |
5179 | { |
5180 | case 0: return TupleType::template get<0>(); |
5181 | case 1: return TupleType::template get<1>(); |
5182 | case 2: return TupleType::template get<2>(); |
5183 | case 3: return TupleType::template get<3>(); |
5184 | case 4: return TupleType::template get<4>(); |
5185 | case 5: return TupleType::template get<5>(); |
5186 | case 6: return TupleType::template get<6>(); |
5187 | case 7: return TupleType::template get<7>(); |
5188 | case 8: return TupleType::template get<8>(); |
5189 | case 9: return TupleType::template get<9>(); |
5190 | case 10: return TupleType::template get<10>(); |
5191 | case 11: return TupleType::template get<11>(); |
5192 | case 12: return TupleType::template get<12>(); |
5193 | case 13: return TupleType::template get<13>(); |
5194 | case 14: return TupleType::template get<14>(); |
5195 | case 15: return TupleType::template get<15>(); |
5196 | case 16: return TupleType::template get<16>(); |
5197 | case 17: return TupleType::template get<17>(); |
5198 | case 18: return TupleType::template get<18>(); |
5199 | case 19: return TupleType::template get<19>(); |
5200 | case 20: return TupleType::template get<20>(); |
5201 | case 21: return TupleType::template get<21>(); |
5202 | case 22: return TupleType::template get<22>(); |
5203 | case 23: return TupleType::template get<23>(); |
5204 | case 24: return TupleType::template get<24>(); |
5205 | case 25: return TupleType::template get<25>(); |
5206 | case 26: return TupleType::template get<26>(); |
5207 | case 27: return TupleType::template get<27>(); |
5208 | default: throw RangeException(); |
5209 | } |
5210 | } |
5211 | } |
5212 | |
5213 | throw NotFoundException("Name not found: " + name); |
5214 | } |
5215 | |
5216 | const DynamicAny operator [] (const std::string& name) const |
5217 | { |
5218 | return get(name); |
5219 | } |
5220 | |
5221 | template<int N> |
5222 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
5223 | { |
5224 | return TupleType::template get<N>(); |
5225 | } |
5226 | |
5227 | template<int N> |
5228 | typename TypeGetter<N, Type>::HeadType& get() |
5229 | { |
5230 | return TupleType::template get<N>(); |
5231 | } |
5232 | |
5233 | template<int N> |
5234 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
5235 | { |
5236 | return TupleType::template set<N>(val); |
5237 | } |
5238 | |
5239 | const NameVecPtr& names() |
5240 | { |
5241 | return _pNames; |
5242 | } |
5243 | |
5244 | void setName(std::size_t index, const std::string& name) |
5245 | { |
5246 | if (index >= _pNames->size()) |
5247 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
5248 | |
5249 | (*_pNames)[index] = name; |
5250 | } |
5251 | |
5252 | const std::string& getName(std::size_t index) |
5253 | { |
5254 | if (index >= _pNames->size()) |
5255 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
5256 | |
5257 | return (*_pNames)[index]; |
5258 | } |
5259 | |
5260 | bool operator == (const NamedTuple& other) const |
5261 | { |
5262 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
5263 | } |
5264 | |
5265 | bool operator != (const NamedTuple& other) const |
5266 | { |
5267 | return !(*this == other); |
5268 | } |
5269 | |
5270 | bool operator < (const NamedTuple& other) const |
5271 | { |
5272 | TupleType th(*this); |
5273 | TupleType oth(other); |
5274 | |
5275 | return (th < oth && _pNames == other._pNames) || |
5276 | (th == oth && _pNames < other._pNames) || |
5277 | (th < oth && _pNames < other._pNames); |
5278 | } |
5279 | |
5280 | private: |
5281 | void init(const std::string& n0 = "A" , |
5282 | const std::string& n1 = "B" , |
5283 | const std::string& n2 = "C" , |
5284 | const std::string& n3 = "D" , |
5285 | const std::string& n4 = "E" , |
5286 | const std::string& n5 = "F" , |
5287 | const std::string& n6 = "G" , |
5288 | const std::string& n7 = "H" , |
5289 | const std::string& n8 = "I" , |
5290 | const std::string& n9 = "J" , |
5291 | const std::string& n10 = "K" , |
5292 | const std::string& n11 = "L" , |
5293 | const std::string& n12 = "M" , |
5294 | const std::string& n13 = "N" , |
5295 | const std::string& n14 = "O" , |
5296 | const std::string& n15 = "P" , |
5297 | const std::string& n16 = "Q" , |
5298 | const std::string& n17 = "R" , |
5299 | const std::string& n18 = "S" , |
5300 | const std::string& n19 = "T" , |
5301 | const std::string& n20 = "U" , |
5302 | const std::string& n21 = "V" , |
5303 | const std::string& n22 = "W" , |
5304 | const std::string& n23 = "X" , |
5305 | const std::string& n24 = "Y" , |
5306 | const std::string& n25 = "Z" , |
5307 | const std::string& n26 = "A1" , |
5308 | const std::string& n27 = "B1" ) |
5309 | { |
5310 | if (!_pNames) |
5311 | { |
5312 | _pNames = new NameVec; |
5313 | _pNames->push_back(n0); |
5314 | _pNames->push_back(n1); |
5315 | _pNames->push_back(n2); |
5316 | _pNames->push_back(n3); |
5317 | _pNames->push_back(n4); |
5318 | _pNames->push_back(n5); |
5319 | _pNames->push_back(n6); |
5320 | _pNames->push_back(n7); |
5321 | _pNames->push_back(n8); |
5322 | _pNames->push_back(n9); |
5323 | _pNames->push_back(n10); |
5324 | _pNames->push_back(n11); |
5325 | _pNames->push_back(n12); |
5326 | _pNames->push_back(n13); |
5327 | _pNames->push_back(n14); |
5328 | _pNames->push_back(n15); |
5329 | _pNames->push_back(n16); |
5330 | _pNames->push_back(n17); |
5331 | _pNames->push_back(n18); |
5332 | _pNames->push_back(n19); |
5333 | _pNames->push_back(n20); |
5334 | _pNames->push_back(n21); |
5335 | _pNames->push_back(n22); |
5336 | _pNames->push_back(n23); |
5337 | _pNames->push_back(n24); |
5338 | _pNames->push_back(n25); |
5339 | _pNames->push_back(n26); |
5340 | _pNames->push_back(n27); |
5341 | } |
5342 | } |
5343 | |
5344 | NameVecPtr _pNames; |
5345 | }; |
5346 | |
5347 | |
5348 | template<class T0, |
5349 | class T1, |
5350 | class T2, |
5351 | class T3, |
5352 | class T4, |
5353 | class T5, |
5354 | class T6, |
5355 | class T7, |
5356 | class T8, |
5357 | class T9, |
5358 | class T10, |
5359 | class T11, |
5360 | class T12, |
5361 | class T13, |
5362 | class T14, |
5363 | class T15, |
5364 | class T16, |
5365 | class T17, |
5366 | class T18, |
5367 | class T19, |
5368 | class T20, |
5369 | class T21, |
5370 | class T22, |
5371 | class T23, |
5372 | class T24, |
5373 | class T25, |
5374 | class T26> |
5375 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,NullTypeList>: |
5376 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26> |
5377 | { |
5378 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26> TupleType; |
5379 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26>::Type Type; |
5380 | typedef std::vector<std::string> NameVec; |
5381 | typedef SharedPtr<NameVec> NameVecPtr; |
5382 | |
5383 | NamedTuple(): _pNames(0) |
5384 | { |
5385 | init(); |
5386 | } |
5387 | |
5388 | NamedTuple(const NameVecPtr& rNames) |
5389 | { |
5390 | if (rNames->size() != TupleType::length) |
5391 | throw InvalidArgumentException("Wrong names vector length." ); |
5392 | |
5393 | _pNames = rNames; |
5394 | } |
5395 | |
5396 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
5397 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
5398 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
5399 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
5400 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
5401 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
5402 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
5403 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
5404 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
5405 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
5406 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
5407 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
5408 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
5409 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
5410 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
5411 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
5412 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
5413 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
5414 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
5415 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
5416 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
5417 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
5418 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
5419 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
5420 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
5421 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
5422 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26)): |
5423 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26), |
5424 | _pNames(0) |
5425 | { |
5426 | init(); |
5427 | } |
5428 | |
5429 | NamedTuple(const NameVecPtr& rNames, |
5430 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
5431 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
5432 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
5433 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
5434 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
5435 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
5436 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
5437 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
5438 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
5439 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
5440 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
5441 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
5442 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
5443 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
5444 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
5445 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
5446 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
5447 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
5448 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
5449 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
5450 | typename TypeWrapper<T0>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
5451 | typename TypeWrapper<T1>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
5452 | typename TypeWrapper<T2>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
5453 | typename TypeWrapper<T3>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
5454 | typename TypeWrapper<T4>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
5455 | typename TypeWrapper<T5>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
5456 | typename TypeWrapper<T6>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26)): |
5457 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26) |
5458 | { |
5459 | if (rNames->size() != TupleType::length) |
5460 | throw InvalidArgumentException("Wrong names vector length." ); |
5461 | |
5462 | _pNames = rNames; |
5463 | } |
5464 | |
5465 | NamedTuple(const std::string& n0, |
5466 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
5467 | const std::string& n1 = "B" , |
5468 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
5469 | const std::string& n2 = "C" , |
5470 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
5471 | const std::string& n3 = "D" , |
5472 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
5473 | const std::string& n4 = "E" , |
5474 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
5475 | const std::string& n5 = "F" , |
5476 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
5477 | const std::string& n6 = "G" , |
5478 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
5479 | const std::string& n7 = "H" , |
5480 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
5481 | const std::string& n8 = "I" , |
5482 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
5483 | const std::string& n9 = "J" , |
5484 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
5485 | const std::string& n10 = "K" , |
5486 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
5487 | const std::string& n11 = "L" , |
5488 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
5489 | const std::string& n12 = "M" , |
5490 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
5491 | const std::string& n13 = "N" , |
5492 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
5493 | const std::string& n14 = "O" , |
5494 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
5495 | const std::string& n15 = "P" , |
5496 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
5497 | const std::string& n16 = "Q" , |
5498 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
5499 | const std::string& n17 = "R" , |
5500 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
5501 | const std::string& n18 = "S" , |
5502 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
5503 | const std::string& n19 = "T" , |
5504 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
5505 | const std::string& n20 = "U" , |
5506 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
5507 | const std::string& n21 = "V" , |
5508 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
5509 | const std::string& n22 = "W" , |
5510 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
5511 | const std::string& n23 = "X" , |
5512 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
5513 | const std::string& n24 = "Y" , |
5514 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
5515 | const std::string& n25 = "Z" , |
5516 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25), |
5517 | const std::string& n26 = "A1" , |
5518 | typename TypeWrapper<T26>::CONSTTYPE& t26 = POCO_TYPEWRAPPER_DEFAULTVALUE(T26)): |
5519 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26), |
5520 | _pNames(0) |
5521 | { |
5522 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26); |
5523 | } |
5524 | |
5525 | const DynamicAny get(const std::string& name) const |
5526 | { |
5527 | NameVec::const_iterator it = _pNames->begin(); |
5528 | NameVec::const_iterator itEnd = _pNames->end(); |
5529 | |
5530 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
5531 | { |
5532 | if (name == *it) |
5533 | { |
5534 | switch (counter) |
5535 | { |
5536 | case 0: return TupleType::template get<0>(); |
5537 | case 1: return TupleType::template get<1>(); |
5538 | case 2: return TupleType::template get<2>(); |
5539 | case 3: return TupleType::template get<3>(); |
5540 | case 4: return TupleType::template get<4>(); |
5541 | case 5: return TupleType::template get<5>(); |
5542 | case 6: return TupleType::template get<6>(); |
5543 | case 7: return TupleType::template get<7>(); |
5544 | case 8: return TupleType::template get<8>(); |
5545 | case 9: return TupleType::template get<9>(); |
5546 | case 10: return TupleType::template get<10>(); |
5547 | case 11: return TupleType::template get<11>(); |
5548 | case 12: return TupleType::template get<12>(); |
5549 | case 13: return TupleType::template get<13>(); |
5550 | case 14: return TupleType::template get<14>(); |
5551 | case 15: return TupleType::template get<15>(); |
5552 | case 16: return TupleType::template get<16>(); |
5553 | case 17: return TupleType::template get<17>(); |
5554 | case 18: return TupleType::template get<18>(); |
5555 | case 19: return TupleType::template get<19>(); |
5556 | case 20: return TupleType::template get<20>(); |
5557 | case 21: return TupleType::template get<21>(); |
5558 | case 22: return TupleType::template get<22>(); |
5559 | case 23: return TupleType::template get<23>(); |
5560 | case 24: return TupleType::template get<24>(); |
5561 | case 25: return TupleType::template get<25>(); |
5562 | case 26: return TupleType::template get<26>(); |
5563 | default: throw RangeException(); |
5564 | } |
5565 | } |
5566 | } |
5567 | |
5568 | throw NotFoundException("Name not found: " + name); |
5569 | } |
5570 | |
5571 | const DynamicAny operator [] (const std::string& name) const |
5572 | { |
5573 | return get(name); |
5574 | } |
5575 | |
5576 | template<int N> |
5577 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
5578 | { |
5579 | return TupleType::template get<N>(); |
5580 | } |
5581 | |
5582 | template<int N> |
5583 | typename TypeGetter<N, Type>::HeadType& get() |
5584 | { |
5585 | return TupleType::template get<N>(); |
5586 | } |
5587 | |
5588 | template<int N> |
5589 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
5590 | { |
5591 | return TupleType::template set<N>(val); |
5592 | } |
5593 | |
5594 | const NameVecPtr& names() |
5595 | { |
5596 | return _pNames; |
5597 | } |
5598 | |
5599 | void setName(std::size_t index, const std::string& name) |
5600 | { |
5601 | if (index >= _pNames->size()) |
5602 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
5603 | |
5604 | (*_pNames)[index] = name; |
5605 | } |
5606 | |
5607 | const std::string& getName(std::size_t index) |
5608 | { |
5609 | if (index >= _pNames->size()) |
5610 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
5611 | |
5612 | return (*_pNames)[index]; |
5613 | } |
5614 | |
5615 | bool operator == (const NamedTuple& other) const |
5616 | { |
5617 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
5618 | } |
5619 | |
5620 | bool operator != (const NamedTuple& other) const |
5621 | { |
5622 | return !(*this == other); |
5623 | } |
5624 | |
5625 | bool operator < (const NamedTuple& other) const |
5626 | { |
5627 | TupleType th(*this); |
5628 | TupleType oth(other); |
5629 | |
5630 | return (th < oth && _pNames == other._pNames) || |
5631 | (th == oth && _pNames < other._pNames) || |
5632 | (th < oth && _pNames < other._pNames); |
5633 | } |
5634 | |
5635 | private: |
5636 | void init(const std::string& n0 = "A" , |
5637 | const std::string& n1 = "B" , |
5638 | const std::string& n2 = "C" , |
5639 | const std::string& n3 = "D" , |
5640 | const std::string& n4 = "E" , |
5641 | const std::string& n5 = "F" , |
5642 | const std::string& n6 = "G" , |
5643 | const std::string& n7 = "H" , |
5644 | const std::string& n8 = "I" , |
5645 | const std::string& n9 = "J" , |
5646 | const std::string& n10 = "K" , |
5647 | const std::string& n11 = "L" , |
5648 | const std::string& n12 = "M" , |
5649 | const std::string& n13 = "N" , |
5650 | const std::string& n14 = "O" , |
5651 | const std::string& n15 = "P" , |
5652 | const std::string& n16 = "Q" , |
5653 | const std::string& n17 = "R" , |
5654 | const std::string& n18 = "S" , |
5655 | const std::string& n19 = "T" , |
5656 | const std::string& n20 = "U" , |
5657 | const std::string& n21 = "V" , |
5658 | const std::string& n22 = "W" , |
5659 | const std::string& n23 = "X" , |
5660 | const std::string& n24 = "Y" , |
5661 | const std::string& n25 = "Z" , |
5662 | const std::string& n26 = "A1" ) |
5663 | { |
5664 | if (!_pNames) |
5665 | { |
5666 | _pNames = new NameVec; |
5667 | _pNames->push_back(n0); |
5668 | _pNames->push_back(n1); |
5669 | _pNames->push_back(n2); |
5670 | _pNames->push_back(n3); |
5671 | _pNames->push_back(n4); |
5672 | _pNames->push_back(n5); |
5673 | _pNames->push_back(n6); |
5674 | _pNames->push_back(n7); |
5675 | _pNames->push_back(n8); |
5676 | _pNames->push_back(n9); |
5677 | _pNames->push_back(n10); |
5678 | _pNames->push_back(n11); |
5679 | _pNames->push_back(n12); |
5680 | _pNames->push_back(n13); |
5681 | _pNames->push_back(n14); |
5682 | _pNames->push_back(n15); |
5683 | _pNames->push_back(n16); |
5684 | _pNames->push_back(n17); |
5685 | _pNames->push_back(n18); |
5686 | _pNames->push_back(n19); |
5687 | _pNames->push_back(n20); |
5688 | _pNames->push_back(n21); |
5689 | _pNames->push_back(n22); |
5690 | _pNames->push_back(n23); |
5691 | _pNames->push_back(n24); |
5692 | _pNames->push_back(n25); |
5693 | _pNames->push_back(n26); |
5694 | } |
5695 | } |
5696 | |
5697 | NameVecPtr _pNames; |
5698 | }; |
5699 | |
5700 | |
5701 | template<class T0, |
5702 | class T1, |
5703 | class T2, |
5704 | class T3, |
5705 | class T4, |
5706 | class T5, |
5707 | class T6, |
5708 | class T7, |
5709 | class T8, |
5710 | class T9, |
5711 | class T10, |
5712 | class T11, |
5713 | class T12, |
5714 | class T13, |
5715 | class T14, |
5716 | class T15, |
5717 | class T16, |
5718 | class T17, |
5719 | class T18, |
5720 | class T19, |
5721 | class T20, |
5722 | class T21, |
5723 | class T22, |
5724 | class T23, |
5725 | class T24, |
5726 | class T25> |
5727 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,NullTypeList>: |
5728 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25> |
5729 | { |
5730 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25> TupleType; |
5731 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25>::Type Type; |
5732 | typedef std::vector<std::string> NameVec; |
5733 | typedef SharedPtr<NameVec> NameVecPtr; |
5734 | |
5735 | NamedTuple(): _pNames(0) |
5736 | { |
5737 | init(); |
5738 | } |
5739 | |
5740 | NamedTuple(const NameVecPtr& rNames) |
5741 | { |
5742 | if (rNames->size() != TupleType::length) |
5743 | throw InvalidArgumentException("Wrong names vector length." ); |
5744 | |
5745 | _pNames = rNames; |
5746 | } |
5747 | |
5748 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
5749 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
5750 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
5751 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
5752 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
5753 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
5754 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
5755 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
5756 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
5757 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
5758 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
5759 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
5760 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
5761 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
5762 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
5763 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
5764 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
5765 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
5766 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
5767 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
5768 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
5769 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
5770 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
5771 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
5772 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
5773 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25)): |
5774 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25), |
5775 | _pNames(0) |
5776 | { |
5777 | init(); |
5778 | } |
5779 | |
5780 | NamedTuple(const NameVecPtr& rNames, |
5781 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
5782 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
5783 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
5784 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
5785 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
5786 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
5787 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
5788 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
5789 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
5790 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
5791 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
5792 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
5793 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
5794 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
5795 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
5796 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
5797 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
5798 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
5799 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
5800 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
5801 | typename TypeWrapper<T0>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
5802 | typename TypeWrapper<T1>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
5803 | typename TypeWrapper<T2>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
5804 | typename TypeWrapper<T3>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
5805 | typename TypeWrapper<T4>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
5806 | typename TypeWrapper<T5>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25)): |
5807 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25) |
5808 | { |
5809 | if (rNames->size() != TupleType::length) |
5810 | throw InvalidArgumentException("Wrong names vector length." ); |
5811 | |
5812 | _pNames = rNames; |
5813 | } |
5814 | |
5815 | NamedTuple(const std::string& n0, |
5816 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
5817 | const std::string& n1 = "B" , |
5818 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
5819 | const std::string& n2 = "C" , |
5820 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
5821 | const std::string& n3 = "D" , |
5822 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
5823 | const std::string& n4 = "E" , |
5824 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
5825 | const std::string& n5 = "F" , |
5826 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
5827 | const std::string& n6 = "G" , |
5828 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
5829 | const std::string& n7 = "H" , |
5830 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
5831 | const std::string& n8 = "I" , |
5832 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
5833 | const std::string& n9 = "J" , |
5834 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
5835 | const std::string& n10 = "K" , |
5836 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
5837 | const std::string& n11 = "L" , |
5838 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
5839 | const std::string& n12 = "M" , |
5840 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
5841 | const std::string& n13 = "N" , |
5842 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
5843 | const std::string& n14 = "O" , |
5844 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
5845 | const std::string& n15 = "P" , |
5846 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
5847 | const std::string& n16 = "Q" , |
5848 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
5849 | const std::string& n17 = "R" , |
5850 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
5851 | const std::string& n18 = "S" , |
5852 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
5853 | const std::string& n19 = "T" , |
5854 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
5855 | const std::string& n20 = "U" , |
5856 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
5857 | const std::string& n21 = "V" , |
5858 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
5859 | const std::string& n22 = "W" , |
5860 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
5861 | const std::string& n23 = "X" , |
5862 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
5863 | const std::string& n24 = "Y" , |
5864 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24), |
5865 | const std::string& n25 = "Z" , |
5866 | typename TypeWrapper<T25>::CONSTTYPE& t25 = POCO_TYPEWRAPPER_DEFAULTVALUE(T25)): |
5867 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25), |
5868 | _pNames(0) |
5869 | { |
5870 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25); |
5871 | } |
5872 | |
5873 | const DynamicAny get(const std::string& name) const |
5874 | { |
5875 | NameVec::const_iterator it = _pNames->begin(); |
5876 | NameVec::const_iterator itEnd = _pNames->end(); |
5877 | |
5878 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
5879 | { |
5880 | if (name == *it) |
5881 | { |
5882 | switch (counter) |
5883 | { |
5884 | case 0: return TupleType::template get<0>(); |
5885 | case 1: return TupleType::template get<1>(); |
5886 | case 2: return TupleType::template get<2>(); |
5887 | case 3: return TupleType::template get<3>(); |
5888 | case 4: return TupleType::template get<4>(); |
5889 | case 5: return TupleType::template get<5>(); |
5890 | case 6: return TupleType::template get<6>(); |
5891 | case 7: return TupleType::template get<7>(); |
5892 | case 8: return TupleType::template get<8>(); |
5893 | case 9: return TupleType::template get<9>(); |
5894 | case 10: return TupleType::template get<10>(); |
5895 | case 11: return TupleType::template get<11>(); |
5896 | case 12: return TupleType::template get<12>(); |
5897 | case 13: return TupleType::template get<13>(); |
5898 | case 14: return TupleType::template get<14>(); |
5899 | case 15: return TupleType::template get<15>(); |
5900 | case 16: return TupleType::template get<16>(); |
5901 | case 17: return TupleType::template get<17>(); |
5902 | case 18: return TupleType::template get<18>(); |
5903 | case 19: return TupleType::template get<19>(); |
5904 | case 20: return TupleType::template get<20>(); |
5905 | case 21: return TupleType::template get<21>(); |
5906 | case 22: return TupleType::template get<22>(); |
5907 | case 23: return TupleType::template get<23>(); |
5908 | case 24: return TupleType::template get<24>(); |
5909 | case 25: return TupleType::template get<25>(); |
5910 | default: throw RangeException(); |
5911 | } |
5912 | } |
5913 | } |
5914 | |
5915 | throw NotFoundException("Name not found: " + name); |
5916 | } |
5917 | |
5918 | const DynamicAny operator [] (const std::string& name) const |
5919 | { |
5920 | return get(name); |
5921 | } |
5922 | |
5923 | template<int N> |
5924 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
5925 | { |
5926 | return TupleType::template get<N>(); |
5927 | } |
5928 | |
5929 | template<int N> |
5930 | typename TypeGetter<N, Type>::HeadType& get() |
5931 | { |
5932 | return TupleType::template get<N>(); |
5933 | } |
5934 | |
5935 | template<int N> |
5936 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
5937 | { |
5938 | return TupleType::template set<N>(val); |
5939 | } |
5940 | |
5941 | const NameVecPtr& names() |
5942 | { |
5943 | return _pNames; |
5944 | } |
5945 | |
5946 | void setName(std::size_t index, const std::string& name) |
5947 | { |
5948 | if (index >= _pNames->size()) |
5949 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
5950 | |
5951 | (*_pNames)[index] = name; |
5952 | } |
5953 | |
5954 | const std::string& getName(std::size_t index) |
5955 | { |
5956 | if (index >= _pNames->size()) |
5957 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
5958 | |
5959 | return (*_pNames)[index]; |
5960 | } |
5961 | |
5962 | bool operator == (const NamedTuple& other) const |
5963 | { |
5964 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
5965 | } |
5966 | |
5967 | bool operator != (const NamedTuple& other) const |
5968 | { |
5969 | return !(*this == other); |
5970 | } |
5971 | |
5972 | bool operator < (const NamedTuple& other) const |
5973 | { |
5974 | TupleType th(*this); |
5975 | TupleType oth(other); |
5976 | |
5977 | return (th < oth && _pNames == other._pNames) || |
5978 | (th == oth && _pNames < other._pNames) || |
5979 | (th < oth && _pNames < other._pNames); |
5980 | } |
5981 | |
5982 | private: |
5983 | void init(const std::string& n0 = "A" , |
5984 | const std::string& n1 = "B" , |
5985 | const std::string& n2 = "C" , |
5986 | const std::string& n3 = "D" , |
5987 | const std::string& n4 = "E" , |
5988 | const std::string& n5 = "F" , |
5989 | const std::string& n6 = "G" , |
5990 | const std::string& n7 = "H" , |
5991 | const std::string& n8 = "I" , |
5992 | const std::string& n9 = "J" , |
5993 | const std::string& n10 = "K" , |
5994 | const std::string& n11 = "L" , |
5995 | const std::string& n12 = "M" , |
5996 | const std::string& n13 = "N" , |
5997 | const std::string& n14 = "O" , |
5998 | const std::string& n15 = "P" , |
5999 | const std::string& n16 = "Q" , |
6000 | const std::string& n17 = "R" , |
6001 | const std::string& n18 = "S" , |
6002 | const std::string& n19 = "T" , |
6003 | const std::string& n20 = "U" , |
6004 | const std::string& n21 = "V" , |
6005 | const std::string& n22 = "W" , |
6006 | const std::string& n23 = "X" , |
6007 | const std::string& n24 = "Y" , |
6008 | const std::string& n25 = "Z" ) |
6009 | { |
6010 | if (!_pNames) |
6011 | { |
6012 | _pNames = new NameVec; |
6013 | _pNames->push_back(n0); |
6014 | _pNames->push_back(n1); |
6015 | _pNames->push_back(n2); |
6016 | _pNames->push_back(n3); |
6017 | _pNames->push_back(n4); |
6018 | _pNames->push_back(n5); |
6019 | _pNames->push_back(n6); |
6020 | _pNames->push_back(n7); |
6021 | _pNames->push_back(n8); |
6022 | _pNames->push_back(n9); |
6023 | _pNames->push_back(n10); |
6024 | _pNames->push_back(n11); |
6025 | _pNames->push_back(n12); |
6026 | _pNames->push_back(n13); |
6027 | _pNames->push_back(n14); |
6028 | _pNames->push_back(n15); |
6029 | _pNames->push_back(n16); |
6030 | _pNames->push_back(n17); |
6031 | _pNames->push_back(n18); |
6032 | _pNames->push_back(n19); |
6033 | _pNames->push_back(n20); |
6034 | _pNames->push_back(n21); |
6035 | _pNames->push_back(n22); |
6036 | _pNames->push_back(n23); |
6037 | _pNames->push_back(n24); |
6038 | _pNames->push_back(n25); |
6039 | } |
6040 | } |
6041 | |
6042 | NameVecPtr _pNames; |
6043 | }; |
6044 | |
6045 | |
6046 | template<class T0, |
6047 | class T1, |
6048 | class T2, |
6049 | class T3, |
6050 | class T4, |
6051 | class T5, |
6052 | class T6, |
6053 | class T7, |
6054 | class T8, |
6055 | class T9, |
6056 | class T10, |
6057 | class T11, |
6058 | class T12, |
6059 | class T13, |
6060 | class T14, |
6061 | class T15, |
6062 | class T16, |
6063 | class T17, |
6064 | class T18, |
6065 | class T19, |
6066 | class T20, |
6067 | class T21, |
6068 | class T22, |
6069 | class T23, |
6070 | class T24> |
6071 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,NullTypeList>: |
6072 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24> |
6073 | { |
6074 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24> TupleType; |
6075 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24>::Type Type; |
6076 | typedef std::vector<std::string> NameVec; |
6077 | typedef SharedPtr<NameVec> NameVecPtr; |
6078 | |
6079 | NamedTuple(): _pNames(0) |
6080 | { |
6081 | init(); |
6082 | } |
6083 | |
6084 | NamedTuple(const NameVecPtr& rNames) |
6085 | { |
6086 | if (rNames->size() != TupleType::length) |
6087 | throw InvalidArgumentException("Wrong names vector length." ); |
6088 | |
6089 | _pNames = rNames; |
6090 | } |
6091 | |
6092 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
6093 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
6094 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
6095 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
6096 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
6097 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
6098 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
6099 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
6100 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
6101 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
6102 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
6103 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
6104 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
6105 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
6106 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
6107 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
6108 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
6109 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
6110 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
6111 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
6112 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
6113 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
6114 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
6115 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
6116 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24)): |
6117 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24), |
6118 | _pNames(0) |
6119 | { |
6120 | init(); |
6121 | } |
6122 | |
6123 | NamedTuple(const NameVecPtr& rNames, |
6124 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
6125 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
6126 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
6127 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
6128 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
6129 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
6130 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
6131 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
6132 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
6133 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
6134 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
6135 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
6136 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
6137 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
6138 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
6139 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
6140 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
6141 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
6142 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
6143 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
6144 | typename TypeWrapper<T0>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
6145 | typename TypeWrapper<T1>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
6146 | typename TypeWrapper<T2>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
6147 | typename TypeWrapper<T3>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
6148 | typename TypeWrapper<T4>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24)): |
6149 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24) |
6150 | { |
6151 | if (rNames->size() != TupleType::length) |
6152 | throw InvalidArgumentException("Wrong names vector length." ); |
6153 | |
6154 | _pNames = rNames; |
6155 | } |
6156 | |
6157 | NamedTuple(const std::string& n0, |
6158 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
6159 | const std::string& n1 = "B" , |
6160 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
6161 | const std::string& n2 = "C" , |
6162 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
6163 | const std::string& n3 = "D" , |
6164 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
6165 | const std::string& n4 = "E" , |
6166 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
6167 | const std::string& n5 = "F" , |
6168 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
6169 | const std::string& n6 = "G" , |
6170 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
6171 | const std::string& n7 = "H" , |
6172 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
6173 | const std::string& n8 = "I" , |
6174 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
6175 | const std::string& n9 = "J" , |
6176 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
6177 | const std::string& n10 = "K" , |
6178 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
6179 | const std::string& n11 = "L" , |
6180 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
6181 | const std::string& n12 = "M" , |
6182 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
6183 | const std::string& n13 = "N" , |
6184 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
6185 | const std::string& n14 = "O" , |
6186 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
6187 | const std::string& n15 = "P" , |
6188 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
6189 | const std::string& n16 = "Q" , |
6190 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
6191 | const std::string& n17 = "R" , |
6192 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
6193 | const std::string& n18 = "S" , |
6194 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
6195 | const std::string& n19 = "T" , |
6196 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
6197 | const std::string& n20 = "U" , |
6198 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
6199 | const std::string& n21 = "V" , |
6200 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
6201 | const std::string& n22 = "W" , |
6202 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
6203 | const std::string& n23 = "X" , |
6204 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23), |
6205 | const std::string& n24 = "Y" , |
6206 | typename TypeWrapper<T24>::CONSTTYPE& t24 = POCO_TYPEWRAPPER_DEFAULTVALUE(T24)): |
6207 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24), |
6208 | _pNames(0) |
6209 | { |
6210 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24); |
6211 | } |
6212 | |
6213 | const DynamicAny get(const std::string& name) const |
6214 | { |
6215 | NameVec::const_iterator it = _pNames->begin(); |
6216 | NameVec::const_iterator itEnd = _pNames->end(); |
6217 | |
6218 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
6219 | { |
6220 | if (name == *it) |
6221 | { |
6222 | switch (counter) |
6223 | { |
6224 | case 0: return TupleType::template get<0>(); |
6225 | case 1: return TupleType::template get<1>(); |
6226 | case 2: return TupleType::template get<2>(); |
6227 | case 3: return TupleType::template get<3>(); |
6228 | case 4: return TupleType::template get<4>(); |
6229 | case 5: return TupleType::template get<5>(); |
6230 | case 6: return TupleType::template get<6>(); |
6231 | case 7: return TupleType::template get<7>(); |
6232 | case 8: return TupleType::template get<8>(); |
6233 | case 9: return TupleType::template get<9>(); |
6234 | case 10: return TupleType::template get<10>(); |
6235 | case 11: return TupleType::template get<11>(); |
6236 | case 12: return TupleType::template get<12>(); |
6237 | case 13: return TupleType::template get<13>(); |
6238 | case 14: return TupleType::template get<14>(); |
6239 | case 15: return TupleType::template get<15>(); |
6240 | case 16: return TupleType::template get<16>(); |
6241 | case 17: return TupleType::template get<17>(); |
6242 | case 18: return TupleType::template get<18>(); |
6243 | case 19: return TupleType::template get<19>(); |
6244 | case 20: return TupleType::template get<20>(); |
6245 | case 21: return TupleType::template get<21>(); |
6246 | case 22: return TupleType::template get<22>(); |
6247 | case 23: return TupleType::template get<23>(); |
6248 | case 24: return TupleType::template get<24>(); |
6249 | default: throw RangeException(); |
6250 | } |
6251 | } |
6252 | } |
6253 | |
6254 | throw NotFoundException("Name not found: " + name); |
6255 | } |
6256 | |
6257 | const DynamicAny operator [] (const std::string& name) const |
6258 | { |
6259 | return get(name); |
6260 | } |
6261 | |
6262 | template<int N> |
6263 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
6264 | { |
6265 | return TupleType::template get<N>(); |
6266 | } |
6267 | |
6268 | template<int N> |
6269 | typename TypeGetter<N, Type>::HeadType& get() |
6270 | { |
6271 | return TupleType::template get<N>(); |
6272 | } |
6273 | |
6274 | template<int N> |
6275 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
6276 | { |
6277 | return TupleType::template set<N>(val); |
6278 | } |
6279 | |
6280 | const NameVecPtr& names() |
6281 | { |
6282 | return _pNames; |
6283 | } |
6284 | |
6285 | void setName(std::size_t index, const std::string& name) |
6286 | { |
6287 | if (index >= _pNames->size()) |
6288 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
6289 | |
6290 | (*_pNames)[index] = name; |
6291 | } |
6292 | |
6293 | const std::string& getName(std::size_t index) |
6294 | { |
6295 | if (index >= _pNames->size()) |
6296 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
6297 | |
6298 | return (*_pNames)[index]; |
6299 | } |
6300 | |
6301 | bool operator == (const NamedTuple& other) const |
6302 | { |
6303 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
6304 | } |
6305 | |
6306 | bool operator != (const NamedTuple& other) const |
6307 | { |
6308 | return !(*this == other); |
6309 | } |
6310 | |
6311 | bool operator < (const NamedTuple& other) const |
6312 | { |
6313 | TupleType th(*this); |
6314 | TupleType oth(other); |
6315 | |
6316 | return (th < oth && _pNames == other._pNames) || |
6317 | (th == oth && _pNames < other._pNames) || |
6318 | (th < oth && _pNames < other._pNames); |
6319 | } |
6320 | |
6321 | private: |
6322 | void init(const std::string& n0 = "A" , |
6323 | const std::string& n1 = "B" , |
6324 | const std::string& n2 = "C" , |
6325 | const std::string& n3 = "D" , |
6326 | const std::string& n4 = "E" , |
6327 | const std::string& n5 = "F" , |
6328 | const std::string& n6 = "G" , |
6329 | const std::string& n7 = "H" , |
6330 | const std::string& n8 = "I" , |
6331 | const std::string& n9 = "J" , |
6332 | const std::string& n10 = "K" , |
6333 | const std::string& n11 = "L" , |
6334 | const std::string& n12 = "M" , |
6335 | const std::string& n13 = "N" , |
6336 | const std::string& n14 = "O" , |
6337 | const std::string& n15 = "P" , |
6338 | const std::string& n16 = "Q" , |
6339 | const std::string& n17 = "R" , |
6340 | const std::string& n18 = "S" , |
6341 | const std::string& n19 = "T" , |
6342 | const std::string& n20 = "U" , |
6343 | const std::string& n21 = "V" , |
6344 | const std::string& n22 = "W" , |
6345 | const std::string& n23 = "X" , |
6346 | const std::string& n24 = "Y" ) |
6347 | { |
6348 | if (!_pNames) |
6349 | { |
6350 | _pNames = new NameVec; |
6351 | _pNames->push_back(n0); |
6352 | _pNames->push_back(n1); |
6353 | _pNames->push_back(n2); |
6354 | _pNames->push_back(n3); |
6355 | _pNames->push_back(n4); |
6356 | _pNames->push_back(n5); |
6357 | _pNames->push_back(n6); |
6358 | _pNames->push_back(n7); |
6359 | _pNames->push_back(n8); |
6360 | _pNames->push_back(n9); |
6361 | _pNames->push_back(n10); |
6362 | _pNames->push_back(n11); |
6363 | _pNames->push_back(n12); |
6364 | _pNames->push_back(n13); |
6365 | _pNames->push_back(n14); |
6366 | _pNames->push_back(n15); |
6367 | _pNames->push_back(n16); |
6368 | _pNames->push_back(n17); |
6369 | _pNames->push_back(n18); |
6370 | _pNames->push_back(n19); |
6371 | _pNames->push_back(n20); |
6372 | _pNames->push_back(n21); |
6373 | _pNames->push_back(n22); |
6374 | _pNames->push_back(n23); |
6375 | _pNames->push_back(n24); |
6376 | } |
6377 | } |
6378 | |
6379 | NameVecPtr _pNames; |
6380 | }; |
6381 | |
6382 | |
6383 | template<class T0, |
6384 | class T1, |
6385 | class T2, |
6386 | class T3, |
6387 | class T4, |
6388 | class T5, |
6389 | class T6, |
6390 | class T7, |
6391 | class T8, |
6392 | class T9, |
6393 | class T10, |
6394 | class T11, |
6395 | class T12, |
6396 | class T13, |
6397 | class T14, |
6398 | class T15, |
6399 | class T16, |
6400 | class T17, |
6401 | class T18, |
6402 | class T19, |
6403 | class T20, |
6404 | class T21, |
6405 | class T22, |
6406 | class T23> |
6407 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,NullTypeList>: |
6408 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23> |
6409 | { |
6410 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23> TupleType; |
6411 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23>::Type Type; |
6412 | typedef std::vector<std::string> NameVec; |
6413 | typedef SharedPtr<NameVec> NameVecPtr; |
6414 | |
6415 | NamedTuple(): _pNames(0) |
6416 | { |
6417 | init(); |
6418 | } |
6419 | |
6420 | NamedTuple(const NameVecPtr& rNames) |
6421 | { |
6422 | if (rNames->size() != TupleType::length) |
6423 | throw InvalidArgumentException("Wrong names vector length." ); |
6424 | |
6425 | _pNames = rNames; |
6426 | } |
6427 | |
6428 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
6429 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
6430 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
6431 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
6432 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
6433 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
6434 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
6435 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
6436 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
6437 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
6438 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
6439 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
6440 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
6441 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
6442 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
6443 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
6444 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
6445 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
6446 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
6447 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
6448 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
6449 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
6450 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
6451 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23)): |
6452 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23), |
6453 | _pNames(0) |
6454 | { |
6455 | init(); |
6456 | } |
6457 | |
6458 | NamedTuple(const NameVecPtr& rNames, |
6459 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
6460 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
6461 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
6462 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
6463 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
6464 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
6465 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
6466 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
6467 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
6468 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
6469 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
6470 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
6471 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
6472 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
6473 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
6474 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
6475 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
6476 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
6477 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
6478 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
6479 | typename TypeWrapper<T0>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
6480 | typename TypeWrapper<T1>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
6481 | typename TypeWrapper<T2>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
6482 | typename TypeWrapper<T3>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23)): |
6483 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23) |
6484 | { |
6485 | if (rNames->size() != TupleType::length) |
6486 | throw InvalidArgumentException("Wrong names vector length." ); |
6487 | |
6488 | _pNames = rNames; |
6489 | } |
6490 | |
6491 | NamedTuple(const std::string& n0, |
6492 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
6493 | const std::string& n1 = "B" , |
6494 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
6495 | const std::string& n2 = "C" , |
6496 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
6497 | const std::string& n3 = "D" , |
6498 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
6499 | const std::string& n4 = "E" , |
6500 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
6501 | const std::string& n5 = "F" , |
6502 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
6503 | const std::string& n6 = "G" , |
6504 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
6505 | const std::string& n7 = "H" , |
6506 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
6507 | const std::string& n8 = "I" , |
6508 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
6509 | const std::string& n9 = "J" , |
6510 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
6511 | const std::string& n10 = "K" , |
6512 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
6513 | const std::string& n11 = "L" , |
6514 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
6515 | const std::string& n12 = "M" , |
6516 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
6517 | const std::string& n13 = "N" , |
6518 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
6519 | const std::string& n14 = "O" , |
6520 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
6521 | const std::string& n15 = "P" , |
6522 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
6523 | const std::string& n16 = "Q" , |
6524 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
6525 | const std::string& n17 = "R" , |
6526 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
6527 | const std::string& n18 = "S" , |
6528 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
6529 | const std::string& n19 = "T" , |
6530 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
6531 | const std::string& n20 = "U" , |
6532 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
6533 | const std::string& n21 = "V" , |
6534 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
6535 | const std::string& n22 = "W" , |
6536 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22), |
6537 | const std::string& n23 = "X" , |
6538 | typename TypeWrapper<T23>::CONSTTYPE& t23 = POCO_TYPEWRAPPER_DEFAULTVALUE(T23)): |
6539 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23), |
6540 | _pNames(0) |
6541 | { |
6542 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23); |
6543 | } |
6544 | |
6545 | const DynamicAny get(const std::string& name) const |
6546 | { |
6547 | NameVec::const_iterator it = _pNames->begin(); |
6548 | NameVec::const_iterator itEnd = _pNames->end(); |
6549 | |
6550 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
6551 | { |
6552 | if (name == *it) |
6553 | { |
6554 | switch (counter) |
6555 | { |
6556 | case 0: return TupleType::template get<0>(); |
6557 | case 1: return TupleType::template get<1>(); |
6558 | case 2: return TupleType::template get<2>(); |
6559 | case 3: return TupleType::template get<3>(); |
6560 | case 4: return TupleType::template get<4>(); |
6561 | case 5: return TupleType::template get<5>(); |
6562 | case 6: return TupleType::template get<6>(); |
6563 | case 7: return TupleType::template get<7>(); |
6564 | case 8: return TupleType::template get<8>(); |
6565 | case 9: return TupleType::template get<9>(); |
6566 | case 10: return TupleType::template get<10>(); |
6567 | case 11: return TupleType::template get<11>(); |
6568 | case 12: return TupleType::template get<12>(); |
6569 | case 13: return TupleType::template get<13>(); |
6570 | case 14: return TupleType::template get<14>(); |
6571 | case 15: return TupleType::template get<15>(); |
6572 | case 16: return TupleType::template get<16>(); |
6573 | case 17: return TupleType::template get<17>(); |
6574 | case 18: return TupleType::template get<18>(); |
6575 | case 19: return TupleType::template get<19>(); |
6576 | case 20: return TupleType::template get<20>(); |
6577 | case 21: return TupleType::template get<21>(); |
6578 | case 22: return TupleType::template get<22>(); |
6579 | case 23: return TupleType::template get<23>(); |
6580 | default: throw RangeException(); |
6581 | } |
6582 | } |
6583 | } |
6584 | |
6585 | throw NotFoundException("Name not found: " + name); |
6586 | } |
6587 | |
6588 | const DynamicAny operator [] (const std::string& name) const |
6589 | { |
6590 | return get(name); |
6591 | } |
6592 | |
6593 | template<int N> |
6594 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
6595 | { |
6596 | return TupleType::template get<N>(); |
6597 | } |
6598 | |
6599 | template<int N> |
6600 | typename TypeGetter<N, Type>::HeadType& get() |
6601 | { |
6602 | return TupleType::template get<N>(); |
6603 | } |
6604 | |
6605 | template<int N> |
6606 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
6607 | { |
6608 | return TupleType::template set<N>(val); |
6609 | } |
6610 | |
6611 | const NameVecPtr& names() |
6612 | { |
6613 | return _pNames; |
6614 | } |
6615 | |
6616 | void setName(std::size_t index, const std::string& name) |
6617 | { |
6618 | if (index >= _pNames->size()) |
6619 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
6620 | |
6621 | (*_pNames)[index] = name; |
6622 | } |
6623 | |
6624 | const std::string& getName(std::size_t index) |
6625 | { |
6626 | if (index >= _pNames->size()) |
6627 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
6628 | |
6629 | return (*_pNames)[index]; |
6630 | } |
6631 | |
6632 | bool operator == (const NamedTuple& other) const |
6633 | { |
6634 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
6635 | } |
6636 | |
6637 | bool operator != (const NamedTuple& other) const |
6638 | { |
6639 | return !(*this == other); |
6640 | } |
6641 | |
6642 | bool operator < (const NamedTuple& other) const |
6643 | { |
6644 | TupleType th(*this); |
6645 | TupleType oth(other); |
6646 | |
6647 | return (th < oth && _pNames == other._pNames) || |
6648 | (th == oth && _pNames < other._pNames) || |
6649 | (th < oth && _pNames < other._pNames); |
6650 | } |
6651 | |
6652 | private: |
6653 | void init(const std::string& n0 = "A" , |
6654 | const std::string& n1 = "B" , |
6655 | const std::string& n2 = "C" , |
6656 | const std::string& n3 = "D" , |
6657 | const std::string& n4 = "E" , |
6658 | const std::string& n5 = "F" , |
6659 | const std::string& n6 = "G" , |
6660 | const std::string& n7 = "H" , |
6661 | const std::string& n8 = "I" , |
6662 | const std::string& n9 = "J" , |
6663 | const std::string& n10 = "K" , |
6664 | const std::string& n11 = "L" , |
6665 | const std::string& n12 = "M" , |
6666 | const std::string& n13 = "N" , |
6667 | const std::string& n14 = "O" , |
6668 | const std::string& n15 = "P" , |
6669 | const std::string& n16 = "Q" , |
6670 | const std::string& n17 = "R" , |
6671 | const std::string& n18 = "S" , |
6672 | const std::string& n19 = "T" , |
6673 | const std::string& n20 = "U" , |
6674 | const std::string& n21 = "V" , |
6675 | const std::string& n22 = "W" , |
6676 | const std::string& n23 = "X" ) |
6677 | { |
6678 | if (!_pNames) |
6679 | { |
6680 | _pNames = new NameVec; |
6681 | _pNames->push_back(n0); |
6682 | _pNames->push_back(n1); |
6683 | _pNames->push_back(n2); |
6684 | _pNames->push_back(n3); |
6685 | _pNames->push_back(n4); |
6686 | _pNames->push_back(n5); |
6687 | _pNames->push_back(n6); |
6688 | _pNames->push_back(n7); |
6689 | _pNames->push_back(n8); |
6690 | _pNames->push_back(n9); |
6691 | _pNames->push_back(n10); |
6692 | _pNames->push_back(n11); |
6693 | _pNames->push_back(n12); |
6694 | _pNames->push_back(n13); |
6695 | _pNames->push_back(n14); |
6696 | _pNames->push_back(n15); |
6697 | _pNames->push_back(n16); |
6698 | _pNames->push_back(n17); |
6699 | _pNames->push_back(n18); |
6700 | _pNames->push_back(n19); |
6701 | _pNames->push_back(n20); |
6702 | _pNames->push_back(n21); |
6703 | _pNames->push_back(n22); |
6704 | _pNames->push_back(n23); |
6705 | } |
6706 | } |
6707 | |
6708 | NameVecPtr _pNames; |
6709 | }; |
6710 | |
6711 | |
6712 | template<class T0, |
6713 | class T1, |
6714 | class T2, |
6715 | class T3, |
6716 | class T4, |
6717 | class T5, |
6718 | class T6, |
6719 | class T7, |
6720 | class T8, |
6721 | class T9, |
6722 | class T10, |
6723 | class T11, |
6724 | class T12, |
6725 | class T13, |
6726 | class T14, |
6727 | class T15, |
6728 | class T16, |
6729 | class T17, |
6730 | class T18, |
6731 | class T19, |
6732 | class T20, |
6733 | class T21, |
6734 | class T22> |
6735 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,NullTypeList>: |
6736 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22> |
6737 | { |
6738 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22> TupleType; |
6739 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22>::Type Type; |
6740 | typedef std::vector<std::string> NameVec; |
6741 | typedef SharedPtr<NameVec> NameVecPtr; |
6742 | |
6743 | NamedTuple(): _pNames(0) |
6744 | { |
6745 | init(); |
6746 | } |
6747 | |
6748 | NamedTuple(const NameVecPtr& rNames) |
6749 | { |
6750 | if (rNames->size() != TupleType::length) |
6751 | throw InvalidArgumentException("Wrong names vector length." ); |
6752 | |
6753 | _pNames = rNames; |
6754 | } |
6755 | |
6756 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
6757 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
6758 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
6759 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
6760 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
6761 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
6762 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
6763 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
6764 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
6765 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
6766 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
6767 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
6768 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
6769 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
6770 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
6771 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
6772 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
6773 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
6774 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
6775 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
6776 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
6777 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
6778 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22)): |
6779 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22), |
6780 | _pNames(0) |
6781 | { |
6782 | init(); |
6783 | } |
6784 | |
6785 | NamedTuple(const NameVecPtr& rNames, |
6786 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
6787 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
6788 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
6789 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
6790 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
6791 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
6792 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
6793 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
6794 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
6795 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
6796 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
6797 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
6798 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
6799 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
6800 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
6801 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
6802 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
6803 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
6804 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
6805 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
6806 | typename TypeWrapper<T0>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
6807 | typename TypeWrapper<T1>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
6808 | typename TypeWrapper<T2>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22)): |
6809 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22) |
6810 | { |
6811 | if (rNames->size() != TupleType::length) |
6812 | throw InvalidArgumentException("Wrong names vector length." ); |
6813 | |
6814 | _pNames = rNames; |
6815 | } |
6816 | |
6817 | NamedTuple(const std::string& n0, |
6818 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
6819 | const std::string& n1 = "B" , |
6820 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
6821 | const std::string& n2 = "C" , |
6822 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
6823 | const std::string& n3 = "D" , |
6824 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
6825 | const std::string& n4 = "E" , |
6826 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
6827 | const std::string& n5 = "F" , |
6828 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
6829 | const std::string& n6 = "G" , |
6830 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
6831 | const std::string& n7 = "H" , |
6832 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
6833 | const std::string& n8 = "I" , |
6834 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
6835 | const std::string& n9 = "J" , |
6836 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
6837 | const std::string& n10 = "K" , |
6838 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
6839 | const std::string& n11 = "L" , |
6840 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
6841 | const std::string& n12 = "M" , |
6842 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
6843 | const std::string& n13 = "N" , |
6844 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
6845 | const std::string& n14 = "O" , |
6846 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
6847 | const std::string& n15 = "P" , |
6848 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
6849 | const std::string& n16 = "Q" , |
6850 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
6851 | const std::string& n17 = "R" , |
6852 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
6853 | const std::string& n18 = "S" , |
6854 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
6855 | const std::string& n19 = "T" , |
6856 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
6857 | const std::string& n20 = "U" , |
6858 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
6859 | const std::string& n21 = "V" , |
6860 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21), |
6861 | const std::string& n22 = "W" , |
6862 | typename TypeWrapper<T22>::CONSTTYPE& t22 = POCO_TYPEWRAPPER_DEFAULTVALUE(T22)): |
6863 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22), |
6864 | _pNames(0) |
6865 | { |
6866 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22); |
6867 | } |
6868 | |
6869 | const DynamicAny get(const std::string& name) const |
6870 | { |
6871 | NameVec::const_iterator it = _pNames->begin(); |
6872 | NameVec::const_iterator itEnd = _pNames->end(); |
6873 | |
6874 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
6875 | { |
6876 | if (name == *it) |
6877 | { |
6878 | switch (counter) |
6879 | { |
6880 | case 0: return TupleType::template get<0>(); |
6881 | case 1: return TupleType::template get<1>(); |
6882 | case 2: return TupleType::template get<2>(); |
6883 | case 3: return TupleType::template get<3>(); |
6884 | case 4: return TupleType::template get<4>(); |
6885 | case 5: return TupleType::template get<5>(); |
6886 | case 6: return TupleType::template get<6>(); |
6887 | case 7: return TupleType::template get<7>(); |
6888 | case 8: return TupleType::template get<8>(); |
6889 | case 9: return TupleType::template get<9>(); |
6890 | case 10: return TupleType::template get<10>(); |
6891 | case 11: return TupleType::template get<11>(); |
6892 | case 12: return TupleType::template get<12>(); |
6893 | case 13: return TupleType::template get<13>(); |
6894 | case 14: return TupleType::template get<14>(); |
6895 | case 15: return TupleType::template get<15>(); |
6896 | case 16: return TupleType::template get<16>(); |
6897 | case 17: return TupleType::template get<17>(); |
6898 | case 18: return TupleType::template get<18>(); |
6899 | case 19: return TupleType::template get<19>(); |
6900 | case 20: return TupleType::template get<20>(); |
6901 | case 21: return TupleType::template get<21>(); |
6902 | case 22: return TupleType::template get<22>(); |
6903 | default: throw RangeException(); |
6904 | } |
6905 | } |
6906 | } |
6907 | |
6908 | throw NotFoundException("Name not found: " + name); |
6909 | } |
6910 | |
6911 | const DynamicAny operator [] (const std::string& name) const |
6912 | { |
6913 | return get(name); |
6914 | } |
6915 | |
6916 | template<int N> |
6917 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
6918 | { |
6919 | return TupleType::template get<N>(); |
6920 | } |
6921 | |
6922 | template<int N> |
6923 | typename TypeGetter<N, Type>::HeadType& get() |
6924 | { |
6925 | return TupleType::template get<N>(); |
6926 | } |
6927 | |
6928 | template<int N> |
6929 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
6930 | { |
6931 | return TupleType::template set<N>(val); |
6932 | } |
6933 | |
6934 | const NameVecPtr& names() |
6935 | { |
6936 | return _pNames; |
6937 | } |
6938 | |
6939 | void setName(std::size_t index, const std::string& name) |
6940 | { |
6941 | if (index >= _pNames->size()) |
6942 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
6943 | |
6944 | (*_pNames)[index] = name; |
6945 | } |
6946 | |
6947 | const std::string& getName(std::size_t index) |
6948 | { |
6949 | if (index >= _pNames->size()) |
6950 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
6951 | |
6952 | return (*_pNames)[index]; |
6953 | } |
6954 | |
6955 | bool operator == (const NamedTuple& other) const |
6956 | { |
6957 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
6958 | } |
6959 | |
6960 | bool operator != (const NamedTuple& other) const |
6961 | { |
6962 | return !(*this == other); |
6963 | } |
6964 | |
6965 | bool operator < (const NamedTuple& other) const |
6966 | { |
6967 | TupleType th(*this); |
6968 | TupleType oth(other); |
6969 | |
6970 | return (th < oth && _pNames == other._pNames) || |
6971 | (th == oth && _pNames < other._pNames) || |
6972 | (th < oth && _pNames < other._pNames); |
6973 | } |
6974 | |
6975 | private: |
6976 | void init(const std::string& n0 = "A" , |
6977 | const std::string& n1 = "B" , |
6978 | const std::string& n2 = "C" , |
6979 | const std::string& n3 = "D" , |
6980 | const std::string& n4 = "E" , |
6981 | const std::string& n5 = "F" , |
6982 | const std::string& n6 = "G" , |
6983 | const std::string& n7 = "H" , |
6984 | const std::string& n8 = "I" , |
6985 | const std::string& n9 = "J" , |
6986 | const std::string& n10 = "K" , |
6987 | const std::string& n11 = "L" , |
6988 | const std::string& n12 = "M" , |
6989 | const std::string& n13 = "N" , |
6990 | const std::string& n14 = "O" , |
6991 | const std::string& n15 = "P" , |
6992 | const std::string& n16 = "Q" , |
6993 | const std::string& n17 = "R" , |
6994 | const std::string& n18 = "S" , |
6995 | const std::string& n19 = "T" , |
6996 | const std::string& n20 = "U" , |
6997 | const std::string& n21 = "V" , |
6998 | const std::string& n22 = "W" ) |
6999 | { |
7000 | if (!_pNames) |
7001 | { |
7002 | _pNames = new NameVec; |
7003 | _pNames->push_back(n0); |
7004 | _pNames->push_back(n1); |
7005 | _pNames->push_back(n2); |
7006 | _pNames->push_back(n3); |
7007 | _pNames->push_back(n4); |
7008 | _pNames->push_back(n5); |
7009 | _pNames->push_back(n6); |
7010 | _pNames->push_back(n7); |
7011 | _pNames->push_back(n8); |
7012 | _pNames->push_back(n9); |
7013 | _pNames->push_back(n10); |
7014 | _pNames->push_back(n11); |
7015 | _pNames->push_back(n12); |
7016 | _pNames->push_back(n13); |
7017 | _pNames->push_back(n14); |
7018 | _pNames->push_back(n15); |
7019 | _pNames->push_back(n16); |
7020 | _pNames->push_back(n17); |
7021 | _pNames->push_back(n18); |
7022 | _pNames->push_back(n19); |
7023 | _pNames->push_back(n20); |
7024 | _pNames->push_back(n21); |
7025 | _pNames->push_back(n22); |
7026 | } |
7027 | } |
7028 | |
7029 | NameVecPtr _pNames; |
7030 | }; |
7031 | |
7032 | |
7033 | template<class T0, |
7034 | class T1, |
7035 | class T2, |
7036 | class T3, |
7037 | class T4, |
7038 | class T5, |
7039 | class T6, |
7040 | class T7, |
7041 | class T8, |
7042 | class T9, |
7043 | class T10, |
7044 | class T11, |
7045 | class T12, |
7046 | class T13, |
7047 | class T14, |
7048 | class T15, |
7049 | class T16, |
7050 | class T17, |
7051 | class T18, |
7052 | class T19, |
7053 | class T20, |
7054 | class T21> |
7055 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,NullTypeList>: |
7056 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21> |
7057 | { |
7058 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21> TupleType; |
7059 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21>::Type Type; |
7060 | typedef std::vector<std::string> NameVec; |
7061 | typedef SharedPtr<NameVec> NameVecPtr; |
7062 | |
7063 | NamedTuple(): _pNames(0) |
7064 | { |
7065 | init(); |
7066 | } |
7067 | |
7068 | NamedTuple(const NameVecPtr& rNames) |
7069 | { |
7070 | if (rNames->size() != TupleType::length) |
7071 | throw InvalidArgumentException("Wrong names vector length." ); |
7072 | |
7073 | _pNames = rNames; |
7074 | } |
7075 | |
7076 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
7077 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
7078 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
7079 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
7080 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
7081 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
7082 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
7083 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
7084 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
7085 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
7086 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
7087 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
7088 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
7089 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
7090 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
7091 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
7092 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
7093 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
7094 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
7095 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
7096 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
7097 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21)): |
7098 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21), |
7099 | _pNames(0) |
7100 | { |
7101 | init(); |
7102 | } |
7103 | |
7104 | NamedTuple(const NameVecPtr& rNames, |
7105 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
7106 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
7107 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
7108 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
7109 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
7110 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
7111 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
7112 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
7113 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
7114 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
7115 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
7116 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
7117 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
7118 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
7119 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
7120 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
7121 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
7122 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
7123 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
7124 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
7125 | typename TypeWrapper<T0>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
7126 | typename TypeWrapper<T1>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21)): |
7127 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21) |
7128 | { |
7129 | if (rNames->size() != TupleType::length) |
7130 | throw InvalidArgumentException("Wrong names vector length." ); |
7131 | |
7132 | _pNames = rNames; |
7133 | } |
7134 | |
7135 | NamedTuple(const std::string& n0, |
7136 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
7137 | const std::string& n1 = "B" , |
7138 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
7139 | const std::string& n2 = "C" , |
7140 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
7141 | const std::string& n3 = "D" , |
7142 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
7143 | const std::string& n4 = "E" , |
7144 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
7145 | const std::string& n5 = "F" , |
7146 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
7147 | const std::string& n6 = "G" , |
7148 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
7149 | const std::string& n7 = "H" , |
7150 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
7151 | const std::string& n8 = "I" , |
7152 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
7153 | const std::string& n9 = "J" , |
7154 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
7155 | const std::string& n10 = "K" , |
7156 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
7157 | const std::string& n11 = "L" , |
7158 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
7159 | const std::string& n12 = "M" , |
7160 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
7161 | const std::string& n13 = "N" , |
7162 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
7163 | const std::string& n14 = "O" , |
7164 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
7165 | const std::string& n15 = "P" , |
7166 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
7167 | const std::string& n16 = "Q" , |
7168 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
7169 | const std::string& n17 = "R" , |
7170 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
7171 | const std::string& n18 = "S" , |
7172 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
7173 | const std::string& n19 = "T" , |
7174 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
7175 | const std::string& n20 = "U" , |
7176 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20), |
7177 | const std::string& n21 = "V" , |
7178 | typename TypeWrapper<T21>::CONSTTYPE& t21 = POCO_TYPEWRAPPER_DEFAULTVALUE(T21)): |
7179 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21), |
7180 | _pNames(0) |
7181 | { |
7182 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21); |
7183 | } |
7184 | |
7185 | const DynamicAny get(const std::string& name) const |
7186 | { |
7187 | NameVec::const_iterator it = _pNames->begin(); |
7188 | NameVec::const_iterator itEnd = _pNames->end(); |
7189 | |
7190 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
7191 | { |
7192 | if (name == *it) |
7193 | { |
7194 | switch (counter) |
7195 | { |
7196 | case 0: return TupleType::template get<0>(); |
7197 | case 1: return TupleType::template get<1>(); |
7198 | case 2: return TupleType::template get<2>(); |
7199 | case 3: return TupleType::template get<3>(); |
7200 | case 4: return TupleType::template get<4>(); |
7201 | case 5: return TupleType::template get<5>(); |
7202 | case 6: return TupleType::template get<6>(); |
7203 | case 7: return TupleType::template get<7>(); |
7204 | case 8: return TupleType::template get<8>(); |
7205 | case 9: return TupleType::template get<9>(); |
7206 | case 10: return TupleType::template get<10>(); |
7207 | case 11: return TupleType::template get<11>(); |
7208 | case 12: return TupleType::template get<12>(); |
7209 | case 13: return TupleType::template get<13>(); |
7210 | case 14: return TupleType::template get<14>(); |
7211 | case 15: return TupleType::template get<15>(); |
7212 | case 16: return TupleType::template get<16>(); |
7213 | case 17: return TupleType::template get<17>(); |
7214 | case 18: return TupleType::template get<18>(); |
7215 | case 19: return TupleType::template get<19>(); |
7216 | case 20: return TupleType::template get<20>(); |
7217 | case 21: return TupleType::template get<21>(); |
7218 | default: throw RangeException(); |
7219 | } |
7220 | } |
7221 | } |
7222 | |
7223 | throw NotFoundException("Name not found: " + name); |
7224 | } |
7225 | |
7226 | const DynamicAny operator [] (const std::string& name) const |
7227 | { |
7228 | return get(name); |
7229 | } |
7230 | |
7231 | template<int N> |
7232 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
7233 | { |
7234 | return TupleType::template get<N>(); |
7235 | } |
7236 | |
7237 | template<int N> |
7238 | typename TypeGetter<N, Type>::HeadType& get() |
7239 | { |
7240 | return TupleType::template get<N>(); |
7241 | } |
7242 | |
7243 | template<int N> |
7244 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
7245 | { |
7246 | return TupleType::template set<N>(val); |
7247 | } |
7248 | |
7249 | const NameVecPtr& names() |
7250 | { |
7251 | return _pNames; |
7252 | } |
7253 | |
7254 | void setName(std::size_t index, const std::string& name) |
7255 | { |
7256 | if (index >= _pNames->size()) |
7257 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
7258 | |
7259 | (*_pNames)[index] = name; |
7260 | } |
7261 | |
7262 | const std::string& getName(std::size_t index) |
7263 | { |
7264 | if (index >= _pNames->size()) |
7265 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
7266 | |
7267 | return (*_pNames)[index]; |
7268 | } |
7269 | |
7270 | bool operator == (const NamedTuple& other) const |
7271 | { |
7272 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
7273 | } |
7274 | |
7275 | bool operator != (const NamedTuple& other) const |
7276 | { |
7277 | return !(*this == other); |
7278 | } |
7279 | |
7280 | bool operator < (const NamedTuple& other) const |
7281 | { |
7282 | TupleType th(*this); |
7283 | TupleType oth(other); |
7284 | |
7285 | return (th < oth && _pNames == other._pNames) || |
7286 | (th == oth && _pNames < other._pNames) || |
7287 | (th < oth && _pNames < other._pNames); |
7288 | } |
7289 | |
7290 | private: |
7291 | void init(const std::string& n0 = "A" , |
7292 | const std::string& n1 = "B" , |
7293 | const std::string& n2 = "C" , |
7294 | const std::string& n3 = "D" , |
7295 | const std::string& n4 = "E" , |
7296 | const std::string& n5 = "F" , |
7297 | const std::string& n6 = "G" , |
7298 | const std::string& n7 = "H" , |
7299 | const std::string& n8 = "I" , |
7300 | const std::string& n9 = "J" , |
7301 | const std::string& n10 = "K" , |
7302 | const std::string& n11 = "L" , |
7303 | const std::string& n12 = "M" , |
7304 | const std::string& n13 = "N" , |
7305 | const std::string& n14 = "O" , |
7306 | const std::string& n15 = "P" , |
7307 | const std::string& n16 = "Q" , |
7308 | const std::string& n17 = "R" , |
7309 | const std::string& n18 = "S" , |
7310 | const std::string& n19 = "T" , |
7311 | const std::string& n20 = "U" , |
7312 | const std::string& n21 = "V" ) |
7313 | { |
7314 | if (!_pNames) |
7315 | { |
7316 | _pNames = new NameVec; |
7317 | _pNames->push_back(n0); |
7318 | _pNames->push_back(n1); |
7319 | _pNames->push_back(n2); |
7320 | _pNames->push_back(n3); |
7321 | _pNames->push_back(n4); |
7322 | _pNames->push_back(n5); |
7323 | _pNames->push_back(n6); |
7324 | _pNames->push_back(n7); |
7325 | _pNames->push_back(n8); |
7326 | _pNames->push_back(n9); |
7327 | _pNames->push_back(n10); |
7328 | _pNames->push_back(n11); |
7329 | _pNames->push_back(n12); |
7330 | _pNames->push_back(n13); |
7331 | _pNames->push_back(n14); |
7332 | _pNames->push_back(n15); |
7333 | _pNames->push_back(n16); |
7334 | _pNames->push_back(n17); |
7335 | _pNames->push_back(n18); |
7336 | _pNames->push_back(n19); |
7337 | _pNames->push_back(n20); |
7338 | _pNames->push_back(n21); |
7339 | } |
7340 | } |
7341 | |
7342 | NameVecPtr _pNames; |
7343 | }; |
7344 | |
7345 | |
7346 | template<class T0, |
7347 | class T1, |
7348 | class T2, |
7349 | class T3, |
7350 | class T4, |
7351 | class T5, |
7352 | class T6, |
7353 | class T7, |
7354 | class T8, |
7355 | class T9, |
7356 | class T10, |
7357 | class T11, |
7358 | class T12, |
7359 | class T13, |
7360 | class T14, |
7361 | class T15, |
7362 | class T16, |
7363 | class T17, |
7364 | class T18, |
7365 | class T19, |
7366 | class T20> |
7367 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,NullTypeList>: |
7368 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20> |
7369 | { |
7370 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20> TupleType; |
7371 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20>::Type Type; |
7372 | typedef std::vector<std::string> NameVec; |
7373 | typedef SharedPtr<NameVec> NameVecPtr; |
7374 | |
7375 | NamedTuple(): _pNames(0) |
7376 | { |
7377 | init(); |
7378 | } |
7379 | |
7380 | NamedTuple(const NameVecPtr& rNames) |
7381 | { |
7382 | if (rNames->size() != TupleType::length) |
7383 | throw InvalidArgumentException("Wrong names vector length." ); |
7384 | |
7385 | _pNames = rNames; |
7386 | } |
7387 | |
7388 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
7389 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
7390 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
7391 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
7392 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
7393 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
7394 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
7395 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
7396 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
7397 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
7398 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
7399 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
7400 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
7401 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
7402 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
7403 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
7404 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
7405 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
7406 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
7407 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
7408 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20)): |
7409 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20), |
7410 | _pNames(0) |
7411 | { |
7412 | init(); |
7413 | } |
7414 | |
7415 | NamedTuple(const NameVecPtr& rNames, |
7416 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
7417 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
7418 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
7419 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
7420 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
7421 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
7422 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
7423 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
7424 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
7425 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
7426 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
7427 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
7428 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
7429 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
7430 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
7431 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
7432 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
7433 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
7434 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
7435 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
7436 | typename TypeWrapper<T0>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20)): |
7437 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20) |
7438 | { |
7439 | if (rNames->size() != TupleType::length) |
7440 | throw InvalidArgumentException("Wrong names vector length." ); |
7441 | |
7442 | _pNames = rNames; |
7443 | } |
7444 | |
7445 | NamedTuple(const std::string& n0, |
7446 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
7447 | const std::string& n1 = "B" , |
7448 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
7449 | const std::string& n2 = "C" , |
7450 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
7451 | const std::string& n3 = "D" , |
7452 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
7453 | const std::string& n4 = "E" , |
7454 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
7455 | const std::string& n5 = "F" , |
7456 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
7457 | const std::string& n6 = "G" , |
7458 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
7459 | const std::string& n7 = "H" , |
7460 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
7461 | const std::string& n8 = "I" , |
7462 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
7463 | const std::string& n9 = "J" , |
7464 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
7465 | const std::string& n10 = "K" , |
7466 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
7467 | const std::string& n11 = "L" , |
7468 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
7469 | const std::string& n12 = "M" , |
7470 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
7471 | const std::string& n13 = "N" , |
7472 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
7473 | const std::string& n14 = "O" , |
7474 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
7475 | const std::string& n15 = "P" , |
7476 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
7477 | const std::string& n16 = "Q" , |
7478 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
7479 | const std::string& n17 = "R" , |
7480 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
7481 | const std::string& n18 = "S" , |
7482 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
7483 | const std::string& n19 = "T" , |
7484 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19), |
7485 | const std::string& n20 = "U" , |
7486 | typename TypeWrapper<T20>::CONSTTYPE& t20 = POCO_TYPEWRAPPER_DEFAULTVALUE(T20)): |
7487 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20), |
7488 | _pNames(0) |
7489 | { |
7490 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20); |
7491 | } |
7492 | |
7493 | const DynamicAny get(const std::string& name) const |
7494 | { |
7495 | NameVec::const_iterator it = _pNames->begin(); |
7496 | NameVec::const_iterator itEnd = _pNames->end(); |
7497 | |
7498 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
7499 | { |
7500 | if (name == *it) |
7501 | { |
7502 | switch (counter) |
7503 | { |
7504 | case 0: return TupleType::template get<0>(); |
7505 | case 1: return TupleType::template get<1>(); |
7506 | case 2: return TupleType::template get<2>(); |
7507 | case 3: return TupleType::template get<3>(); |
7508 | case 4: return TupleType::template get<4>(); |
7509 | case 5: return TupleType::template get<5>(); |
7510 | case 6: return TupleType::template get<6>(); |
7511 | case 7: return TupleType::template get<7>(); |
7512 | case 8: return TupleType::template get<8>(); |
7513 | case 9: return TupleType::template get<9>(); |
7514 | case 10: return TupleType::template get<10>(); |
7515 | case 11: return TupleType::template get<11>(); |
7516 | case 12: return TupleType::template get<12>(); |
7517 | case 13: return TupleType::template get<13>(); |
7518 | case 14: return TupleType::template get<14>(); |
7519 | case 15: return TupleType::template get<15>(); |
7520 | case 16: return TupleType::template get<16>(); |
7521 | case 17: return TupleType::template get<17>(); |
7522 | case 18: return TupleType::template get<18>(); |
7523 | case 19: return TupleType::template get<19>(); |
7524 | case 20: return TupleType::template get<20>(); |
7525 | default: throw RangeException(); |
7526 | } |
7527 | } |
7528 | } |
7529 | |
7530 | throw NotFoundException("Name not found: " + name); |
7531 | } |
7532 | |
7533 | const DynamicAny operator [] (const std::string& name) const |
7534 | { |
7535 | return get(name); |
7536 | } |
7537 | |
7538 | template<int N> |
7539 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
7540 | { |
7541 | return TupleType::template get<N>(); |
7542 | } |
7543 | |
7544 | template<int N> |
7545 | typename TypeGetter<N, Type>::HeadType& get() |
7546 | { |
7547 | return TupleType::template get<N>(); |
7548 | } |
7549 | |
7550 | template<int N> |
7551 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
7552 | { |
7553 | return TupleType::template set<N>(val); |
7554 | } |
7555 | |
7556 | const NameVecPtr& names() |
7557 | { |
7558 | return _pNames; |
7559 | } |
7560 | |
7561 | void setName(std::size_t index, const std::string& name) |
7562 | { |
7563 | if (index >= _pNames->size()) |
7564 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
7565 | |
7566 | (*_pNames)[index] = name; |
7567 | } |
7568 | |
7569 | const std::string& getName(std::size_t index) |
7570 | { |
7571 | if (index >= _pNames->size()) |
7572 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
7573 | |
7574 | return (*_pNames)[index]; |
7575 | } |
7576 | |
7577 | bool operator == (const NamedTuple& other) const |
7578 | { |
7579 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
7580 | } |
7581 | |
7582 | bool operator != (const NamedTuple& other) const |
7583 | { |
7584 | return !(*this == other); |
7585 | } |
7586 | |
7587 | bool operator < (const NamedTuple& other) const |
7588 | { |
7589 | TupleType th(*this); |
7590 | TupleType oth(other); |
7591 | |
7592 | return (th < oth && _pNames == other._pNames) || |
7593 | (th == oth && _pNames < other._pNames) || |
7594 | (th < oth && _pNames < other._pNames); |
7595 | } |
7596 | |
7597 | private: |
7598 | void init(const std::string& n0 = "A" , |
7599 | const std::string& n1 = "B" , |
7600 | const std::string& n2 = "C" , |
7601 | const std::string& n3 = "D" , |
7602 | const std::string& n4 = "E" , |
7603 | const std::string& n5 = "F" , |
7604 | const std::string& n6 = "G" , |
7605 | const std::string& n7 = "H" , |
7606 | const std::string& n8 = "I" , |
7607 | const std::string& n9 = "J" , |
7608 | const std::string& n10 = "K" , |
7609 | const std::string& n11 = "L" , |
7610 | const std::string& n12 = "M" , |
7611 | const std::string& n13 = "N" , |
7612 | const std::string& n14 = "O" , |
7613 | const std::string& n15 = "P" , |
7614 | const std::string& n16 = "Q" , |
7615 | const std::string& n17 = "R" , |
7616 | const std::string& n18 = "S" , |
7617 | const std::string& n19 = "T" , |
7618 | const std::string& n20 = "U" ) |
7619 | { |
7620 | if (!_pNames) |
7621 | { |
7622 | _pNames = new NameVec; |
7623 | _pNames->push_back(n0); |
7624 | _pNames->push_back(n1); |
7625 | _pNames->push_back(n2); |
7626 | _pNames->push_back(n3); |
7627 | _pNames->push_back(n4); |
7628 | _pNames->push_back(n5); |
7629 | _pNames->push_back(n6); |
7630 | _pNames->push_back(n7); |
7631 | _pNames->push_back(n8); |
7632 | _pNames->push_back(n9); |
7633 | _pNames->push_back(n10); |
7634 | _pNames->push_back(n11); |
7635 | _pNames->push_back(n12); |
7636 | _pNames->push_back(n13); |
7637 | _pNames->push_back(n14); |
7638 | _pNames->push_back(n15); |
7639 | _pNames->push_back(n16); |
7640 | _pNames->push_back(n17); |
7641 | _pNames->push_back(n18); |
7642 | _pNames->push_back(n19); |
7643 | _pNames->push_back(n20); |
7644 | } |
7645 | } |
7646 | |
7647 | NameVecPtr _pNames; |
7648 | }; |
7649 | |
7650 | |
7651 | template<class T0, |
7652 | class T1, |
7653 | class T2, |
7654 | class T3, |
7655 | class T4, |
7656 | class T5, |
7657 | class T6, |
7658 | class T7, |
7659 | class T8, |
7660 | class T9, |
7661 | class T10, |
7662 | class T11, |
7663 | class T12, |
7664 | class T13, |
7665 | class T14, |
7666 | class T15, |
7667 | class T16, |
7668 | class T17, |
7669 | class T18, |
7670 | class T19> |
7671 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,NullTypeList>: |
7672 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19> |
7673 | { |
7674 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19> TupleType; |
7675 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>::Type Type; |
7676 | typedef std::vector<std::string> NameVec; |
7677 | typedef SharedPtr<NameVec> NameVecPtr; |
7678 | |
7679 | NamedTuple(): _pNames(0) |
7680 | { |
7681 | init(); |
7682 | } |
7683 | |
7684 | NamedTuple(const NameVecPtr& rNames) |
7685 | { |
7686 | if (rNames->size() != TupleType::length) |
7687 | throw InvalidArgumentException("Wrong names vector length." ); |
7688 | |
7689 | _pNames = rNames; |
7690 | } |
7691 | |
7692 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
7693 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
7694 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
7695 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
7696 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
7697 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
7698 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
7699 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
7700 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
7701 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
7702 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
7703 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
7704 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
7705 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
7706 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
7707 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
7708 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
7709 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
7710 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
7711 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19)): |
7712 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19), |
7713 | _pNames(0) |
7714 | { |
7715 | init(); |
7716 | } |
7717 | |
7718 | NamedTuple(const NameVecPtr& rNames, |
7719 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
7720 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
7721 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
7722 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
7723 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
7724 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
7725 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
7726 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
7727 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
7728 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
7729 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
7730 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
7731 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
7732 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
7733 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
7734 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
7735 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
7736 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
7737 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
7738 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19)): |
7739 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19) |
7740 | { |
7741 | if (rNames->size() != TupleType::length) |
7742 | throw InvalidArgumentException("Wrong names vector length." ); |
7743 | |
7744 | _pNames = rNames; |
7745 | } |
7746 | |
7747 | NamedTuple(const std::string& n0, |
7748 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
7749 | const std::string& n1 = "B" , |
7750 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
7751 | const std::string& n2 = "C" , |
7752 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
7753 | const std::string& n3 = "D" , |
7754 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
7755 | const std::string& n4 = "E" , |
7756 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
7757 | const std::string& n5 = "F" , |
7758 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
7759 | const std::string& n6 = "G" , |
7760 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
7761 | const std::string& n7 = "H" , |
7762 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
7763 | const std::string& n8 = "I" , |
7764 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
7765 | const std::string& n9 = "J" , |
7766 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
7767 | const std::string& n10 = "K" , |
7768 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
7769 | const std::string& n11 = "L" , |
7770 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
7771 | const std::string& n12 = "M" , |
7772 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
7773 | const std::string& n13 = "N" , |
7774 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
7775 | const std::string& n14 = "O" , |
7776 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
7777 | const std::string& n15 = "P" , |
7778 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
7779 | const std::string& n16 = "Q" , |
7780 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
7781 | const std::string& n17 = "R" , |
7782 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
7783 | const std::string& n18 = "S" , |
7784 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), |
7785 | const std::string& n19 = "T" , |
7786 | typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19)): |
7787 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19), |
7788 | _pNames(0) |
7789 | { |
7790 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19); |
7791 | } |
7792 | |
7793 | const DynamicAny get(const std::string& name) const |
7794 | { |
7795 | NameVec::const_iterator it = _pNames->begin(); |
7796 | NameVec::const_iterator itEnd = _pNames->end(); |
7797 | |
7798 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
7799 | { |
7800 | if (name == *it) |
7801 | { |
7802 | switch (counter) |
7803 | { |
7804 | case 0: return TupleType::template get<0>(); |
7805 | case 1: return TupleType::template get<1>(); |
7806 | case 2: return TupleType::template get<2>(); |
7807 | case 3: return TupleType::template get<3>(); |
7808 | case 4: return TupleType::template get<4>(); |
7809 | case 5: return TupleType::template get<5>(); |
7810 | case 6: return TupleType::template get<6>(); |
7811 | case 7: return TupleType::template get<7>(); |
7812 | case 8: return TupleType::template get<8>(); |
7813 | case 9: return TupleType::template get<9>(); |
7814 | case 10: return TupleType::template get<10>(); |
7815 | case 11: return TupleType::template get<11>(); |
7816 | case 12: return TupleType::template get<12>(); |
7817 | case 13: return TupleType::template get<13>(); |
7818 | case 14: return TupleType::template get<14>(); |
7819 | case 15: return TupleType::template get<15>(); |
7820 | case 16: return TupleType::template get<16>(); |
7821 | case 17: return TupleType::template get<17>(); |
7822 | case 18: return TupleType::template get<18>(); |
7823 | case 19: return TupleType::template get<19>(); |
7824 | default: throw RangeException(); |
7825 | } |
7826 | } |
7827 | } |
7828 | |
7829 | throw NotFoundException("Name not found: " + name); |
7830 | } |
7831 | |
7832 | const DynamicAny operator [] (const std::string& name) const |
7833 | { |
7834 | return get(name); |
7835 | } |
7836 | |
7837 | template<int N> |
7838 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
7839 | { |
7840 | return TupleType::template get<N>(); |
7841 | } |
7842 | |
7843 | template<int N> |
7844 | typename TypeGetter<N, Type>::HeadType& get() |
7845 | { |
7846 | return TupleType::template get<N>(); |
7847 | } |
7848 | |
7849 | template<int N> |
7850 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
7851 | { |
7852 | return TupleType::template set<N>(val); |
7853 | } |
7854 | |
7855 | const NameVecPtr& names() |
7856 | { |
7857 | return _pNames; |
7858 | } |
7859 | |
7860 | void setName(std::size_t index, const std::string& name) |
7861 | { |
7862 | if (index >= _pNames->size()) |
7863 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
7864 | |
7865 | (*_pNames)[index] = name; |
7866 | } |
7867 | |
7868 | const std::string& getName(std::size_t index) |
7869 | { |
7870 | if (index >= _pNames->size()) |
7871 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
7872 | |
7873 | return (*_pNames)[index]; |
7874 | } |
7875 | |
7876 | bool operator == (const NamedTuple& other) const |
7877 | { |
7878 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
7879 | } |
7880 | |
7881 | bool operator != (const NamedTuple& other) const |
7882 | { |
7883 | return !(*this == other); |
7884 | } |
7885 | |
7886 | bool operator < (const NamedTuple& other) const |
7887 | { |
7888 | TupleType th(*this); |
7889 | TupleType oth(other); |
7890 | |
7891 | return (th < oth && _pNames == other._pNames) || |
7892 | (th == oth && _pNames < other._pNames) || |
7893 | (th < oth && _pNames < other._pNames); |
7894 | } |
7895 | |
7896 | private: |
7897 | void init(const std::string& n0 = "A" , |
7898 | const std::string& n1 = "B" , |
7899 | const std::string& n2 = "C" , |
7900 | const std::string& n3 = "D" , |
7901 | const std::string& n4 = "E" , |
7902 | const std::string& n5 = "F" , |
7903 | const std::string& n6 = "G" , |
7904 | const std::string& n7 = "H" , |
7905 | const std::string& n8 = "I" , |
7906 | const std::string& n9 = "J" , |
7907 | const std::string& n10 = "K" , |
7908 | const std::string& n11 = "L" , |
7909 | const std::string& n12 = "M" , |
7910 | const std::string& n13 = "N" , |
7911 | const std::string& n14 = "O" , |
7912 | const std::string& n15 = "P" , |
7913 | const std::string& n16 = "Q" , |
7914 | const std::string& n17 = "R" , |
7915 | const std::string& n18 = "S" , |
7916 | const std::string& n19 = "T" ) |
7917 | { |
7918 | if (!_pNames) |
7919 | { |
7920 | _pNames = new NameVec; |
7921 | _pNames->push_back(n0); |
7922 | _pNames->push_back(n1); |
7923 | _pNames->push_back(n2); |
7924 | _pNames->push_back(n3); |
7925 | _pNames->push_back(n4); |
7926 | _pNames->push_back(n5); |
7927 | _pNames->push_back(n6); |
7928 | _pNames->push_back(n7); |
7929 | _pNames->push_back(n8); |
7930 | _pNames->push_back(n9); |
7931 | _pNames->push_back(n10); |
7932 | _pNames->push_back(n11); |
7933 | _pNames->push_back(n12); |
7934 | _pNames->push_back(n13); |
7935 | _pNames->push_back(n14); |
7936 | _pNames->push_back(n15); |
7937 | _pNames->push_back(n16); |
7938 | _pNames->push_back(n17); |
7939 | _pNames->push_back(n18); |
7940 | _pNames->push_back(n19); |
7941 | } |
7942 | } |
7943 | |
7944 | NameVecPtr _pNames; |
7945 | }; |
7946 | |
7947 | |
7948 | template<class T0, |
7949 | class T1, |
7950 | class T2, |
7951 | class T3, |
7952 | class T4, |
7953 | class T5, |
7954 | class T6, |
7955 | class T7, |
7956 | class T8, |
7957 | class T9, |
7958 | class T10, |
7959 | class T11, |
7960 | class T12, |
7961 | class T13, |
7962 | class T14, |
7963 | class T15, |
7964 | class T16, |
7965 | class T17, |
7966 | class T18> |
7967 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,NullTypeList>: |
7968 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18> |
7969 | { |
7970 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18> TupleType; |
7971 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>::Type Type; |
7972 | typedef std::vector<std::string> NameVec; |
7973 | typedef SharedPtr<NameVec> NameVecPtr; |
7974 | |
7975 | NamedTuple(): _pNames(0) |
7976 | { |
7977 | init(); |
7978 | } |
7979 | |
7980 | NamedTuple(const NameVecPtr& rNames) |
7981 | { |
7982 | if (rNames->size() != TupleType::length) |
7983 | throw InvalidArgumentException("Wrong names vector length." ); |
7984 | |
7985 | _pNames = rNames; |
7986 | } |
7987 | |
7988 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
7989 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
7990 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
7991 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
7992 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
7993 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
7994 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
7995 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
7996 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
7997 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
7998 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
7999 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
8000 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
8001 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
8002 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
8003 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
8004 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
8005 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
8006 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18)): |
8007 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18), |
8008 | _pNames(0) |
8009 | { |
8010 | init(); |
8011 | } |
8012 | |
8013 | NamedTuple(const NameVecPtr& rNames, |
8014 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
8015 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
8016 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
8017 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
8018 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
8019 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
8020 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
8021 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
8022 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
8023 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
8024 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
8025 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
8026 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
8027 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
8028 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
8029 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
8030 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
8031 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
8032 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18)): |
8033 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18) |
8034 | { |
8035 | if (rNames->size() != TupleType::length) |
8036 | throw InvalidArgumentException("Wrong names vector length." ); |
8037 | |
8038 | _pNames = rNames; |
8039 | } |
8040 | |
8041 | NamedTuple(const std::string& n0, |
8042 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
8043 | const std::string& n1 = "B" , |
8044 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
8045 | const std::string& n2 = "C" , |
8046 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
8047 | const std::string& n3 = "D" , |
8048 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
8049 | const std::string& n4 = "E" , |
8050 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
8051 | const std::string& n5 = "F" , |
8052 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
8053 | const std::string& n6 = "G" , |
8054 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
8055 | const std::string& n7 = "H" , |
8056 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
8057 | const std::string& n8 = "I" , |
8058 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
8059 | const std::string& n9 = "J" , |
8060 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
8061 | const std::string& n10 = "K" , |
8062 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
8063 | const std::string& n11 = "L" , |
8064 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
8065 | const std::string& n12 = "M" , |
8066 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
8067 | const std::string& n13 = "N" , |
8068 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
8069 | const std::string& n14 = "O" , |
8070 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
8071 | const std::string& n15 = "P" , |
8072 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
8073 | const std::string& n16 = "Q" , |
8074 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
8075 | const std::string& n17 = "R" , |
8076 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), |
8077 | const std::string& n18 = "S" , |
8078 | typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18)): |
8079 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18), |
8080 | _pNames(0) |
8081 | { |
8082 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18); |
8083 | } |
8084 | |
8085 | const DynamicAny get(const std::string& name) const |
8086 | { |
8087 | NameVec::const_iterator it = _pNames->begin(); |
8088 | NameVec::const_iterator itEnd = _pNames->end(); |
8089 | |
8090 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
8091 | { |
8092 | if (name == *it) |
8093 | { |
8094 | switch (counter) |
8095 | { |
8096 | case 0: return TupleType::template get<0>(); |
8097 | case 1: return TupleType::template get<1>(); |
8098 | case 2: return TupleType::template get<2>(); |
8099 | case 3: return TupleType::template get<3>(); |
8100 | case 4: return TupleType::template get<4>(); |
8101 | case 5: return TupleType::template get<5>(); |
8102 | case 6: return TupleType::template get<6>(); |
8103 | case 7: return TupleType::template get<7>(); |
8104 | case 8: return TupleType::template get<8>(); |
8105 | case 9: return TupleType::template get<9>(); |
8106 | case 10: return TupleType::template get<10>(); |
8107 | case 11: return TupleType::template get<11>(); |
8108 | case 12: return TupleType::template get<12>(); |
8109 | case 13: return TupleType::template get<13>(); |
8110 | case 14: return TupleType::template get<14>(); |
8111 | case 15: return TupleType::template get<15>(); |
8112 | case 16: return TupleType::template get<16>(); |
8113 | case 17: return TupleType::template get<17>(); |
8114 | case 18: return TupleType::template get<18>(); |
8115 | default: throw RangeException(); |
8116 | } |
8117 | } |
8118 | } |
8119 | |
8120 | throw NotFoundException("Name not found: " + name); |
8121 | } |
8122 | |
8123 | const DynamicAny operator [] (const std::string& name) const |
8124 | { |
8125 | return get(name); |
8126 | } |
8127 | |
8128 | template<int N> |
8129 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
8130 | { |
8131 | return TupleType::template get<N>(); |
8132 | } |
8133 | |
8134 | template<int N> |
8135 | typename TypeGetter<N, Type>::HeadType& get() |
8136 | { |
8137 | return TupleType::template get<N>(); |
8138 | } |
8139 | |
8140 | template<int N> |
8141 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
8142 | { |
8143 | return TupleType::template set<N>(val); |
8144 | } |
8145 | |
8146 | const NameVecPtr& names() |
8147 | { |
8148 | return _pNames; |
8149 | } |
8150 | |
8151 | void setName(std::size_t index, const std::string& name) |
8152 | { |
8153 | if (index >= _pNames->size()) |
8154 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
8155 | |
8156 | (*_pNames)[index] = name; |
8157 | } |
8158 | |
8159 | const std::string& getName(std::size_t index) |
8160 | { |
8161 | if (index >= _pNames->size()) |
8162 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
8163 | |
8164 | return (*_pNames)[index]; |
8165 | } |
8166 | |
8167 | bool operator == (const NamedTuple& other) const |
8168 | { |
8169 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
8170 | } |
8171 | |
8172 | bool operator != (const NamedTuple& other) const |
8173 | { |
8174 | return !(*this == other); |
8175 | } |
8176 | |
8177 | bool operator < (const NamedTuple& other) const |
8178 | { |
8179 | TupleType th(*this); |
8180 | TupleType oth(other); |
8181 | |
8182 | return (th < oth && _pNames == other._pNames) || |
8183 | (th == oth && _pNames < other._pNames) || |
8184 | (th < oth && _pNames < other._pNames); |
8185 | } |
8186 | |
8187 | private: |
8188 | void init(const std::string& n0 = "A" , |
8189 | const std::string& n1 = "B" , |
8190 | const std::string& n2 = "C" , |
8191 | const std::string& n3 = "D" , |
8192 | const std::string& n4 = "E" , |
8193 | const std::string& n5 = "F" , |
8194 | const std::string& n6 = "G" , |
8195 | const std::string& n7 = "H" , |
8196 | const std::string& n8 = "I" , |
8197 | const std::string& n9 = "J" , |
8198 | const std::string& n10 = "K" , |
8199 | const std::string& n11 = "L" , |
8200 | const std::string& n12 = "M" , |
8201 | const std::string& n13 = "N" , |
8202 | const std::string& n14 = "O" , |
8203 | const std::string& n15 = "P" , |
8204 | const std::string& n16 = "Q" , |
8205 | const std::string& n17 = "R" , |
8206 | const std::string& n18 = "S" ) |
8207 | { |
8208 | if (!_pNames) |
8209 | { |
8210 | _pNames = new NameVec; |
8211 | _pNames->push_back(n0); |
8212 | _pNames->push_back(n1); |
8213 | _pNames->push_back(n2); |
8214 | _pNames->push_back(n3); |
8215 | _pNames->push_back(n4); |
8216 | _pNames->push_back(n5); |
8217 | _pNames->push_back(n6); |
8218 | _pNames->push_back(n7); |
8219 | _pNames->push_back(n8); |
8220 | _pNames->push_back(n9); |
8221 | _pNames->push_back(n10); |
8222 | _pNames->push_back(n11); |
8223 | _pNames->push_back(n12); |
8224 | _pNames->push_back(n13); |
8225 | _pNames->push_back(n14); |
8226 | _pNames->push_back(n15); |
8227 | _pNames->push_back(n16); |
8228 | _pNames->push_back(n17); |
8229 | _pNames->push_back(n18); |
8230 | } |
8231 | } |
8232 | |
8233 | NameVecPtr _pNames; |
8234 | }; |
8235 | |
8236 | |
8237 | template<class T0, |
8238 | class T1, |
8239 | class T2, |
8240 | class T3, |
8241 | class T4, |
8242 | class T5, |
8243 | class T6, |
8244 | class T7, |
8245 | class T8, |
8246 | class T9, |
8247 | class T10, |
8248 | class T11, |
8249 | class T12, |
8250 | class T13, |
8251 | class T14, |
8252 | class T15, |
8253 | class T16, |
8254 | class T17> |
8255 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,NullTypeList>: |
8256 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17> |
8257 | { |
8258 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17> TupleType; |
8259 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>::Type Type; |
8260 | typedef std::vector<std::string> NameVec; |
8261 | typedef SharedPtr<NameVec> NameVecPtr; |
8262 | |
8263 | NamedTuple(): _pNames(0) |
8264 | { |
8265 | init(); |
8266 | } |
8267 | |
8268 | NamedTuple(const NameVecPtr& rNames) |
8269 | { |
8270 | if (rNames->size() != TupleType::length) |
8271 | throw InvalidArgumentException("Wrong names vector length." ); |
8272 | |
8273 | _pNames = rNames; |
8274 | } |
8275 | |
8276 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
8277 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
8278 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
8279 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
8280 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
8281 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
8282 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
8283 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
8284 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
8285 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
8286 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
8287 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
8288 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
8289 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
8290 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
8291 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
8292 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
8293 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17)): |
8294 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17), |
8295 | _pNames(0) |
8296 | { |
8297 | init(); |
8298 | } |
8299 | |
8300 | NamedTuple(const NameVecPtr& rNames, |
8301 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
8302 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
8303 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
8304 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
8305 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
8306 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
8307 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
8308 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
8309 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
8310 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
8311 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
8312 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
8313 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
8314 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
8315 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
8316 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
8317 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
8318 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17)): |
8319 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17) |
8320 | { |
8321 | if (rNames->size() != TupleType::length) |
8322 | throw InvalidArgumentException("Wrong names vector length." ); |
8323 | |
8324 | _pNames = rNames; |
8325 | } |
8326 | |
8327 | NamedTuple(const std::string& n0, |
8328 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
8329 | const std::string& n1 = "B" , |
8330 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
8331 | const std::string& n2 = "C" , |
8332 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
8333 | const std::string& n3 = "D" , |
8334 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
8335 | const std::string& n4 = "E" , |
8336 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
8337 | const std::string& n5 = "F" , |
8338 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
8339 | const std::string& n6 = "G" , |
8340 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
8341 | const std::string& n7 = "H" , |
8342 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
8343 | const std::string& n8 = "I" , |
8344 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
8345 | const std::string& n9 = "J" , |
8346 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
8347 | const std::string& n10 = "K" , |
8348 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
8349 | const std::string& n11 = "L" , |
8350 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
8351 | const std::string& n12 = "M" , |
8352 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
8353 | const std::string& n13 = "N" , |
8354 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
8355 | const std::string& n14 = "O" , |
8356 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
8357 | const std::string& n15 = "P" , |
8358 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
8359 | const std::string& n16 = "Q" , |
8360 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), |
8361 | const std::string& n17 = "R" , |
8362 | typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17)): |
8363 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17), |
8364 | _pNames(0) |
8365 | { |
8366 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17); |
8367 | } |
8368 | |
8369 | const DynamicAny get(const std::string& name) const |
8370 | { |
8371 | NameVec::const_iterator it = _pNames->begin(); |
8372 | NameVec::const_iterator itEnd = _pNames->end(); |
8373 | |
8374 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
8375 | { |
8376 | if (name == *it) |
8377 | { |
8378 | switch (counter) |
8379 | { |
8380 | case 0: return TupleType::template get<0>(); |
8381 | case 1: return TupleType::template get<1>(); |
8382 | case 2: return TupleType::template get<2>(); |
8383 | case 3: return TupleType::template get<3>(); |
8384 | case 4: return TupleType::template get<4>(); |
8385 | case 5: return TupleType::template get<5>(); |
8386 | case 6: return TupleType::template get<6>(); |
8387 | case 7: return TupleType::template get<7>(); |
8388 | case 8: return TupleType::template get<8>(); |
8389 | case 9: return TupleType::template get<9>(); |
8390 | case 10: return TupleType::template get<10>(); |
8391 | case 11: return TupleType::template get<11>(); |
8392 | case 12: return TupleType::template get<12>(); |
8393 | case 13: return TupleType::template get<13>(); |
8394 | case 14: return TupleType::template get<14>(); |
8395 | case 15: return TupleType::template get<15>(); |
8396 | case 16: return TupleType::template get<16>(); |
8397 | case 17: return TupleType::template get<17>(); |
8398 | default: throw RangeException(); |
8399 | } |
8400 | } |
8401 | } |
8402 | |
8403 | throw NotFoundException("Name not found: " + name); |
8404 | } |
8405 | |
8406 | const DynamicAny operator [] (const std::string& name) const |
8407 | { |
8408 | return get(name); |
8409 | } |
8410 | |
8411 | template<int N> |
8412 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
8413 | { |
8414 | return TupleType::template get<N>(); |
8415 | } |
8416 | |
8417 | template<int N> |
8418 | typename TypeGetter<N, Type>::HeadType& get() |
8419 | { |
8420 | return TupleType::template get<N>(); |
8421 | } |
8422 | |
8423 | template<int N> |
8424 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
8425 | { |
8426 | return TupleType::template set<N>(val); |
8427 | } |
8428 | |
8429 | const NameVecPtr& names() |
8430 | { |
8431 | return _pNames; |
8432 | } |
8433 | |
8434 | void setName(std::size_t index, const std::string& name) |
8435 | { |
8436 | if (index >= _pNames->size()) |
8437 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
8438 | |
8439 | (*_pNames)[index] = name; |
8440 | } |
8441 | |
8442 | const std::string& getName(std::size_t index) |
8443 | { |
8444 | if (index >= _pNames->size()) |
8445 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
8446 | |
8447 | return (*_pNames)[index]; |
8448 | } |
8449 | |
8450 | bool operator == (const NamedTuple& other) const |
8451 | { |
8452 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
8453 | } |
8454 | |
8455 | bool operator != (const NamedTuple& other) const |
8456 | { |
8457 | return !(*this == other); |
8458 | } |
8459 | |
8460 | bool operator < (const NamedTuple& other) const |
8461 | { |
8462 | TupleType th(*this); |
8463 | TupleType oth(other); |
8464 | |
8465 | return (th < oth && _pNames == other._pNames) || |
8466 | (th == oth && _pNames < other._pNames) || |
8467 | (th < oth && _pNames < other._pNames); |
8468 | } |
8469 | |
8470 | private: |
8471 | void init(const std::string& n0 = "A" , |
8472 | const std::string& n1 = "B" , |
8473 | const std::string& n2 = "C" , |
8474 | const std::string& n3 = "D" , |
8475 | const std::string& n4 = "E" , |
8476 | const std::string& n5 = "F" , |
8477 | const std::string& n6 = "G" , |
8478 | const std::string& n7 = "H" , |
8479 | const std::string& n8 = "I" , |
8480 | const std::string& n9 = "J" , |
8481 | const std::string& n10 = "K" , |
8482 | const std::string& n11 = "L" , |
8483 | const std::string& n12 = "M" , |
8484 | const std::string& n13 = "N" , |
8485 | const std::string& n14 = "O" , |
8486 | const std::string& n15 = "P" , |
8487 | const std::string& n16 = "Q" , |
8488 | const std::string& n17 = "R" ) |
8489 | { |
8490 | if (!_pNames) |
8491 | { |
8492 | _pNames = new NameVec; |
8493 | _pNames->push_back(n0); |
8494 | _pNames->push_back(n1); |
8495 | _pNames->push_back(n2); |
8496 | _pNames->push_back(n3); |
8497 | _pNames->push_back(n4); |
8498 | _pNames->push_back(n5); |
8499 | _pNames->push_back(n6); |
8500 | _pNames->push_back(n7); |
8501 | _pNames->push_back(n8); |
8502 | _pNames->push_back(n9); |
8503 | _pNames->push_back(n10); |
8504 | _pNames->push_back(n11); |
8505 | _pNames->push_back(n12); |
8506 | _pNames->push_back(n13); |
8507 | _pNames->push_back(n14); |
8508 | _pNames->push_back(n15); |
8509 | _pNames->push_back(n16); |
8510 | _pNames->push_back(n17); |
8511 | } |
8512 | } |
8513 | |
8514 | NameVecPtr _pNames; |
8515 | }; |
8516 | |
8517 | |
8518 | template<class T0, |
8519 | class T1, |
8520 | class T2, |
8521 | class T3, |
8522 | class T4, |
8523 | class T5, |
8524 | class T6, |
8525 | class T7, |
8526 | class T8, |
8527 | class T9, |
8528 | class T10, |
8529 | class T11, |
8530 | class T12, |
8531 | class T13, |
8532 | class T14, |
8533 | class T15, |
8534 | class T16> |
8535 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,NullTypeList>: |
8536 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16> |
8537 | { |
8538 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16> TupleType; |
8539 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>::Type Type; |
8540 | typedef std::vector<std::string> NameVec; |
8541 | typedef SharedPtr<NameVec> NameVecPtr; |
8542 | |
8543 | NamedTuple(): _pNames(0) |
8544 | { |
8545 | init(); |
8546 | } |
8547 | |
8548 | NamedTuple(const NameVecPtr& rNames) |
8549 | { |
8550 | if (rNames->size() != TupleType::length) |
8551 | throw InvalidArgumentException("Wrong names vector length." ); |
8552 | |
8553 | _pNames = rNames; |
8554 | } |
8555 | |
8556 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
8557 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
8558 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
8559 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
8560 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
8561 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
8562 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
8563 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
8564 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
8565 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
8566 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
8567 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
8568 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
8569 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
8570 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
8571 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
8572 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16)): |
8573 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16), |
8574 | _pNames(0) |
8575 | { |
8576 | init(); |
8577 | } |
8578 | |
8579 | NamedTuple(const NameVecPtr& rNames, |
8580 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
8581 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
8582 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
8583 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
8584 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
8585 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
8586 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
8587 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
8588 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
8589 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
8590 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
8591 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
8592 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
8593 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
8594 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
8595 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
8596 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16)): |
8597 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16) |
8598 | { |
8599 | if (rNames->size() != TupleType::length) |
8600 | throw InvalidArgumentException("Wrong names vector length." ); |
8601 | |
8602 | _pNames = rNames; |
8603 | } |
8604 | |
8605 | NamedTuple(const std::string& n0, |
8606 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
8607 | const std::string& n1 = "B" , |
8608 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
8609 | const std::string& n2 = "C" , |
8610 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
8611 | const std::string& n3 = "D" , |
8612 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
8613 | const std::string& n4 = "E" , |
8614 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
8615 | const std::string& n5 = "F" , |
8616 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
8617 | const std::string& n6 = "G" , |
8618 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
8619 | const std::string& n7 = "H" , |
8620 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
8621 | const std::string& n8 = "I" , |
8622 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
8623 | const std::string& n9 = "J" , |
8624 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
8625 | const std::string& n10 = "K" , |
8626 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
8627 | const std::string& n11 = "L" , |
8628 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
8629 | const std::string& n12 = "M" , |
8630 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
8631 | const std::string& n13 = "N" , |
8632 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
8633 | const std::string& n14 = "O" , |
8634 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
8635 | const std::string& n15 = "P" , |
8636 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), |
8637 | const std::string& n16 = "Q" , |
8638 | typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16)): |
8639 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16), |
8640 | _pNames(0) |
8641 | { |
8642 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16); |
8643 | } |
8644 | |
8645 | const DynamicAny get(const std::string& name) const |
8646 | { |
8647 | NameVec::const_iterator it = _pNames->begin(); |
8648 | NameVec::const_iterator itEnd = _pNames->end(); |
8649 | |
8650 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
8651 | { |
8652 | if (name == *it) |
8653 | { |
8654 | switch (counter) |
8655 | { |
8656 | case 0: return TupleType::template get<0>(); |
8657 | case 1: return TupleType::template get<1>(); |
8658 | case 2: return TupleType::template get<2>(); |
8659 | case 3: return TupleType::template get<3>(); |
8660 | case 4: return TupleType::template get<4>(); |
8661 | case 5: return TupleType::template get<5>(); |
8662 | case 6: return TupleType::template get<6>(); |
8663 | case 7: return TupleType::template get<7>(); |
8664 | case 8: return TupleType::template get<8>(); |
8665 | case 9: return TupleType::template get<9>(); |
8666 | case 10: return TupleType::template get<10>(); |
8667 | case 11: return TupleType::template get<11>(); |
8668 | case 12: return TupleType::template get<12>(); |
8669 | case 13: return TupleType::template get<13>(); |
8670 | case 14: return TupleType::template get<14>(); |
8671 | case 15: return TupleType::template get<15>(); |
8672 | case 16: return TupleType::template get<16>(); |
8673 | default: throw RangeException(); |
8674 | } |
8675 | } |
8676 | } |
8677 | |
8678 | throw NotFoundException("Name not found: " + name); |
8679 | } |
8680 | |
8681 | const DynamicAny operator [] (const std::string& name) const |
8682 | { |
8683 | return get(name); |
8684 | } |
8685 | |
8686 | template<int N> |
8687 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
8688 | { |
8689 | return TupleType::template get<N>(); |
8690 | } |
8691 | |
8692 | template<int N> |
8693 | typename TypeGetter<N, Type>::HeadType& get() |
8694 | { |
8695 | return TupleType::template get<N>(); |
8696 | } |
8697 | |
8698 | template<int N> |
8699 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
8700 | { |
8701 | return TupleType::template set<N>(val); |
8702 | } |
8703 | |
8704 | const NameVecPtr& names() |
8705 | { |
8706 | return _pNames; |
8707 | } |
8708 | |
8709 | void setName(std::size_t index, const std::string& name) |
8710 | { |
8711 | if (index >= _pNames->size()) |
8712 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
8713 | |
8714 | (*_pNames)[index] = name; |
8715 | } |
8716 | |
8717 | const std::string& getName(std::size_t index) |
8718 | { |
8719 | if (index >= _pNames->size()) |
8720 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
8721 | |
8722 | return (*_pNames)[index]; |
8723 | } |
8724 | |
8725 | bool operator == (const NamedTuple& other) const |
8726 | { |
8727 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
8728 | } |
8729 | |
8730 | bool operator != (const NamedTuple& other) const |
8731 | { |
8732 | return !(*this == other); |
8733 | } |
8734 | |
8735 | bool operator < (const NamedTuple& other) const |
8736 | { |
8737 | TupleType th(*this); |
8738 | TupleType oth(other); |
8739 | |
8740 | return (th < oth && _pNames == other._pNames) || |
8741 | (th == oth && _pNames < other._pNames) || |
8742 | (th < oth && _pNames < other._pNames); |
8743 | } |
8744 | |
8745 | private: |
8746 | void init(const std::string& n0 = "A" , |
8747 | const std::string& n1 = "B" , |
8748 | const std::string& n2 = "C" , |
8749 | const std::string& n3 = "D" , |
8750 | const std::string& n4 = "E" , |
8751 | const std::string& n5 = "F" , |
8752 | const std::string& n6 = "G" , |
8753 | const std::string& n7 = "H" , |
8754 | const std::string& n8 = "I" , |
8755 | const std::string& n9 = "J" , |
8756 | const std::string& n10 = "K" , |
8757 | const std::string& n11 = "L" , |
8758 | const std::string& n12 = "M" , |
8759 | const std::string& n13 = "N" , |
8760 | const std::string& n14 = "O" , |
8761 | const std::string& n15 = "P" , |
8762 | const std::string& n16 = "Q" ) |
8763 | { |
8764 | if (!_pNames) |
8765 | { |
8766 | _pNames = new NameVec; |
8767 | _pNames->push_back(n0); |
8768 | _pNames->push_back(n1); |
8769 | _pNames->push_back(n2); |
8770 | _pNames->push_back(n3); |
8771 | _pNames->push_back(n4); |
8772 | _pNames->push_back(n5); |
8773 | _pNames->push_back(n6); |
8774 | _pNames->push_back(n7); |
8775 | _pNames->push_back(n8); |
8776 | _pNames->push_back(n9); |
8777 | _pNames->push_back(n10); |
8778 | _pNames->push_back(n11); |
8779 | _pNames->push_back(n12); |
8780 | _pNames->push_back(n13); |
8781 | _pNames->push_back(n14); |
8782 | _pNames->push_back(n15); |
8783 | _pNames->push_back(n16); |
8784 | } |
8785 | } |
8786 | |
8787 | NameVecPtr _pNames; |
8788 | }; |
8789 | |
8790 | |
8791 | template<class T0, |
8792 | class T1, |
8793 | class T2, |
8794 | class T3, |
8795 | class T4, |
8796 | class T5, |
8797 | class T6, |
8798 | class T7, |
8799 | class T8, |
8800 | class T9, |
8801 | class T10, |
8802 | class T11, |
8803 | class T12, |
8804 | class T13, |
8805 | class T14, |
8806 | class T15> |
8807 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,NullTypeList>: |
8808 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15> |
8809 | { |
8810 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15> TupleType; |
8811 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>::Type Type; |
8812 | |
8813 | typedef std::vector<std::string> NameVec; |
8814 | typedef SharedPtr<NameVec> NameVecPtr; |
8815 | |
8816 | NamedTuple(): _pNames(0) |
8817 | { |
8818 | init(); |
8819 | } |
8820 | |
8821 | NamedTuple(const NameVecPtr& rNames) |
8822 | { |
8823 | if (rNames->size() != TupleType::length) |
8824 | throw InvalidArgumentException("Wrong names vector length." ); |
8825 | |
8826 | _pNames = rNames; |
8827 | } |
8828 | |
8829 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
8830 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
8831 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
8832 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
8833 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
8834 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
8835 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
8836 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
8837 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
8838 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
8839 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
8840 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
8841 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
8842 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
8843 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
8844 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15)): |
8845 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15), |
8846 | _pNames(0) |
8847 | { |
8848 | init(); |
8849 | } |
8850 | |
8851 | NamedTuple(const NameVecPtr& rNames, |
8852 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
8853 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
8854 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
8855 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
8856 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
8857 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
8858 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
8859 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
8860 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
8861 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
8862 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
8863 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
8864 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
8865 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
8866 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
8867 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15)): |
8868 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15) |
8869 | { |
8870 | if (rNames->size() != TupleType::length) |
8871 | throw InvalidArgumentException("Wrong names vector length." ); |
8872 | |
8873 | _pNames = rNames; |
8874 | } |
8875 | |
8876 | NamedTuple(const std::string& n0, |
8877 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
8878 | const std::string& n1 = "B" , |
8879 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
8880 | const std::string& n2 = "C" , |
8881 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
8882 | const std::string& n3 = "D" , |
8883 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
8884 | const std::string& n4 = "E" , |
8885 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
8886 | const std::string& n5 = "F" , |
8887 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
8888 | const std::string& n6 = "G" , |
8889 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
8890 | const std::string& n7 = "H" , |
8891 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
8892 | const std::string& n8 = "I" , |
8893 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
8894 | const std::string& n9 = "J" , |
8895 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
8896 | const std::string& n10 = "K" , |
8897 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
8898 | const std::string& n11 = "L" , |
8899 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
8900 | const std::string& n12 = "M" , |
8901 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
8902 | const std::string& n13 = "N" , |
8903 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
8904 | const std::string& n14 = "O" , |
8905 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), |
8906 | const std::string& n15 = "P" , |
8907 | typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15)): |
8908 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15), |
8909 | _pNames(0) |
8910 | { |
8911 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15); |
8912 | } |
8913 | |
8914 | const DynamicAny get(const std::string& name) const |
8915 | { |
8916 | NameVec::const_iterator it = _pNames->begin(); |
8917 | NameVec::const_iterator itEnd = _pNames->end(); |
8918 | |
8919 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
8920 | { |
8921 | if (name == *it) |
8922 | { |
8923 | switch (counter) |
8924 | { |
8925 | case 0: return TupleType::template get<0>(); |
8926 | case 1: return TupleType::template get<1>(); |
8927 | case 2: return TupleType::template get<2>(); |
8928 | case 3: return TupleType::template get<3>(); |
8929 | case 4: return TupleType::template get<4>(); |
8930 | case 5: return TupleType::template get<5>(); |
8931 | case 6: return TupleType::template get<6>(); |
8932 | case 7: return TupleType::template get<7>(); |
8933 | case 8: return TupleType::template get<8>(); |
8934 | case 9: return TupleType::template get<9>(); |
8935 | case 10: return TupleType::template get<10>(); |
8936 | case 11: return TupleType::template get<11>(); |
8937 | case 12: return TupleType::template get<12>(); |
8938 | case 13: return TupleType::template get<13>(); |
8939 | case 14: return TupleType::template get<14>(); |
8940 | case 15: return TupleType::template get<15>(); |
8941 | default: throw RangeException(); |
8942 | } |
8943 | } |
8944 | } |
8945 | |
8946 | throw NotFoundException("Name not found: " + name); |
8947 | } |
8948 | |
8949 | const DynamicAny operator [] (const std::string& name) const |
8950 | { |
8951 | return get(name); |
8952 | } |
8953 | |
8954 | template<int N> |
8955 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
8956 | { |
8957 | return TupleType::template get<N>(); |
8958 | } |
8959 | |
8960 | template<int N> |
8961 | typename TypeGetter<N, Type>::HeadType& get() |
8962 | { |
8963 | return TupleType::template get<N>(); |
8964 | } |
8965 | |
8966 | template<int N> |
8967 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
8968 | { |
8969 | return TupleType::template set<N>(val); |
8970 | } |
8971 | |
8972 | const NameVecPtr& names() |
8973 | { |
8974 | return _pNames; |
8975 | } |
8976 | |
8977 | void setName(std::size_t index, const std::string& name) |
8978 | { |
8979 | if (index >= _pNames->size()) |
8980 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
8981 | |
8982 | (*_pNames)[index] = name; |
8983 | } |
8984 | |
8985 | const std::string& getName(std::size_t index) |
8986 | { |
8987 | if (index >= _pNames->size()) |
8988 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
8989 | |
8990 | return (*_pNames)[index]; |
8991 | } |
8992 | |
8993 | bool operator == (const NamedTuple& other) const |
8994 | { |
8995 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
8996 | } |
8997 | |
8998 | bool operator != (const NamedTuple& other) const |
8999 | { |
9000 | return !(*this == other); |
9001 | } |
9002 | |
9003 | bool operator < (const NamedTuple& other) const |
9004 | { |
9005 | TupleType th(*this); |
9006 | TupleType oth(other); |
9007 | |
9008 | return (th < oth && _pNames == other._pNames) || |
9009 | (th == oth && _pNames < other._pNames) || |
9010 | (th < oth && _pNames < other._pNames); |
9011 | } |
9012 | |
9013 | private: |
9014 | void init(const std::string& n0 = "A" , |
9015 | const std::string& n1 = "B" , |
9016 | const std::string& n2 = "C" , |
9017 | const std::string& n3 = "D" , |
9018 | const std::string& n4 = "E" , |
9019 | const std::string& n5 = "F" , |
9020 | const std::string& n6 = "G" , |
9021 | const std::string& n7 = "H" , |
9022 | const std::string& n8 = "I" , |
9023 | const std::string& n9 = "J" , |
9024 | const std::string& n10 = "K" , |
9025 | const std::string& n11 = "L" , |
9026 | const std::string& n12 = "M" , |
9027 | const std::string& n13 = "N" , |
9028 | const std::string& n14 = "O" , |
9029 | const std::string& n15 = "P" ) |
9030 | { |
9031 | if (!_pNames) |
9032 | { |
9033 | _pNames = new NameVec; |
9034 | _pNames->push_back(n0); |
9035 | _pNames->push_back(n1); |
9036 | _pNames->push_back(n2); |
9037 | _pNames->push_back(n3); |
9038 | _pNames->push_back(n4); |
9039 | _pNames->push_back(n5); |
9040 | _pNames->push_back(n6); |
9041 | _pNames->push_back(n7); |
9042 | _pNames->push_back(n8); |
9043 | _pNames->push_back(n9); |
9044 | _pNames->push_back(n10); |
9045 | _pNames->push_back(n11); |
9046 | _pNames->push_back(n12); |
9047 | _pNames->push_back(n13); |
9048 | _pNames->push_back(n14); |
9049 | _pNames->push_back(n15); |
9050 | } |
9051 | } |
9052 | |
9053 | NameVecPtr _pNames; |
9054 | }; |
9055 | |
9056 | |
9057 | template<class T0, |
9058 | class T1, |
9059 | class T2, |
9060 | class T3, |
9061 | class T4, |
9062 | class T5, |
9063 | class T6, |
9064 | class T7, |
9065 | class T8, |
9066 | class T9, |
9067 | class T10, |
9068 | class T11, |
9069 | class T12, |
9070 | class T13, |
9071 | class T14> |
9072 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,NullTypeList>: |
9073 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14> |
9074 | { |
9075 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14> TupleType; |
9076 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>::Type Type; |
9077 | |
9078 | typedef std::vector<std::string> NameVec; |
9079 | typedef SharedPtr<NameVec> NameVecPtr; |
9080 | |
9081 | NamedTuple(): _pNames(0) |
9082 | { |
9083 | init(); |
9084 | } |
9085 | |
9086 | NamedTuple(const NameVecPtr& rNames) |
9087 | { |
9088 | if (rNames->size() != TupleType::length) |
9089 | throw InvalidArgumentException("Wrong names vector length." ); |
9090 | |
9091 | _pNames = rNames; |
9092 | } |
9093 | |
9094 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
9095 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
9096 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
9097 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
9098 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
9099 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
9100 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
9101 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
9102 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
9103 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
9104 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
9105 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
9106 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
9107 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
9108 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14)): |
9109 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14), |
9110 | _pNames(0) |
9111 | { |
9112 | init(); |
9113 | } |
9114 | |
9115 | NamedTuple(const NameVecPtr& rNames, |
9116 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
9117 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
9118 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
9119 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
9120 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
9121 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
9122 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
9123 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
9124 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
9125 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
9126 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
9127 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
9128 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
9129 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
9130 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14)): |
9131 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14) |
9132 | { |
9133 | if (rNames->size() != TupleType::length) |
9134 | throw InvalidArgumentException("Wrong names vector length." ); |
9135 | |
9136 | _pNames = rNames; |
9137 | } |
9138 | |
9139 | NamedTuple(const std::string& n0, |
9140 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
9141 | const std::string& n1 = "B" , |
9142 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
9143 | const std::string& n2 = "C" , |
9144 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
9145 | const std::string& n3 = "D" , |
9146 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
9147 | const std::string& n4 = "E" , |
9148 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
9149 | const std::string& n5 = "F" , |
9150 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
9151 | const std::string& n6 = "G" , |
9152 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
9153 | const std::string& n7 = "H" , |
9154 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
9155 | const std::string& n8 = "I" , |
9156 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
9157 | const std::string& n9 = "J" , |
9158 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
9159 | const std::string& n10 = "K" , |
9160 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
9161 | const std::string& n11 = "L" , |
9162 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
9163 | const std::string& n12 = "M" , |
9164 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
9165 | const std::string& n13 = "N" , |
9166 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), |
9167 | const std::string& n14 = "O" , |
9168 | typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14)): |
9169 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14), |
9170 | _pNames(0) |
9171 | { |
9172 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14); |
9173 | } |
9174 | |
9175 | const DynamicAny get(const std::string& name) const |
9176 | { |
9177 | NameVec::const_iterator it = _pNames->begin(); |
9178 | NameVec::const_iterator itEnd = _pNames->end(); |
9179 | |
9180 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
9181 | { |
9182 | if (name == *it) |
9183 | { |
9184 | switch (counter) |
9185 | { |
9186 | case 0: return TupleType::template get<0>(); |
9187 | case 1: return TupleType::template get<1>(); |
9188 | case 2: return TupleType::template get<2>(); |
9189 | case 3: return TupleType::template get<3>(); |
9190 | case 4: return TupleType::template get<4>(); |
9191 | case 5: return TupleType::template get<5>(); |
9192 | case 6: return TupleType::template get<6>(); |
9193 | case 7: return TupleType::template get<7>(); |
9194 | case 8: return TupleType::template get<8>(); |
9195 | case 9: return TupleType::template get<9>(); |
9196 | case 10: return TupleType::template get<10>(); |
9197 | case 11: return TupleType::template get<11>(); |
9198 | case 12: return TupleType::template get<12>(); |
9199 | case 13: return TupleType::template get<13>(); |
9200 | case 14: return TupleType::template get<14>(); |
9201 | default: throw RangeException(); |
9202 | } |
9203 | } |
9204 | } |
9205 | |
9206 | throw NotFoundException("Name not found: " + name); |
9207 | } |
9208 | |
9209 | const DynamicAny operator [] (const std::string& name) const |
9210 | { |
9211 | return get(name); |
9212 | } |
9213 | |
9214 | template<int N> |
9215 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
9216 | { |
9217 | return TupleType::template get<N>(); |
9218 | } |
9219 | |
9220 | template<int N> |
9221 | typename TypeGetter<N, Type>::HeadType& get() |
9222 | { |
9223 | return TupleType::template get<N>(); |
9224 | } |
9225 | |
9226 | template<int N> |
9227 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
9228 | { |
9229 | return TupleType::template set<N>(val); |
9230 | } |
9231 | |
9232 | const NameVecPtr& names() |
9233 | { |
9234 | return _pNames; |
9235 | } |
9236 | |
9237 | void setName(std::size_t index, const std::string& name) |
9238 | { |
9239 | if (index >= _pNames->size()) |
9240 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
9241 | |
9242 | (*_pNames)[index] = name; |
9243 | } |
9244 | |
9245 | const std::string& getName(std::size_t index) |
9246 | { |
9247 | if (index >= _pNames->size()) |
9248 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
9249 | |
9250 | return (*_pNames)[index]; |
9251 | } |
9252 | |
9253 | bool operator == (const NamedTuple& other) const |
9254 | { |
9255 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
9256 | } |
9257 | |
9258 | bool operator != (const NamedTuple& other) const |
9259 | { |
9260 | return !(*this == other); |
9261 | } |
9262 | |
9263 | bool operator < (const NamedTuple& other) const |
9264 | { |
9265 | TupleType th(*this); |
9266 | TupleType oth(other); |
9267 | |
9268 | return (th < oth && _pNames == other._pNames) || |
9269 | (th == oth && _pNames < other._pNames) || |
9270 | (th < oth && _pNames < other._pNames); |
9271 | } |
9272 | |
9273 | private: |
9274 | void init(const std::string& n0 = "A" , |
9275 | const std::string& n1 = "B" , |
9276 | const std::string& n2 = "C" , |
9277 | const std::string& n3 = "D" , |
9278 | const std::string& n4 = "E" , |
9279 | const std::string& n5 = "F" , |
9280 | const std::string& n6 = "G" , |
9281 | const std::string& n7 = "H" , |
9282 | const std::string& n8 = "I" , |
9283 | const std::string& n9 = "J" , |
9284 | const std::string& n10 = "K" , |
9285 | const std::string& n11 = "L" , |
9286 | const std::string& n12 = "M" , |
9287 | const std::string& n13 = "N" , |
9288 | const std::string& n14 = "O" ) |
9289 | { |
9290 | if (!_pNames) |
9291 | { |
9292 | _pNames = new NameVec; |
9293 | _pNames->push_back(n0); |
9294 | _pNames->push_back(n1); |
9295 | _pNames->push_back(n2); |
9296 | _pNames->push_back(n3); |
9297 | _pNames->push_back(n4); |
9298 | _pNames->push_back(n5); |
9299 | _pNames->push_back(n6); |
9300 | _pNames->push_back(n7); |
9301 | _pNames->push_back(n8); |
9302 | _pNames->push_back(n9); |
9303 | _pNames->push_back(n10); |
9304 | _pNames->push_back(n11); |
9305 | _pNames->push_back(n12); |
9306 | _pNames->push_back(n13); |
9307 | _pNames->push_back(n14); |
9308 | } |
9309 | } |
9310 | |
9311 | NameVecPtr _pNames; |
9312 | }; |
9313 | |
9314 | |
9315 | template<class T0, |
9316 | class T1, |
9317 | class T2, |
9318 | class T3, |
9319 | class T4, |
9320 | class T5, |
9321 | class T6, |
9322 | class T7, |
9323 | class T8, |
9324 | class T9, |
9325 | class T10, |
9326 | class T11, |
9327 | class T12, |
9328 | class T13> |
9329 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,NullTypeList>: |
9330 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13> |
9331 | { |
9332 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13> TupleType; |
9333 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>::Type Type; |
9334 | |
9335 | typedef std::vector<std::string> NameVec; |
9336 | typedef SharedPtr<NameVec> NameVecPtr; |
9337 | |
9338 | NamedTuple(): _pNames(0) |
9339 | { |
9340 | init(); |
9341 | } |
9342 | |
9343 | NamedTuple(const NameVecPtr& rNames) |
9344 | { |
9345 | if (rNames->size() != TupleType::length) |
9346 | throw InvalidArgumentException("Wrong names vector length." ); |
9347 | |
9348 | _pNames = rNames; |
9349 | } |
9350 | |
9351 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
9352 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
9353 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
9354 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
9355 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
9356 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
9357 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
9358 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
9359 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
9360 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
9361 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
9362 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
9363 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
9364 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13)): |
9365 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13), |
9366 | _pNames(0) |
9367 | { |
9368 | init(); |
9369 | } |
9370 | |
9371 | NamedTuple(const NameVecPtr& rNames, |
9372 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
9373 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
9374 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
9375 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
9376 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
9377 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
9378 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
9379 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
9380 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
9381 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
9382 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
9383 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
9384 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
9385 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13)): |
9386 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13) |
9387 | { |
9388 | if (rNames->size() != TupleType::length) |
9389 | throw InvalidArgumentException("Wrong names vector length." ); |
9390 | |
9391 | _pNames = rNames; |
9392 | } |
9393 | |
9394 | NamedTuple(const std::string& n0, |
9395 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
9396 | const std::string& n1 = "B" , |
9397 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
9398 | const std::string& n2 = "C" , |
9399 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
9400 | const std::string& n3 = "D" , |
9401 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
9402 | const std::string& n4 = "E" , |
9403 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
9404 | const std::string& n5 = "F" , |
9405 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
9406 | const std::string& n6 = "G" , |
9407 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
9408 | const std::string& n7 = "H" , |
9409 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
9410 | const std::string& n8 = "I" , |
9411 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
9412 | const std::string& n9 = "J" , |
9413 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
9414 | const std::string& n10 = "K" , |
9415 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
9416 | const std::string& n11 = "L" , |
9417 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
9418 | const std::string& n12 = "M" , |
9419 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), |
9420 | const std::string& n13 = "N" , |
9421 | typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13)): |
9422 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13), |
9423 | _pNames(0) |
9424 | { |
9425 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13); |
9426 | } |
9427 | |
9428 | const DynamicAny get(const std::string& name) const |
9429 | { |
9430 | NameVec::const_iterator it = _pNames->begin(); |
9431 | NameVec::const_iterator itEnd = _pNames->end(); |
9432 | |
9433 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
9434 | { |
9435 | if (name == *it) |
9436 | { |
9437 | switch (counter) |
9438 | { |
9439 | case 0: return TupleType::template get<0>(); |
9440 | case 1: return TupleType::template get<1>(); |
9441 | case 2: return TupleType::template get<2>(); |
9442 | case 3: return TupleType::template get<3>(); |
9443 | case 4: return TupleType::template get<4>(); |
9444 | case 5: return TupleType::template get<5>(); |
9445 | case 6: return TupleType::template get<6>(); |
9446 | case 7: return TupleType::template get<7>(); |
9447 | case 8: return TupleType::template get<8>(); |
9448 | case 9: return TupleType::template get<9>(); |
9449 | case 10: return TupleType::template get<10>(); |
9450 | case 11: return TupleType::template get<11>(); |
9451 | case 12: return TupleType::template get<12>(); |
9452 | case 13: return TupleType::template get<13>(); |
9453 | default: throw RangeException(); |
9454 | } |
9455 | } |
9456 | } |
9457 | |
9458 | throw NotFoundException("Name not found: " + name); |
9459 | } |
9460 | |
9461 | const DynamicAny operator [] (const std::string& name) const |
9462 | { |
9463 | return get(name); |
9464 | } |
9465 | |
9466 | template<int N> |
9467 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
9468 | { |
9469 | return TupleType::template get<N>(); |
9470 | } |
9471 | |
9472 | template<int N> |
9473 | typename TypeGetter<N, Type>::HeadType& get() |
9474 | { |
9475 | return TupleType::template get<N>(); |
9476 | } |
9477 | |
9478 | template<int N> |
9479 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
9480 | { |
9481 | return TupleType::template set<N>(val); |
9482 | } |
9483 | |
9484 | const NameVecPtr& names() |
9485 | { |
9486 | return _pNames; |
9487 | } |
9488 | |
9489 | void setName(std::size_t index, const std::string& name) |
9490 | { |
9491 | if (index >= _pNames->size()) |
9492 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
9493 | |
9494 | (*_pNames)[index] = name; |
9495 | } |
9496 | |
9497 | const std::string& getName(std::size_t index) |
9498 | { |
9499 | if (index >= _pNames->size()) |
9500 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
9501 | |
9502 | return (*_pNames)[index]; |
9503 | } |
9504 | |
9505 | bool operator == (const NamedTuple& other) const |
9506 | { |
9507 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
9508 | } |
9509 | |
9510 | bool operator != (const NamedTuple& other) const |
9511 | { |
9512 | return !(*this == other); |
9513 | } |
9514 | |
9515 | bool operator < (const NamedTuple& other) const |
9516 | { |
9517 | TupleType th(*this); |
9518 | TupleType oth(other); |
9519 | |
9520 | return (th < oth && _pNames == other._pNames) || |
9521 | (th == oth && _pNames < other._pNames) || |
9522 | (th < oth && _pNames < other._pNames); |
9523 | } |
9524 | |
9525 | private: |
9526 | void init(const std::string& n0 = "A" , |
9527 | const std::string& n1 = "B" , |
9528 | const std::string& n2 = "C" , |
9529 | const std::string& n3 = "D" , |
9530 | const std::string& n4 = "E" , |
9531 | const std::string& n5 = "F" , |
9532 | const std::string& n6 = "G" , |
9533 | const std::string& n7 = "H" , |
9534 | const std::string& n8 = "I" , |
9535 | const std::string& n9 = "J" , |
9536 | const std::string& n10 = "K" , |
9537 | const std::string& n11 = "L" , |
9538 | const std::string& n12 = "M" , |
9539 | const std::string& n13 = "N" ) |
9540 | { |
9541 | if (!_pNames) |
9542 | { |
9543 | _pNames = new NameVec; |
9544 | _pNames->push_back(n0); |
9545 | _pNames->push_back(n1); |
9546 | _pNames->push_back(n2); |
9547 | _pNames->push_back(n3); |
9548 | _pNames->push_back(n4); |
9549 | _pNames->push_back(n5); |
9550 | _pNames->push_back(n6); |
9551 | _pNames->push_back(n7); |
9552 | _pNames->push_back(n8); |
9553 | _pNames->push_back(n9); |
9554 | _pNames->push_back(n10); |
9555 | _pNames->push_back(n11); |
9556 | _pNames->push_back(n12); |
9557 | _pNames->push_back(n13); |
9558 | } |
9559 | } |
9560 | |
9561 | NameVecPtr _pNames; |
9562 | }; |
9563 | |
9564 | |
9565 | template<class T0, |
9566 | class T1, |
9567 | class T2, |
9568 | class T3, |
9569 | class T4, |
9570 | class T5, |
9571 | class T6, |
9572 | class T7, |
9573 | class T8, |
9574 | class T9, |
9575 | class T10, |
9576 | class T11, |
9577 | class T12> |
9578 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,NullTypeList>: |
9579 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> |
9580 | { |
9581 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> TupleType; |
9582 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>::Type Type; |
9583 | |
9584 | typedef std::vector<std::string> NameVec; |
9585 | typedef SharedPtr<NameVec> NameVecPtr; |
9586 | |
9587 | NamedTuple(): _pNames(0) |
9588 | { |
9589 | init(); |
9590 | } |
9591 | |
9592 | NamedTuple(const NameVecPtr& rNames) |
9593 | { |
9594 | if (rNames->size() != TupleType::length) |
9595 | throw InvalidArgumentException("Wrong names vector length." ); |
9596 | |
9597 | _pNames = rNames; |
9598 | } |
9599 | |
9600 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
9601 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
9602 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
9603 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
9604 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
9605 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
9606 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
9607 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
9608 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
9609 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
9610 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
9611 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
9612 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12)): |
9613 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12), |
9614 | _pNames(0) |
9615 | { |
9616 | init(); |
9617 | } |
9618 | |
9619 | NamedTuple(const NameVecPtr& rNames, |
9620 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
9621 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
9622 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
9623 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
9624 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
9625 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
9626 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
9627 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
9628 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
9629 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
9630 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
9631 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
9632 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12)): |
9633 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12) |
9634 | { |
9635 | if (rNames->size() != TupleType::length) |
9636 | throw InvalidArgumentException("Wrong names vector length." ); |
9637 | |
9638 | _pNames = rNames; |
9639 | } |
9640 | |
9641 | NamedTuple(const std::string& n0, |
9642 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
9643 | const std::string& n1 = "B" , |
9644 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
9645 | const std::string& n2 = "C" , |
9646 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
9647 | const std::string& n3 = "D" , |
9648 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
9649 | const std::string& n4 = "E" , |
9650 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
9651 | const std::string& n5 = "F" , |
9652 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
9653 | const std::string& n6 = "G" , |
9654 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
9655 | const std::string& n7 = "H" , |
9656 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
9657 | const std::string& n8 = "I" , |
9658 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
9659 | const std::string& n9 = "J" , |
9660 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
9661 | const std::string& n10 = "K" , |
9662 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
9663 | const std::string& n11 = "L" , |
9664 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), |
9665 | const std::string& n12 = "M" , |
9666 | typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12)): |
9667 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12), _pNames(0) |
9668 | { |
9669 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12); |
9670 | } |
9671 | |
9672 | const DynamicAny get(const std::string& name) const |
9673 | { |
9674 | NameVec::const_iterator it = _pNames->begin(); |
9675 | NameVec::const_iterator itEnd = _pNames->end(); |
9676 | |
9677 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
9678 | { |
9679 | if (name == *it) |
9680 | { |
9681 | switch (counter) |
9682 | { |
9683 | case 0: return TupleType::template get<0>(); |
9684 | case 1: return TupleType::template get<1>(); |
9685 | case 2: return TupleType::template get<2>(); |
9686 | case 3: return TupleType::template get<3>(); |
9687 | case 4: return TupleType::template get<4>(); |
9688 | case 5: return TupleType::template get<5>(); |
9689 | case 6: return TupleType::template get<6>(); |
9690 | case 7: return TupleType::template get<7>(); |
9691 | case 8: return TupleType::template get<8>(); |
9692 | case 9: return TupleType::template get<9>(); |
9693 | case 10: return TupleType::template get<10>(); |
9694 | case 11: return TupleType::template get<11>(); |
9695 | case 12: return TupleType::template get<12>(); |
9696 | default: throw RangeException(); |
9697 | } |
9698 | } |
9699 | } |
9700 | |
9701 | throw NotFoundException("Name not found: " + name); |
9702 | } |
9703 | |
9704 | const DynamicAny operator [] (const std::string& name) const |
9705 | { |
9706 | return get(name); |
9707 | } |
9708 | |
9709 | template<int N> |
9710 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
9711 | { |
9712 | return TupleType::template get<N>(); |
9713 | } |
9714 | |
9715 | template<int N> |
9716 | typename TypeGetter<N, Type>::HeadType& get() |
9717 | { |
9718 | return TupleType::template get<N>(); |
9719 | } |
9720 | |
9721 | template<int N> |
9722 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
9723 | { |
9724 | return TupleType::template set<N>(val); |
9725 | } |
9726 | |
9727 | const NameVecPtr& names() |
9728 | { |
9729 | return _pNames; |
9730 | } |
9731 | |
9732 | void setName(std::size_t index, const std::string& name) |
9733 | { |
9734 | if (index >= _pNames->size()) |
9735 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
9736 | |
9737 | (*_pNames)[index] = name; |
9738 | } |
9739 | |
9740 | const std::string& getName(std::size_t index) |
9741 | { |
9742 | if (index >= _pNames->size()) |
9743 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
9744 | |
9745 | return (*_pNames)[index]; |
9746 | } |
9747 | |
9748 | bool operator == (const NamedTuple& other) const |
9749 | { |
9750 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
9751 | } |
9752 | |
9753 | bool operator != (const NamedTuple& other) const |
9754 | { |
9755 | return !(*this == other); |
9756 | } |
9757 | |
9758 | bool operator < (const NamedTuple& other) const |
9759 | { |
9760 | TupleType th(*this); |
9761 | TupleType oth(other); |
9762 | |
9763 | return (th < oth && _pNames == other._pNames) || |
9764 | (th == oth && _pNames < other._pNames) || |
9765 | (th < oth && _pNames < other._pNames); |
9766 | } |
9767 | |
9768 | private: |
9769 | void init(const std::string& n0 = "A" , |
9770 | const std::string& n1 = "B" , |
9771 | const std::string& n2 = "C" , |
9772 | const std::string& n3 = "D" , |
9773 | const std::string& n4 = "E" , |
9774 | const std::string& n5 = "F" , |
9775 | const std::string& n6 = "G" , |
9776 | const std::string& n7 = "H" , |
9777 | const std::string& n8 = "I" , |
9778 | const std::string& n9 = "J" , |
9779 | const std::string& n10 = "K" , |
9780 | const std::string& n11 = "L" , |
9781 | const std::string& n12 = "M" ) |
9782 | { |
9783 | if (!_pNames) |
9784 | { |
9785 | _pNames = new NameVec; |
9786 | _pNames->push_back(n0); |
9787 | _pNames->push_back(n1); |
9788 | _pNames->push_back(n2); |
9789 | _pNames->push_back(n3); |
9790 | _pNames->push_back(n4); |
9791 | _pNames->push_back(n5); |
9792 | _pNames->push_back(n6); |
9793 | _pNames->push_back(n7); |
9794 | _pNames->push_back(n8); |
9795 | _pNames->push_back(n9); |
9796 | _pNames->push_back(n10); |
9797 | _pNames->push_back(n11); |
9798 | _pNames->push_back(n12); |
9799 | } |
9800 | } |
9801 | |
9802 | NameVecPtr _pNames; |
9803 | }; |
9804 | |
9805 | |
9806 | template<class T0, |
9807 | class T1, |
9808 | class T2, |
9809 | class T3, |
9810 | class T4, |
9811 | class T5, |
9812 | class T6, |
9813 | class T7, |
9814 | class T8, |
9815 | class T9, |
9816 | class T10, |
9817 | class T11> |
9818 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,NullTypeList>: |
9819 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> |
9820 | { |
9821 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> TupleType; |
9822 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>::Type Type; |
9823 | |
9824 | typedef std::vector<std::string> NameVec; |
9825 | typedef SharedPtr<NameVec> NameVecPtr; |
9826 | |
9827 | NamedTuple(): _pNames(0) |
9828 | { |
9829 | init(); |
9830 | } |
9831 | |
9832 | NamedTuple(const NameVecPtr& rNames) |
9833 | { |
9834 | if (rNames->size() != TupleType::length) |
9835 | throw InvalidArgumentException("Wrong names vector length." ); |
9836 | |
9837 | _pNames = rNames; |
9838 | } |
9839 | |
9840 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
9841 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
9842 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
9843 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
9844 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
9845 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
9846 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
9847 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
9848 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
9849 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
9850 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
9851 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11)): |
9852 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11), |
9853 | _pNames(0) |
9854 | { |
9855 | init(); |
9856 | } |
9857 | |
9858 | NamedTuple(const NameVecPtr& rNames, |
9859 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
9860 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
9861 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
9862 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
9863 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
9864 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
9865 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
9866 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
9867 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
9868 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
9869 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
9870 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11)): |
9871 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11) |
9872 | { |
9873 | if (rNames->size() != TupleType::length) |
9874 | throw InvalidArgumentException("Wrong names vector length." ); |
9875 | |
9876 | _pNames = rNames; |
9877 | } |
9878 | |
9879 | NamedTuple(const std::string& n0, |
9880 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
9881 | const std::string& n1 = "B" , |
9882 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
9883 | const std::string& n2 = "C" , |
9884 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
9885 | const std::string& n3 = "D" , |
9886 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
9887 | const std::string& n4 = "E" , |
9888 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
9889 | const std::string& n5 = "F" , |
9890 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
9891 | const std::string& n6 = "G" , |
9892 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
9893 | const std::string& n7 = "H" , |
9894 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
9895 | const std::string& n8 = "I" , |
9896 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
9897 | const std::string& n9 = "J" , |
9898 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
9899 | const std::string& n10 = "K" , |
9900 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), |
9901 | const std::string& n11 = "L" , |
9902 | typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11)): |
9903 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11), |
9904 | _pNames(0) |
9905 | { |
9906 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11); |
9907 | } |
9908 | |
9909 | const DynamicAny get(const std::string& name) const |
9910 | { |
9911 | NameVec::const_iterator it = _pNames->begin(); |
9912 | NameVec::const_iterator itEnd = _pNames->end(); |
9913 | |
9914 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
9915 | { |
9916 | if (name == *it) |
9917 | { |
9918 | switch (counter) |
9919 | { |
9920 | case 0: return TupleType::template get<0>(); |
9921 | case 1: return TupleType::template get<1>(); |
9922 | case 2: return TupleType::template get<2>(); |
9923 | case 3: return TupleType::template get<3>(); |
9924 | case 4: return TupleType::template get<4>(); |
9925 | case 5: return TupleType::template get<5>(); |
9926 | case 6: return TupleType::template get<6>(); |
9927 | case 7: return TupleType::template get<7>(); |
9928 | case 8: return TupleType::template get<8>(); |
9929 | case 9: return TupleType::template get<9>(); |
9930 | case 10: return TupleType::template get<10>(); |
9931 | case 11: return TupleType::template get<11>(); |
9932 | default: throw RangeException(); |
9933 | } |
9934 | } |
9935 | } |
9936 | |
9937 | throw NotFoundException("Name not found: " + name); |
9938 | } |
9939 | |
9940 | const DynamicAny operator [] (const std::string& name) const |
9941 | { |
9942 | return get(name); |
9943 | } |
9944 | |
9945 | template<int N> |
9946 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
9947 | { |
9948 | return TupleType::template get<N>(); |
9949 | } |
9950 | |
9951 | template<int N> |
9952 | typename TypeGetter<N, Type>::HeadType& get() |
9953 | { |
9954 | return TupleType::template get<N>(); |
9955 | } |
9956 | |
9957 | template<int N> |
9958 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
9959 | { |
9960 | return TupleType::template set<N>(val); |
9961 | } |
9962 | |
9963 | const NameVecPtr& names() |
9964 | { |
9965 | return _pNames; |
9966 | } |
9967 | |
9968 | void setName(std::size_t index, const std::string& name) |
9969 | { |
9970 | if (index >= _pNames->size()) |
9971 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
9972 | |
9973 | (*_pNames)[index] = name; |
9974 | } |
9975 | |
9976 | const std::string& getName(std::size_t index) |
9977 | { |
9978 | if (index >= _pNames->size()) |
9979 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
9980 | |
9981 | return (*_pNames)[index]; |
9982 | } |
9983 | |
9984 | bool operator == (const NamedTuple& other) const |
9985 | { |
9986 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
9987 | } |
9988 | |
9989 | bool operator != (const NamedTuple& other) const |
9990 | { |
9991 | return !(*this == other); |
9992 | } |
9993 | |
9994 | bool operator < (const NamedTuple& other) const |
9995 | { |
9996 | TupleType th(*this); |
9997 | TupleType oth(other); |
9998 | |
9999 | return (th < oth && _pNames == other._pNames) || |
10000 | (th == oth && _pNames < other._pNames) || |
10001 | (th < oth && _pNames < other._pNames); |
10002 | } |
10003 | |
10004 | private: |
10005 | void init(const std::string& n0 = "A" , |
10006 | const std::string& n1 = "B" , |
10007 | const std::string& n2 = "C" , |
10008 | const std::string& n3 = "D" , |
10009 | const std::string& n4 = "E" , |
10010 | const std::string& n5 = "F" , |
10011 | const std::string& n6 = "G" , |
10012 | const std::string& n7 = "H" , |
10013 | const std::string& n8 = "I" , |
10014 | const std::string& n9 = "J" , |
10015 | const std::string& n10 = "K" , |
10016 | const std::string& n11 = "L" ) |
10017 | { |
10018 | if (!_pNames) |
10019 | { |
10020 | _pNames = new NameVec; |
10021 | _pNames->push_back(n0); |
10022 | _pNames->push_back(n1); |
10023 | _pNames->push_back(n2); |
10024 | _pNames->push_back(n3); |
10025 | _pNames->push_back(n4); |
10026 | _pNames->push_back(n5); |
10027 | _pNames->push_back(n6); |
10028 | _pNames->push_back(n7); |
10029 | _pNames->push_back(n8); |
10030 | _pNames->push_back(n9); |
10031 | _pNames->push_back(n10); |
10032 | _pNames->push_back(n11); |
10033 | } |
10034 | } |
10035 | |
10036 | NameVecPtr _pNames; |
10037 | }; |
10038 | |
10039 | |
10040 | template<class T0, |
10041 | class T1, |
10042 | class T2, |
10043 | class T3, |
10044 | class T4, |
10045 | class T5, |
10046 | class T6, |
10047 | class T7, |
10048 | class T8, |
10049 | class T9, |
10050 | class T10> |
10051 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,NullTypeList>: |
10052 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> |
10053 | { |
10054 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> TupleType; |
10055 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>::Type Type; |
10056 | |
10057 | typedef std::vector<std::string> NameVec; |
10058 | typedef SharedPtr<NameVec> NameVecPtr; |
10059 | |
10060 | NamedTuple(): _pNames(0) |
10061 | { |
10062 | init(); |
10063 | } |
10064 | |
10065 | NamedTuple(const NameVecPtr& rNames) |
10066 | { |
10067 | if (rNames->size() != TupleType::length) |
10068 | throw InvalidArgumentException("Wrong names vector length." ); |
10069 | |
10070 | _pNames = rNames; |
10071 | } |
10072 | |
10073 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
10074 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
10075 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
10076 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
10077 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
10078 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
10079 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
10080 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
10081 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
10082 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
10083 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10)): |
10084 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10), |
10085 | _pNames(0) |
10086 | { |
10087 | init(); |
10088 | } |
10089 | |
10090 | NamedTuple(const NameVecPtr& rNames, |
10091 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
10092 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
10093 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
10094 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
10095 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
10096 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
10097 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
10098 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
10099 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
10100 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
10101 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10)): |
10102 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10) |
10103 | { |
10104 | if (rNames->size() != TupleType::length) |
10105 | throw InvalidArgumentException("Wrong names vector length." ); |
10106 | |
10107 | _pNames = rNames; |
10108 | } |
10109 | |
10110 | NamedTuple(const std::string& n0, |
10111 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
10112 | const std::string& n1 = "B" , |
10113 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
10114 | const std::string& n2 = "C" , |
10115 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
10116 | const std::string& n3 = "D" , |
10117 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
10118 | const std::string& n4 = "E" , |
10119 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
10120 | const std::string& n5 = "F" , |
10121 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
10122 | const std::string& n6 = "G" , |
10123 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
10124 | const std::string& n7 = "H" , |
10125 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
10126 | const std::string& n8 = "I" , |
10127 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
10128 | const std::string& n9 = "J" , |
10129 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), |
10130 | const std::string& n10 = "K" , |
10131 | typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10)): |
10132 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10), _pNames(0) |
10133 | { |
10134 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10); |
10135 | } |
10136 | |
10137 | const DynamicAny get(const std::string& name) const |
10138 | { |
10139 | NameVec::const_iterator it = _pNames->begin(); |
10140 | NameVec::const_iterator itEnd = _pNames->end(); |
10141 | |
10142 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
10143 | { |
10144 | if (name == *it) |
10145 | { |
10146 | switch (counter) |
10147 | { |
10148 | case 0: return TupleType::template get<0>(); |
10149 | case 1: return TupleType::template get<1>(); |
10150 | case 2: return TupleType::template get<2>(); |
10151 | case 3: return TupleType::template get<3>(); |
10152 | case 4: return TupleType::template get<4>(); |
10153 | case 5: return TupleType::template get<5>(); |
10154 | case 6: return TupleType::template get<6>(); |
10155 | case 7: return TupleType::template get<7>(); |
10156 | case 8: return TupleType::template get<8>(); |
10157 | case 9: return TupleType::template get<9>(); |
10158 | case 10: return TupleType::template get<10>(); |
10159 | default: throw RangeException(); |
10160 | } |
10161 | } |
10162 | } |
10163 | |
10164 | throw NotFoundException("Name not found: " + name); |
10165 | } |
10166 | |
10167 | const DynamicAny operator [] (const std::string& name) const |
10168 | { |
10169 | return get(name); |
10170 | } |
10171 | |
10172 | template<int N> |
10173 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
10174 | { |
10175 | return TupleType::template get<N>(); |
10176 | } |
10177 | |
10178 | template<int N> |
10179 | typename TypeGetter<N, Type>::HeadType& get() |
10180 | { |
10181 | return TupleType::template get<N>(); |
10182 | } |
10183 | |
10184 | template<int N> |
10185 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
10186 | { |
10187 | return TupleType::template set<N>(val); |
10188 | } |
10189 | |
10190 | const NameVecPtr& names() |
10191 | { |
10192 | return _pNames; |
10193 | } |
10194 | |
10195 | void setName(std::size_t index, const std::string& name) |
10196 | { |
10197 | if (index >= _pNames->size()) |
10198 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
10199 | |
10200 | (*_pNames)[index] = name; |
10201 | } |
10202 | |
10203 | const std::string& getName(std::size_t index) |
10204 | { |
10205 | if (index >= _pNames->size()) |
10206 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
10207 | |
10208 | return (*_pNames)[index]; |
10209 | } |
10210 | |
10211 | bool operator == (const NamedTuple& other) const |
10212 | { |
10213 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
10214 | } |
10215 | |
10216 | bool operator != (const NamedTuple& other) const |
10217 | { |
10218 | return !(*this == other); |
10219 | } |
10220 | |
10221 | bool operator < (const NamedTuple& other) const |
10222 | { |
10223 | TupleType th(*this); |
10224 | TupleType oth(other); |
10225 | |
10226 | return (th < oth && _pNames == other._pNames) || |
10227 | (th == oth && _pNames < other._pNames) || |
10228 | (th < oth && _pNames < other._pNames); |
10229 | } |
10230 | |
10231 | private: |
10232 | void init(const std::string& n0 = "A" , |
10233 | const std::string& n1 = "B" , |
10234 | const std::string& n2 = "C" , |
10235 | const std::string& n3 = "D" , |
10236 | const std::string& n4 = "E" , |
10237 | const std::string& n5 = "F" , |
10238 | const std::string& n6 = "G" , |
10239 | const std::string& n7 = "H" , |
10240 | const std::string& n8 = "I" , |
10241 | const std::string& n9 = "J" , |
10242 | const std::string& n10 = "K" ) |
10243 | { |
10244 | if (!_pNames) |
10245 | { |
10246 | _pNames = new NameVec; |
10247 | _pNames->push_back(n0); |
10248 | _pNames->push_back(n1); |
10249 | _pNames->push_back(n2); |
10250 | _pNames->push_back(n3); |
10251 | _pNames->push_back(n4); |
10252 | _pNames->push_back(n5); |
10253 | _pNames->push_back(n6); |
10254 | _pNames->push_back(n7); |
10255 | _pNames->push_back(n8); |
10256 | _pNames->push_back(n9); |
10257 | _pNames->push_back(n10); |
10258 | } |
10259 | } |
10260 | |
10261 | NameVecPtr _pNames; |
10262 | }; |
10263 | |
10264 | |
10265 | template<class T0, |
10266 | class T1, |
10267 | class T2, |
10268 | class T3, |
10269 | class T4, |
10270 | class T5, |
10271 | class T6, |
10272 | class T7, |
10273 | class T8, |
10274 | class T9> |
10275 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,NullTypeList>: |
10276 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> |
10277 | { |
10278 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> TupleType; |
10279 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>::Type Type; |
10280 | |
10281 | typedef std::vector<std::string> NameVec; |
10282 | typedef SharedPtr<NameVec> NameVecPtr; |
10283 | |
10284 | NamedTuple(): _pNames(0) |
10285 | { |
10286 | init(); |
10287 | } |
10288 | |
10289 | NamedTuple(const NameVecPtr& rNames) |
10290 | { |
10291 | if (rNames->size() != TupleType::length) |
10292 | throw InvalidArgumentException("Wrong names vector length." ); |
10293 | |
10294 | _pNames = rNames; |
10295 | } |
10296 | |
10297 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
10298 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
10299 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
10300 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
10301 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
10302 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
10303 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
10304 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
10305 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
10306 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9)): |
10307 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9), |
10308 | _pNames(0) |
10309 | { |
10310 | init(); |
10311 | } |
10312 | |
10313 | NamedTuple(const NameVecPtr& rNames, |
10314 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
10315 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
10316 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
10317 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
10318 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
10319 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
10320 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
10321 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
10322 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
10323 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9)): |
10324 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9) |
10325 | { |
10326 | if (rNames->size() != TupleType::length) |
10327 | throw InvalidArgumentException("Wrong names vector length." ); |
10328 | |
10329 | _pNames = rNames; |
10330 | } |
10331 | |
10332 | NamedTuple(const std::string& n0, |
10333 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
10334 | const std::string& n1 = "B" , |
10335 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
10336 | const std::string& n2 = "C" , |
10337 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
10338 | const std::string& n3 = "D" , |
10339 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
10340 | const std::string& n4 = "E" , |
10341 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
10342 | const std::string& n5 = "F" , |
10343 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
10344 | const std::string& n6 = "G" , |
10345 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
10346 | const std::string& n7 = "H" , |
10347 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
10348 | const std::string& n8 = "I" , |
10349 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), |
10350 | const std::string& n9 = "J" , |
10351 | typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9)): |
10352 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9), |
10353 | _pNames(0) |
10354 | { |
10355 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9); |
10356 | } |
10357 | |
10358 | const DynamicAny get(const std::string& name) const |
10359 | { |
10360 | NameVec::const_iterator it = _pNames->begin(); |
10361 | NameVec::const_iterator itEnd = _pNames->end(); |
10362 | |
10363 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
10364 | { |
10365 | if (name == *it) |
10366 | { |
10367 | switch (counter) |
10368 | { |
10369 | case 0: return TupleType::template get<0>(); |
10370 | case 1: return TupleType::template get<1>(); |
10371 | case 2: return TupleType::template get<2>(); |
10372 | case 3: return TupleType::template get<3>(); |
10373 | case 4: return TupleType::template get<4>(); |
10374 | case 5: return TupleType::template get<5>(); |
10375 | case 6: return TupleType::template get<6>(); |
10376 | case 7: return TupleType::template get<7>(); |
10377 | case 8: return TupleType::template get<8>(); |
10378 | case 9: return TupleType::template get<9>(); |
10379 | default: throw RangeException(); |
10380 | } |
10381 | } |
10382 | } |
10383 | |
10384 | throw NotFoundException("Name not found: " + name); |
10385 | } |
10386 | |
10387 | const DynamicAny operator [] (const std::string& name) const |
10388 | { |
10389 | return get(name); |
10390 | } |
10391 | |
10392 | template<int N> |
10393 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
10394 | { |
10395 | return TupleType::template get<N>(); |
10396 | } |
10397 | |
10398 | template<int N> |
10399 | typename TypeGetter<N, Type>::HeadType& get() |
10400 | { |
10401 | return TupleType::template get<N>(); |
10402 | } |
10403 | |
10404 | template<int N> |
10405 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
10406 | { |
10407 | return TupleType::template set<N>(val); |
10408 | } |
10409 | |
10410 | const NameVecPtr& names() |
10411 | { |
10412 | return _pNames; |
10413 | } |
10414 | |
10415 | void setName(std::size_t index, const std::string& name) |
10416 | { |
10417 | if (index >= _pNames->size()) |
10418 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
10419 | |
10420 | (*_pNames)[index] = name; |
10421 | } |
10422 | |
10423 | const std::string& getName(std::size_t index) |
10424 | { |
10425 | if (index >= _pNames->size()) |
10426 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
10427 | |
10428 | return (*_pNames)[index]; |
10429 | } |
10430 | |
10431 | bool operator == (const NamedTuple& other) const |
10432 | { |
10433 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
10434 | } |
10435 | |
10436 | bool operator != (const NamedTuple& other) const |
10437 | { |
10438 | return !(*this == other); |
10439 | } |
10440 | |
10441 | bool operator < (const NamedTuple& other) const |
10442 | { |
10443 | TupleType th(*this); |
10444 | TupleType oth(other); |
10445 | |
10446 | return (th < oth && _pNames == other._pNames) || |
10447 | (th == oth && _pNames < other._pNames) || |
10448 | (th < oth && _pNames < other._pNames); |
10449 | } |
10450 | |
10451 | private: |
10452 | void init(const std::string& n0 = "A" , |
10453 | const std::string& n1 = "B" , |
10454 | const std::string& n2 = "C" , |
10455 | const std::string& n3 = "D" , |
10456 | const std::string& n4 = "E" , |
10457 | const std::string& n5 = "F" , |
10458 | const std::string& n6 = "G" , |
10459 | const std::string& n7 = "H" , |
10460 | const std::string& n8 = "I" , |
10461 | const std::string& n9 = "J" ) |
10462 | { |
10463 | if (!_pNames) |
10464 | { |
10465 | _pNames = new NameVec; |
10466 | _pNames->push_back(n0); |
10467 | _pNames->push_back(n1); |
10468 | _pNames->push_back(n2); |
10469 | _pNames->push_back(n3); |
10470 | _pNames->push_back(n4); |
10471 | _pNames->push_back(n5); |
10472 | _pNames->push_back(n6); |
10473 | _pNames->push_back(n7); |
10474 | _pNames->push_back(n8); |
10475 | _pNames->push_back(n9); |
10476 | } |
10477 | } |
10478 | |
10479 | NameVecPtr _pNames; |
10480 | }; |
10481 | |
10482 | |
10483 | template<class T0, |
10484 | class T1, |
10485 | class T2, |
10486 | class T3, |
10487 | class T4, |
10488 | class T5, |
10489 | class T6, |
10490 | class T7, |
10491 | class T8> |
10492 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,NullTypeList>: |
10493 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8> |
10494 | { |
10495 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8> TupleType; |
10496 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8>::Type Type; |
10497 | |
10498 | typedef std::vector<std::string> NameVec; |
10499 | typedef SharedPtr<NameVec> NameVecPtr; |
10500 | |
10501 | NamedTuple(): _pNames(0) |
10502 | { |
10503 | init(); |
10504 | } |
10505 | |
10506 | NamedTuple(const NameVecPtr& rNames) |
10507 | { |
10508 | if (rNames->size() != TupleType::length) |
10509 | throw InvalidArgumentException("Wrong names vector length." ); |
10510 | |
10511 | _pNames = rNames; |
10512 | } |
10513 | |
10514 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
10515 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
10516 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
10517 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
10518 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
10519 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
10520 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
10521 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
10522 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8)): |
10523 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8), |
10524 | _pNames(0) |
10525 | { |
10526 | init(); |
10527 | } |
10528 | |
10529 | NamedTuple(const NameVecPtr& rNames, |
10530 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
10531 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
10532 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
10533 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
10534 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
10535 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
10536 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
10537 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
10538 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8)): |
10539 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8) |
10540 | { |
10541 | if (rNames->size() != TupleType::length) |
10542 | throw InvalidArgumentException("Wrong names vector length." ); |
10543 | |
10544 | _pNames = rNames; |
10545 | } |
10546 | |
10547 | NamedTuple(const std::string& n0, |
10548 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
10549 | const std::string& n1 = "B" , |
10550 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
10551 | const std::string& n2 = "C" , |
10552 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
10553 | const std::string& n3 = "D" , |
10554 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
10555 | const std::string& n4 = "E" , |
10556 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
10557 | const std::string& n5 = "F" , |
10558 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
10559 | const std::string& n6 = "G" , |
10560 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
10561 | const std::string& n7 = "H" , |
10562 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), |
10563 | const std::string& n8 = "I" , |
10564 | typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8)): |
10565 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8), |
10566 | _pNames(0) |
10567 | { |
10568 | init(n0,n1,n2,n3,n4,n5,n6,n7,n8); |
10569 | } |
10570 | |
10571 | const DynamicAny get(const std::string& name) const |
10572 | { |
10573 | NameVec::const_iterator it = _pNames->begin(); |
10574 | NameVec::const_iterator itEnd = _pNames->end(); |
10575 | |
10576 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
10577 | { |
10578 | if (name == *it) |
10579 | { |
10580 | switch (counter) |
10581 | { |
10582 | case 0: return TupleType::template get<0>(); |
10583 | case 1: return TupleType::template get<1>(); |
10584 | case 2: return TupleType::template get<2>(); |
10585 | case 3: return TupleType::template get<3>(); |
10586 | case 4: return TupleType::template get<4>(); |
10587 | case 5: return TupleType::template get<5>(); |
10588 | case 6: return TupleType::template get<6>(); |
10589 | case 7: return TupleType::template get<7>(); |
10590 | case 8: return TupleType::template get<8>(); |
10591 | default: throw RangeException(); |
10592 | } |
10593 | } |
10594 | } |
10595 | |
10596 | throw NotFoundException("Name not found: " + name); |
10597 | } |
10598 | |
10599 | const DynamicAny operator [] (const std::string& name) const |
10600 | { |
10601 | return get(name); |
10602 | } |
10603 | |
10604 | template<int N> |
10605 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
10606 | { |
10607 | return TupleType::template get<N>(); |
10608 | } |
10609 | |
10610 | template<int N> |
10611 | typename TypeGetter<N, Type>::HeadType& get() |
10612 | { |
10613 | return TupleType::template get<N>(); |
10614 | } |
10615 | |
10616 | template<int N> |
10617 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
10618 | { |
10619 | return TupleType::template set<N>(val); |
10620 | } |
10621 | |
10622 | const NameVecPtr& names() |
10623 | { |
10624 | return _pNames; |
10625 | } |
10626 | |
10627 | void setName(std::size_t index, const std::string& name) |
10628 | { |
10629 | if (index >= _pNames->size()) |
10630 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
10631 | |
10632 | (*_pNames)[index] = name; |
10633 | } |
10634 | |
10635 | const std::string& getName(std::size_t index) |
10636 | { |
10637 | if (index >= _pNames->size()) |
10638 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
10639 | |
10640 | return (*_pNames)[index]; |
10641 | } |
10642 | |
10643 | bool operator == (const NamedTuple& other) const |
10644 | { |
10645 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
10646 | } |
10647 | |
10648 | bool operator != (const NamedTuple& other) const |
10649 | { |
10650 | return !(*this == other); |
10651 | } |
10652 | |
10653 | bool operator < (const NamedTuple& other) const |
10654 | { |
10655 | TupleType th(*this); |
10656 | TupleType oth(other); |
10657 | |
10658 | return (th < oth && _pNames == other._pNames) || |
10659 | (th == oth && _pNames < other._pNames) || |
10660 | (th < oth && _pNames < other._pNames); |
10661 | } |
10662 | |
10663 | private: |
10664 | void init(const std::string& n0 = "A" , |
10665 | const std::string& n1 = "B" , |
10666 | const std::string& n2 = "C" , |
10667 | const std::string& n3 = "D" , |
10668 | const std::string& n4 = "E" , |
10669 | const std::string& n5 = "F" , |
10670 | const std::string& n6 = "G" , |
10671 | const std::string& n7 = "H" , |
10672 | const std::string& n8 = "I" ) |
10673 | { |
10674 | if (!_pNames) |
10675 | { |
10676 | _pNames = new NameVec; |
10677 | _pNames->push_back(n0); |
10678 | _pNames->push_back(n1); |
10679 | _pNames->push_back(n2); |
10680 | _pNames->push_back(n3); |
10681 | _pNames->push_back(n4); |
10682 | _pNames->push_back(n5); |
10683 | _pNames->push_back(n6); |
10684 | _pNames->push_back(n7); |
10685 | _pNames->push_back(n8); |
10686 | } |
10687 | } |
10688 | |
10689 | NameVecPtr _pNames; |
10690 | }; |
10691 | |
10692 | |
10693 | template<class T0, |
10694 | class T1, |
10695 | class T2, |
10696 | class T3, |
10697 | class T4, |
10698 | class T5, |
10699 | class T6, |
10700 | class T7> |
10701 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,NullTypeList>: |
10702 | public Tuple<T0,T1,T2,T3,T4,T5,T6,T7> |
10703 | { |
10704 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7> TupleType; |
10705 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7>::Type Type; |
10706 | |
10707 | typedef std::vector<std::string> NameVec; |
10708 | typedef SharedPtr<NameVec> NameVecPtr; |
10709 | |
10710 | NamedTuple(): _pNames(0) |
10711 | { |
10712 | init(); |
10713 | } |
10714 | |
10715 | NamedTuple(const NameVecPtr& rNames) |
10716 | { |
10717 | if (rNames->size() != TupleType::length) |
10718 | throw InvalidArgumentException("Wrong names vector length." ); |
10719 | |
10720 | _pNames = rNames; |
10721 | } |
10722 | |
10723 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
10724 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
10725 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
10726 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
10727 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
10728 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
10729 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
10730 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7)): |
10731 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7), |
10732 | _pNames(0) |
10733 | { |
10734 | init(); |
10735 | } |
10736 | |
10737 | NamedTuple(const NameVecPtr& rNames, |
10738 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
10739 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
10740 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
10741 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
10742 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
10743 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
10744 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
10745 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7)): |
10746 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7) |
10747 | { |
10748 | if (rNames->size() != TupleType::length) |
10749 | throw InvalidArgumentException("Wrong names vector length." ); |
10750 | |
10751 | _pNames = rNames; |
10752 | } |
10753 | |
10754 | NamedTuple(const std::string& n0, |
10755 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
10756 | const std::string& n1 = "B" , |
10757 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
10758 | const std::string& n2 = "C" , |
10759 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
10760 | const std::string& n3 = "D" , |
10761 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
10762 | const std::string& n4 = "E" , |
10763 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
10764 | const std::string& n5 = "F" , |
10765 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
10766 | const std::string& n6 = "G" , |
10767 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), |
10768 | const std::string& n7 = "H" , |
10769 | typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7)): |
10770 | TupleType(t0,t1,t2,t3,t4,t5,t6,t7), |
10771 | _pNames(0) |
10772 | { |
10773 | init(n0,n1,n2,n3,n4,n5,n6,n7); |
10774 | } |
10775 | |
10776 | const DynamicAny get(const std::string& name) const |
10777 | { |
10778 | NameVec::const_iterator it = _pNames->begin(); |
10779 | NameVec::const_iterator itEnd = _pNames->end(); |
10780 | |
10781 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
10782 | { |
10783 | if (name == *it) |
10784 | { |
10785 | switch (counter) |
10786 | { |
10787 | case 0: return TupleType::template get<0>(); |
10788 | case 1: return TupleType::template get<1>(); |
10789 | case 2: return TupleType::template get<2>(); |
10790 | case 3: return TupleType::template get<3>(); |
10791 | case 4: return TupleType::template get<4>(); |
10792 | case 5: return TupleType::template get<5>(); |
10793 | case 6: return TupleType::template get<6>(); |
10794 | case 7: return TupleType::template get<7>(); |
10795 | default: throw RangeException(); |
10796 | } |
10797 | } |
10798 | } |
10799 | |
10800 | throw NotFoundException("Name not found: " + name); |
10801 | } |
10802 | |
10803 | const DynamicAny operator [] (const std::string& name) const |
10804 | { |
10805 | return get(name); |
10806 | } |
10807 | |
10808 | template<int N> |
10809 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
10810 | { |
10811 | return TupleType::template get<N>(); |
10812 | } |
10813 | |
10814 | template<int N> |
10815 | typename TypeGetter<N, Type>::HeadType& get() |
10816 | { |
10817 | return TupleType::template get<N>(); |
10818 | } |
10819 | |
10820 | template<int N> |
10821 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
10822 | { |
10823 | return TupleType::template set<N>(val); |
10824 | } |
10825 | |
10826 | const NameVecPtr& names() |
10827 | { |
10828 | return _pNames; |
10829 | } |
10830 | |
10831 | void setName(std::size_t index, const std::string& name) |
10832 | { |
10833 | if (index >= _pNames->size()) |
10834 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
10835 | |
10836 | (*_pNames)[index] = name; |
10837 | } |
10838 | |
10839 | const std::string& getName(std::size_t index) |
10840 | { |
10841 | if (index >= _pNames->size()) |
10842 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
10843 | |
10844 | return (*_pNames)[index]; |
10845 | } |
10846 | |
10847 | bool operator == (const NamedTuple& other) const |
10848 | { |
10849 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
10850 | } |
10851 | |
10852 | bool operator != (const NamedTuple& other) const |
10853 | { |
10854 | return !(*this == other); |
10855 | } |
10856 | |
10857 | bool operator < (const NamedTuple& other) const |
10858 | { |
10859 | TupleType th(*this); |
10860 | TupleType oth(other); |
10861 | |
10862 | return (th < oth && _pNames == other._pNames) || |
10863 | (th == oth && _pNames < other._pNames) || |
10864 | (th < oth && _pNames < other._pNames); |
10865 | } |
10866 | |
10867 | private: |
10868 | void init(const std::string& n0 = "A" , |
10869 | const std::string& n1 = "B" , |
10870 | const std::string& n2 = "C" , |
10871 | const std::string& n3 = "D" , |
10872 | const std::string& n4 = "E" , |
10873 | const std::string& n5 = "F" , |
10874 | const std::string& n6 = "G" , |
10875 | const std::string& n7 = "H" ) |
10876 | { |
10877 | if (!_pNames) |
10878 | { |
10879 | _pNames = new NameVec; |
10880 | _pNames->push_back(n0); |
10881 | _pNames->push_back(n1); |
10882 | _pNames->push_back(n2); |
10883 | _pNames->push_back(n3); |
10884 | _pNames->push_back(n4); |
10885 | _pNames->push_back(n5); |
10886 | _pNames->push_back(n6); |
10887 | _pNames->push_back(n7); |
10888 | } |
10889 | } |
10890 | |
10891 | NameVecPtr _pNames; |
10892 | }; |
10893 | |
10894 | |
10895 | template<class T0, |
10896 | class T1, |
10897 | class T2, |
10898 | class T3, |
10899 | class T4, |
10900 | class T5, |
10901 | class T6> |
10902 | struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,NullTypeList>: |
10903 | public Tuple<T0,T1,T2,T3,T4,T5,T6> |
10904 | { |
10905 | typedef Tuple<T0,T1,T2,T3,T4,T5,T6> TupleType; |
10906 | typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6>::Type Type; |
10907 | |
10908 | typedef std::vector<std::string> NameVec; |
10909 | typedef SharedPtr<NameVec> NameVecPtr; |
10910 | |
10911 | NamedTuple(): _pNames(0) |
10912 | { |
10913 | init(); |
10914 | } |
10915 | |
10916 | NamedTuple(const NameVecPtr& rNames) |
10917 | { |
10918 | if (rNames->size() != TupleType::length) |
10919 | throw InvalidArgumentException("Wrong names vector length." ); |
10920 | |
10921 | _pNames = rNames; |
10922 | } |
10923 | |
10924 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
10925 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
10926 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
10927 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
10928 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
10929 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
10930 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6)): |
10931 | TupleType(t0,t1,t2,t3,t4,t5,t6), _pNames(0) |
10932 | { |
10933 | init(); |
10934 | } |
10935 | |
10936 | NamedTuple(const NameVecPtr& rNames, |
10937 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
10938 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
10939 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
10940 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
10941 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
10942 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
10943 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6)): |
10944 | TupleType(t0,t1,t2,t3,t4,t5,t6) |
10945 | { |
10946 | if (rNames->size() != TupleType::length) |
10947 | throw InvalidArgumentException("Wrong names vector length." ); |
10948 | |
10949 | _pNames = rNames; |
10950 | } |
10951 | |
10952 | NamedTuple(const std::string& n0, |
10953 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
10954 | const std::string& n1 = "B" , |
10955 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
10956 | const std::string& n2 = "C" , |
10957 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
10958 | const std::string& n3 = "D" , |
10959 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
10960 | const std::string& n4 = "E" , |
10961 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
10962 | const std::string& n5 = "F" , |
10963 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), |
10964 | const std::string& n6 = "G" , |
10965 | typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6)): |
10966 | TupleType(t0,t1,t2,t3,t4,t5,t6), _pNames(0) |
10967 | { |
10968 | init(n0,n1,n2,n3,n4,n5,n6); |
10969 | } |
10970 | |
10971 | const DynamicAny get(const std::string& name) const |
10972 | { |
10973 | NameVec::const_iterator it = _pNames->begin(); |
10974 | NameVec::const_iterator itEnd = _pNames->end(); |
10975 | |
10976 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
10977 | { |
10978 | if (name == *it) |
10979 | { |
10980 | switch (counter) |
10981 | { |
10982 | case 0: return TupleType::template get<0>(); |
10983 | case 1: return TupleType::template get<1>(); |
10984 | case 2: return TupleType::template get<2>(); |
10985 | case 3: return TupleType::template get<3>(); |
10986 | case 4: return TupleType::template get<4>(); |
10987 | case 5: return TupleType::template get<5>(); |
10988 | case 6: return TupleType::template get<6>(); |
10989 | default: throw RangeException(); |
10990 | } |
10991 | } |
10992 | } |
10993 | |
10994 | throw NotFoundException("Name not found: " + name); |
10995 | } |
10996 | |
10997 | const DynamicAny operator [] (const std::string& name) const |
10998 | { |
10999 | return get(name); |
11000 | } |
11001 | |
11002 | template<int N> |
11003 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
11004 | { |
11005 | return TupleType::template get<N>(); |
11006 | } |
11007 | |
11008 | template<int N> |
11009 | typename TypeGetter<N, Type>::HeadType& get() |
11010 | { |
11011 | return TupleType::template get<N>(); |
11012 | } |
11013 | |
11014 | template<int N> |
11015 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
11016 | { |
11017 | return TupleType::template set<N>(val); |
11018 | } |
11019 | |
11020 | const NameVecPtr& names() |
11021 | { |
11022 | return _pNames; |
11023 | } |
11024 | |
11025 | void setName(std::size_t index, const std::string& name) |
11026 | { |
11027 | if (index >= _pNames->size()) |
11028 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
11029 | |
11030 | (*_pNames)[index] = name; |
11031 | } |
11032 | |
11033 | const std::string& getName(std::size_t index) |
11034 | { |
11035 | if (index >= _pNames->size()) |
11036 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
11037 | |
11038 | return (*_pNames)[index]; |
11039 | } |
11040 | |
11041 | bool operator == (const NamedTuple& other) const |
11042 | { |
11043 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
11044 | } |
11045 | |
11046 | bool operator != (const NamedTuple& other) const |
11047 | { |
11048 | return !(*this == other); |
11049 | } |
11050 | |
11051 | bool operator < (const NamedTuple& other) const |
11052 | { |
11053 | TupleType th(*this); |
11054 | TupleType oth(other); |
11055 | |
11056 | return (th < oth && _pNames == other._pNames) || |
11057 | (th == oth && _pNames < other._pNames) || |
11058 | (th < oth && _pNames < other._pNames); |
11059 | } |
11060 | |
11061 | private: |
11062 | void init(const std::string& n0 = "A" , |
11063 | const std::string& n1 = "B" , |
11064 | const std::string& n2 = "C" , |
11065 | const std::string& n3 = "D" , |
11066 | const std::string& n4 = "E" , |
11067 | const std::string& n5 = "F" , |
11068 | const std::string& n6 = "G" ) |
11069 | { |
11070 | if (!_pNames) |
11071 | { |
11072 | _pNames = new NameVec; |
11073 | _pNames->push_back(n0); |
11074 | _pNames->push_back(n1); |
11075 | _pNames->push_back(n2); |
11076 | _pNames->push_back(n3); |
11077 | _pNames->push_back(n4); |
11078 | _pNames->push_back(n5); |
11079 | _pNames->push_back(n6); |
11080 | } |
11081 | } |
11082 | |
11083 | NameVecPtr _pNames; |
11084 | }; |
11085 | |
11086 | |
11087 | template<class T0, |
11088 | class T1, |
11089 | class T2, |
11090 | class T3, |
11091 | class T4, |
11092 | class T5> |
11093 | struct NamedTuple<T0,T1,T2,T3,T4,T5,NullTypeList>: |
11094 | public Tuple<T0,T1,T2,T3,T4,T5> |
11095 | { |
11096 | typedef Tuple<T0,T1,T2,T3,T4,T5> TupleType; |
11097 | typedef typename Tuple<T0,T1,T2,T3,T4,T5>::Type Type; |
11098 | |
11099 | typedef std::vector<std::string> NameVec; |
11100 | typedef SharedPtr<NameVec> NameVecPtr; |
11101 | |
11102 | NamedTuple(): _pNames(0) |
11103 | { |
11104 | init(); |
11105 | } |
11106 | |
11107 | NamedTuple(const NameVecPtr& rNames) |
11108 | { |
11109 | if (rNames->size() != TupleType::length) |
11110 | throw InvalidArgumentException("Wrong names vector length." ); |
11111 | |
11112 | _pNames = rNames; |
11113 | } |
11114 | |
11115 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
11116 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
11117 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
11118 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
11119 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
11120 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5)): |
11121 | TupleType(t0,t1,t2,t3,t4,t5), _pNames(0) |
11122 | { |
11123 | init(); |
11124 | } |
11125 | |
11126 | NamedTuple(const NameVecPtr& rNames, |
11127 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
11128 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
11129 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
11130 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
11131 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
11132 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5)): |
11133 | TupleType(t0,t1,t2,t3,t4,t5) |
11134 | { |
11135 | if (rNames->size() != TupleType::length) |
11136 | throw InvalidArgumentException("Wrong names vector length." ); |
11137 | |
11138 | _pNames = rNames; |
11139 | } |
11140 | |
11141 | NamedTuple(const std::string& n0, |
11142 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
11143 | const std::string& n1 = "B" , |
11144 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
11145 | const std::string& n2 = "C" , |
11146 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
11147 | const std::string& n3 = "D" , |
11148 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
11149 | const std::string& n4 = "E" , |
11150 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), |
11151 | const std::string& n5 = "F" , |
11152 | typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5)): |
11153 | TupleType(t0,t1,t2,t3,t4,t5), _pNames(0) |
11154 | { |
11155 | init(n0,n1,n2,n3,n4,n5); |
11156 | } |
11157 | |
11158 | const DynamicAny get(const std::string& name) const |
11159 | { |
11160 | NameVec::const_iterator it = _pNames->begin(); |
11161 | NameVec::const_iterator itEnd = _pNames->end(); |
11162 | |
11163 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
11164 | { |
11165 | if (name == *it) |
11166 | { |
11167 | switch (counter) |
11168 | { |
11169 | case 0: return TupleType::template get<0>(); |
11170 | case 1: return TupleType::template get<1>(); |
11171 | case 2: return TupleType::template get<2>(); |
11172 | case 3: return TupleType::template get<3>(); |
11173 | case 4: return TupleType::template get<4>(); |
11174 | case 5: return TupleType::template get<5>(); |
11175 | default: throw RangeException(); |
11176 | } |
11177 | } |
11178 | } |
11179 | |
11180 | throw NotFoundException("Name not found: " + name); |
11181 | } |
11182 | |
11183 | const DynamicAny operator [] (const std::string& name) const |
11184 | { |
11185 | return get(name); |
11186 | } |
11187 | |
11188 | template<int N> |
11189 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
11190 | { |
11191 | return TupleType::template get<N>(); |
11192 | } |
11193 | |
11194 | template<int N> |
11195 | typename TypeGetter<N, Type>::HeadType& get() |
11196 | { |
11197 | return TupleType::template get<N>(); |
11198 | } |
11199 | |
11200 | template<int N> |
11201 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
11202 | { |
11203 | return TupleType::template set<N>(val); |
11204 | } |
11205 | |
11206 | const NameVecPtr& names() |
11207 | { |
11208 | return _pNames; |
11209 | } |
11210 | |
11211 | void setName(std::size_t index, const std::string& name) |
11212 | { |
11213 | if (index >= _pNames->size()) |
11214 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
11215 | |
11216 | (*_pNames)[index] = name; |
11217 | } |
11218 | |
11219 | const std::string& getName(std::size_t index) |
11220 | { |
11221 | if (index >= _pNames->size()) |
11222 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
11223 | |
11224 | return (*_pNames)[index]; |
11225 | } |
11226 | |
11227 | bool operator == (const NamedTuple& other) const |
11228 | { |
11229 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
11230 | } |
11231 | |
11232 | bool operator != (const NamedTuple& other) const |
11233 | { |
11234 | return !(*this == other); |
11235 | } |
11236 | |
11237 | bool operator < (const NamedTuple& other) const |
11238 | { |
11239 | TupleType th(*this); |
11240 | TupleType oth(other); |
11241 | |
11242 | return (th < oth && _pNames == other._pNames) || |
11243 | (th == oth && _pNames < other._pNames) || |
11244 | (th < oth && _pNames < other._pNames); |
11245 | } |
11246 | |
11247 | private: |
11248 | void init(const std::string& n0 = "A" , |
11249 | const std::string& n1 = "B" , |
11250 | const std::string& n2 = "C" , |
11251 | const std::string& n3 = "D" , |
11252 | const std::string& n4 = "E" , |
11253 | const std::string& n5 = "F" ) |
11254 | { |
11255 | if (!_pNames) |
11256 | { |
11257 | _pNames = new NameVec; |
11258 | _pNames->push_back(n0); |
11259 | _pNames->push_back(n1); |
11260 | _pNames->push_back(n2); |
11261 | _pNames->push_back(n3); |
11262 | _pNames->push_back(n4); |
11263 | _pNames->push_back(n5); |
11264 | } |
11265 | } |
11266 | |
11267 | NameVecPtr _pNames; |
11268 | }; |
11269 | |
11270 | |
11271 | template<class T0, |
11272 | class T1, |
11273 | class T2, |
11274 | class T3, |
11275 | class T4> |
11276 | struct NamedTuple<T0,T1,T2,T3,T4,NullTypeList>: |
11277 | public Tuple<T0,T1,T2,T3,T4> |
11278 | { |
11279 | typedef Tuple<T0,T1,T2,T3,T4> TupleType; |
11280 | typedef typename Tuple<T0,T1,T2,T3,T4>::Type Type; |
11281 | |
11282 | typedef std::vector<std::string> NameVec; |
11283 | typedef SharedPtr<NameVec> NameVecPtr; |
11284 | |
11285 | NamedTuple(): _pNames(0) |
11286 | { |
11287 | init(); |
11288 | } |
11289 | |
11290 | NamedTuple(const NameVecPtr& rNames) |
11291 | { |
11292 | if (rNames->size() != TupleType::length) |
11293 | throw InvalidArgumentException("Wrong names vector length." ); |
11294 | |
11295 | _pNames = rNames; |
11296 | } |
11297 | |
11298 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
11299 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
11300 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
11301 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
11302 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4)): |
11303 | TupleType(t0,t1,t2,t3,t4), |
11304 | _pNames(0) |
11305 | { |
11306 | init(); |
11307 | } |
11308 | |
11309 | NamedTuple(const NameVecPtr& rNames, |
11310 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
11311 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
11312 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
11313 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
11314 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4)): |
11315 | TupleType(t0,t1,t2,t3,t4) |
11316 | { |
11317 | if (rNames->size() != TupleType::length) |
11318 | throw InvalidArgumentException("Wrong names vector length." ); |
11319 | |
11320 | _pNames = rNames; |
11321 | } |
11322 | |
11323 | NamedTuple(const std::string& n0, |
11324 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
11325 | const std::string& n1 = "B" , |
11326 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
11327 | const std::string& n2 = "C" , |
11328 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
11329 | const std::string& n3 = "D" , |
11330 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), |
11331 | const std::string& n4 = "E" , |
11332 | typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4)): |
11333 | TupleType(t0,t1,t2,t3,t4), |
11334 | _pNames(0) |
11335 | { |
11336 | init(n0,n1,n2,n3,n4); |
11337 | } |
11338 | |
11339 | const DynamicAny get(const std::string& name) const |
11340 | { |
11341 | NameVec::const_iterator it = _pNames->begin(); |
11342 | NameVec::const_iterator itEnd = _pNames->end(); |
11343 | |
11344 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
11345 | { |
11346 | if (name == *it) |
11347 | { |
11348 | switch (counter) |
11349 | { |
11350 | case 0: return TupleType::template get<0>(); |
11351 | case 1: return TupleType::template get<1>(); |
11352 | case 2: return TupleType::template get<2>(); |
11353 | case 3: return TupleType::template get<3>(); |
11354 | case 4: return TupleType::template get<4>(); |
11355 | default: throw RangeException(); |
11356 | } |
11357 | } |
11358 | } |
11359 | |
11360 | throw NotFoundException("Name not found: " + name); |
11361 | } |
11362 | |
11363 | const DynamicAny operator [] (const std::string& name) const |
11364 | { |
11365 | return get(name); |
11366 | } |
11367 | |
11368 | template<int N> |
11369 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
11370 | { |
11371 | return TupleType::template get<N>(); |
11372 | } |
11373 | |
11374 | template<int N> |
11375 | typename TypeGetter<N, Type>::HeadType& get() |
11376 | { |
11377 | return TupleType::template get<N>(); |
11378 | } |
11379 | |
11380 | template<int N> |
11381 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
11382 | { |
11383 | return TupleType::template set<N>(val); |
11384 | } |
11385 | |
11386 | const NameVecPtr& names() |
11387 | { |
11388 | return _pNames; |
11389 | } |
11390 | |
11391 | void setName(std::size_t index, const std::string& name) |
11392 | { |
11393 | if (index >= _pNames->size()) |
11394 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
11395 | |
11396 | (*_pNames)[index] = name; |
11397 | } |
11398 | |
11399 | const std::string& getName(std::size_t index) |
11400 | { |
11401 | if (index >= _pNames->size()) |
11402 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
11403 | |
11404 | return (*_pNames)[index]; |
11405 | } |
11406 | |
11407 | bool operator == (const NamedTuple& other) const |
11408 | { |
11409 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
11410 | } |
11411 | |
11412 | bool operator != (const NamedTuple& other) const |
11413 | { |
11414 | return !(*this == other); |
11415 | } |
11416 | |
11417 | bool operator < (const NamedTuple& other) const |
11418 | { |
11419 | TupleType th(*this); |
11420 | TupleType oth(other); |
11421 | |
11422 | return (th < oth && _pNames == other._pNames) || |
11423 | (th == oth && _pNames < other._pNames) || |
11424 | (th < oth && _pNames < other._pNames); |
11425 | } |
11426 | |
11427 | private: |
11428 | void init(const std::string& n0 = "A" , |
11429 | const std::string& n1 = "B" , |
11430 | const std::string& n2 = "C" , |
11431 | const std::string& n3 = "D" , |
11432 | const std::string& n4 = "E" ) |
11433 | { |
11434 | if (!_pNames) |
11435 | { |
11436 | _pNames = new NameVec; |
11437 | _pNames->push_back(n0); |
11438 | _pNames->push_back(n1); |
11439 | _pNames->push_back(n2); |
11440 | _pNames->push_back(n3); |
11441 | _pNames->push_back(n4); |
11442 | } |
11443 | } |
11444 | |
11445 | NameVecPtr _pNames; |
11446 | }; |
11447 | |
11448 | |
11449 | template<class T0, |
11450 | class T1, |
11451 | class T2, |
11452 | class T3> |
11453 | struct NamedTuple<T0,T1,T2,T3,NullTypeList>: |
11454 | public Tuple<T0,T1,T2,T3> |
11455 | { |
11456 | typedef Tuple<T0,T1,T2,T3> TupleType; |
11457 | typedef typename Tuple<T0,T1,T2,T3>::Type Type; |
11458 | |
11459 | typedef std::vector<std::string> NameVec; |
11460 | typedef SharedPtr<NameVec> NameVecPtr; |
11461 | |
11462 | NamedTuple(): _pNames(0) |
11463 | { |
11464 | init(); |
11465 | } |
11466 | |
11467 | NamedTuple(const NameVecPtr& rNames) |
11468 | { |
11469 | if (rNames->size() != TupleType::length) |
11470 | throw InvalidArgumentException("Wrong names vector length." ); |
11471 | |
11472 | _pNames = rNames; |
11473 | } |
11474 | |
11475 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
11476 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
11477 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
11478 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3)): |
11479 | TupleType(t0,t1,t2,t3), |
11480 | _pNames(0) |
11481 | { |
11482 | init(); |
11483 | } |
11484 | |
11485 | NamedTuple(const NameVecPtr& rNames, |
11486 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
11487 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
11488 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
11489 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3)): |
11490 | TupleType(t0,t1,t2,t3) |
11491 | { |
11492 | if (rNames->size() != TupleType::length) |
11493 | throw InvalidArgumentException("Wrong names vector length." ); |
11494 | |
11495 | _pNames = rNames; |
11496 | } |
11497 | |
11498 | NamedTuple(const std::string& n0, |
11499 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
11500 | const std::string& n1 = "B" , |
11501 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
11502 | const std::string& n2 = "C" , |
11503 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), |
11504 | const std::string& n3 = "D" , |
11505 | typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3)): |
11506 | TupleType(t0,t1,t2,t3), _pNames(0) |
11507 | { |
11508 | init(n0,n1,n2,n3); |
11509 | } |
11510 | |
11511 | const DynamicAny get(const std::string& name) const |
11512 | { |
11513 | NameVec::const_iterator it = _pNames->begin(); |
11514 | NameVec::const_iterator itEnd = _pNames->end(); |
11515 | |
11516 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
11517 | { |
11518 | if (name == *it) |
11519 | { |
11520 | switch (counter) |
11521 | { |
11522 | case 0: return TupleType::template get<0>(); |
11523 | case 1: return TupleType::template get<1>(); |
11524 | case 2: return TupleType::template get<2>(); |
11525 | case 3: return TupleType::template get<3>(); |
11526 | default: throw RangeException(); |
11527 | } |
11528 | } |
11529 | } |
11530 | |
11531 | throw NotFoundException("Name not found: " + name); |
11532 | } |
11533 | |
11534 | const DynamicAny operator [] (const std::string& name) const |
11535 | { |
11536 | return get(name); |
11537 | } |
11538 | |
11539 | template<int N> |
11540 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
11541 | { |
11542 | return TupleType::template get<N>(); |
11543 | } |
11544 | |
11545 | template<int N> |
11546 | typename TypeGetter<N, Type>::HeadType& get() |
11547 | { |
11548 | return TupleType::template get<N>(); |
11549 | } |
11550 | |
11551 | template<int N> |
11552 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
11553 | { |
11554 | return TupleType::template set<N>(val); |
11555 | } |
11556 | |
11557 | const NameVecPtr& names() |
11558 | { |
11559 | return _pNames; |
11560 | } |
11561 | |
11562 | void setName(std::size_t index, const std::string& name) |
11563 | { |
11564 | if (index >= _pNames->size()) |
11565 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
11566 | |
11567 | (*_pNames)[index] = name; |
11568 | } |
11569 | |
11570 | const std::string& getName(std::size_t index) |
11571 | { |
11572 | if (index >= _pNames->size()) |
11573 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
11574 | |
11575 | return (*_pNames)[index]; |
11576 | } |
11577 | |
11578 | bool operator == (const NamedTuple& other) const |
11579 | { |
11580 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
11581 | } |
11582 | |
11583 | bool operator != (const NamedTuple& other) const |
11584 | { |
11585 | return !(*this == other); |
11586 | } |
11587 | |
11588 | bool operator < (const NamedTuple& other) const |
11589 | { |
11590 | TupleType th(*this); |
11591 | TupleType oth(other); |
11592 | |
11593 | return (th < oth && _pNames == other._pNames) || |
11594 | (th == oth && _pNames < other._pNames) || |
11595 | (th < oth && _pNames < other._pNames); |
11596 | } |
11597 | |
11598 | private: |
11599 | void init(const std::string& n0 = "A" , |
11600 | const std::string& n1 = "B" , |
11601 | const std::string& n2 = "C" , |
11602 | const std::string& n3 = "D" ) |
11603 | { |
11604 | if (!_pNames) |
11605 | { |
11606 | _pNames = new NameVec; |
11607 | _pNames->push_back(n0); |
11608 | _pNames->push_back(n1); |
11609 | _pNames->push_back(n2); |
11610 | _pNames->push_back(n3); |
11611 | } |
11612 | } |
11613 | |
11614 | NameVecPtr _pNames; |
11615 | }; |
11616 | |
11617 | |
11618 | template<class T0, |
11619 | class T1, |
11620 | class T2> |
11621 | struct NamedTuple<T0,T1,T2,NullTypeList>: |
11622 | public Tuple<T0,T1,T2> |
11623 | { |
11624 | typedef Tuple<T0,T1,T2> TupleType; |
11625 | typedef typename Tuple<T0,T1,T2>::Type Type; |
11626 | |
11627 | typedef std::vector<std::string> NameVec; |
11628 | typedef SharedPtr<NameVec> NameVecPtr; |
11629 | |
11630 | NamedTuple(): _pNames(0) |
11631 | { |
11632 | init(); |
11633 | } |
11634 | |
11635 | NamedTuple(const NameVecPtr& rNames) |
11636 | { |
11637 | if (rNames->size() != TupleType::length) |
11638 | throw InvalidArgumentException("Wrong names vector length." ); |
11639 | |
11640 | _pNames = rNames; |
11641 | } |
11642 | |
11643 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
11644 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
11645 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2)): |
11646 | TupleType(t0,t1,t2), |
11647 | _pNames(0) |
11648 | { |
11649 | init(); |
11650 | } |
11651 | |
11652 | NamedTuple(const NameVecPtr& rNames, |
11653 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
11654 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
11655 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2)): |
11656 | TupleType(t0,t1,t2) |
11657 | { |
11658 | if (rNames->size() != TupleType::length) |
11659 | throw InvalidArgumentException("Wrong names vector length." ); |
11660 | |
11661 | _pNames = rNames; |
11662 | } |
11663 | |
11664 | NamedTuple(const std::string& n0, |
11665 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
11666 | const std::string& n1 = "B" , |
11667 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), |
11668 | const std::string& n2 = "C" , |
11669 | typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2)): |
11670 | TupleType(t0,t1,t2), |
11671 | _pNames(0) |
11672 | { |
11673 | init(n0,n1,n2); |
11674 | } |
11675 | |
11676 | const DynamicAny get(const std::string& name) const |
11677 | { |
11678 | NameVec::const_iterator it = _pNames->begin(); |
11679 | NameVec::const_iterator itEnd = _pNames->end(); |
11680 | |
11681 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
11682 | { |
11683 | if (name == *it) |
11684 | { |
11685 | switch (counter) |
11686 | { |
11687 | case 0: return TupleType::template get<0>(); |
11688 | case 1: return TupleType::template get<1>(); |
11689 | case 2: return TupleType::template get<2>(); |
11690 | default: throw RangeException(); |
11691 | } |
11692 | } |
11693 | } |
11694 | |
11695 | throw NotFoundException("Name not found: " + name); |
11696 | } |
11697 | |
11698 | const DynamicAny operator [] (const std::string& name) const |
11699 | { |
11700 | return get(name); |
11701 | } |
11702 | |
11703 | template<int N> |
11704 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
11705 | { |
11706 | return TupleType::template get<N>(); |
11707 | } |
11708 | |
11709 | template<int N> |
11710 | typename TypeGetter<N, Type>::HeadType& get() |
11711 | { |
11712 | return TupleType::template get<N>(); |
11713 | } |
11714 | |
11715 | template<int N> |
11716 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
11717 | { |
11718 | return TupleType::template set<N>(val); |
11719 | } |
11720 | |
11721 | const NameVecPtr& names() |
11722 | { |
11723 | return _pNames; |
11724 | } |
11725 | |
11726 | void setName(std::size_t index, const std::string& name) |
11727 | { |
11728 | if (index >= _pNames->size()) |
11729 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
11730 | |
11731 | (*_pNames)[index] = name; |
11732 | } |
11733 | |
11734 | const std::string& getName(std::size_t index) |
11735 | { |
11736 | if (index >= _pNames->size()) |
11737 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
11738 | |
11739 | return (*_pNames)[index]; |
11740 | } |
11741 | |
11742 | bool operator == (const NamedTuple& other) const |
11743 | { |
11744 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
11745 | } |
11746 | |
11747 | bool operator != (const NamedTuple& other) const |
11748 | { |
11749 | return !(*this == other); |
11750 | } |
11751 | |
11752 | bool operator < (const NamedTuple& other) const |
11753 | { |
11754 | TupleType th(*this); |
11755 | TupleType oth(other); |
11756 | |
11757 | return (th < oth && _pNames == other._pNames) || |
11758 | (th == oth && _pNames < other._pNames) || |
11759 | (th < oth && _pNames < other._pNames); |
11760 | } |
11761 | |
11762 | private: |
11763 | void init(const std::string& n0 = "A" , |
11764 | const std::string& n1 = "B" , |
11765 | const std::string& n2 = "C" ) |
11766 | { |
11767 | if (!_pNames) |
11768 | { |
11769 | _pNames = new NameVec; |
11770 | _pNames->push_back(n0); |
11771 | _pNames->push_back(n1); |
11772 | _pNames->push_back(n2); |
11773 | } |
11774 | } |
11775 | |
11776 | NameVecPtr _pNames; |
11777 | }; |
11778 | |
11779 | |
11780 | template<class T0, |
11781 | class T1> |
11782 | struct NamedTuple<T0,T1,NullTypeList>: |
11783 | public Tuple<T0,T1> |
11784 | { |
11785 | typedef Tuple<T0,T1> TupleType; |
11786 | typedef typename Tuple<T0,T1>::Type Type; |
11787 | |
11788 | typedef std::vector<std::string> NameVec; |
11789 | typedef SharedPtr<NameVec> NameVecPtr; |
11790 | |
11791 | NamedTuple(): _pNames(0) |
11792 | { |
11793 | init(); |
11794 | } |
11795 | |
11796 | NamedTuple(const NameVecPtr& rNames) |
11797 | { |
11798 | if (rNames->size() != TupleType::length) |
11799 | throw InvalidArgumentException("Wrong names vector length." ); |
11800 | |
11801 | _pNames = rNames; |
11802 | } |
11803 | |
11804 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, |
11805 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1)): |
11806 | TupleType(t0,t1), |
11807 | _pNames(0) |
11808 | { |
11809 | init(); |
11810 | } |
11811 | |
11812 | NamedTuple(const NameVecPtr& rNames, |
11813 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
11814 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1)): |
11815 | TupleType(t0,t1) |
11816 | { |
11817 | if (rNames->size() != TupleType::length) |
11818 | throw InvalidArgumentException("Wrong names vector length." ); |
11819 | |
11820 | _pNames = rNames; |
11821 | } |
11822 | |
11823 | NamedTuple(const std::string& n0, |
11824 | typename TypeWrapper<T0>::CONSTTYPE& t0, |
11825 | const std::string& n1 = "B" , |
11826 | typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1)): |
11827 | TupleType(t0,t1), |
11828 | _pNames(0) |
11829 | { |
11830 | init(n0,n1); |
11831 | } |
11832 | |
11833 | const DynamicAny get(const std::string& name) const |
11834 | { |
11835 | NameVec::const_iterator it = _pNames->begin(); |
11836 | NameVec::const_iterator itEnd = _pNames->end(); |
11837 | |
11838 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
11839 | { |
11840 | if (name == *it) |
11841 | { |
11842 | switch (counter) |
11843 | { |
11844 | case 0: return TupleType::template get<0>(); |
11845 | case 1: return TupleType::template get<1>(); |
11846 | default: throw RangeException(); |
11847 | } |
11848 | } |
11849 | } |
11850 | |
11851 | throw NotFoundException("Name not found: " + name); |
11852 | } |
11853 | |
11854 | const DynamicAny operator [] (const std::string& name) const |
11855 | { |
11856 | return get(name); |
11857 | } |
11858 | |
11859 | template<int N> |
11860 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
11861 | { |
11862 | return TupleType::template get<N>(); |
11863 | } |
11864 | |
11865 | template<int N> |
11866 | typename TypeGetter<N, Type>::HeadType& get() |
11867 | { |
11868 | return TupleType::template get<N>(); |
11869 | } |
11870 | |
11871 | template<int N> |
11872 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
11873 | { |
11874 | return TupleType::template set<N>(val); |
11875 | } |
11876 | |
11877 | const NameVecPtr& names() |
11878 | { |
11879 | return _pNames; |
11880 | } |
11881 | |
11882 | void setName(std::size_t index, const std::string& name) |
11883 | { |
11884 | if (index >= _pNames->size()) |
11885 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
11886 | |
11887 | (*_pNames)[index] = name; |
11888 | } |
11889 | |
11890 | const std::string& getName(std::size_t index) |
11891 | { |
11892 | if (index >= _pNames->size()) |
11893 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
11894 | |
11895 | return (*_pNames)[index]; |
11896 | } |
11897 | |
11898 | bool operator == (const NamedTuple& other) const |
11899 | { |
11900 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
11901 | } |
11902 | |
11903 | bool operator != (const NamedTuple& other) const |
11904 | { |
11905 | return !(*this == other); |
11906 | } |
11907 | |
11908 | bool operator < (const NamedTuple& other) const |
11909 | { |
11910 | TupleType th(*this); |
11911 | TupleType oth(other); |
11912 | |
11913 | return (th < oth && _pNames == other._pNames) || |
11914 | (th == oth && _pNames < other._pNames) || |
11915 | (th < oth && _pNames < other._pNames); |
11916 | } |
11917 | |
11918 | private: |
11919 | void init(const std::string& n0 = "A" , |
11920 | const std::string& n1 = "B" ) |
11921 | { |
11922 | if (!_pNames) |
11923 | { |
11924 | _pNames = new NameVec; |
11925 | _pNames->push_back(n0); |
11926 | _pNames->push_back(n1); |
11927 | } |
11928 | } |
11929 | |
11930 | NameVecPtr _pNames; |
11931 | }; |
11932 | |
11933 | |
11934 | template<class T0> |
11935 | struct NamedTuple<T0,NullTypeList>: |
11936 | public Tuple<T0> |
11937 | { |
11938 | typedef Tuple<T0> TupleType; |
11939 | typedef typename Tuple<T0>::Type Type; |
11940 | |
11941 | typedef std::vector<std::string> NameVec; |
11942 | typedef SharedPtr<NameVec> NameVecPtr; |
11943 | |
11944 | NamedTuple(): _pNames(0) |
11945 | { |
11946 | init(); |
11947 | } |
11948 | |
11949 | NamedTuple(const NameVecPtr& rNames) |
11950 | { |
11951 | if (rNames->size() != TupleType::length) |
11952 | throw InvalidArgumentException("Wrong names vector length." ); |
11953 | |
11954 | _pNames = rNames; |
11955 | } |
11956 | |
11957 | NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0): |
11958 | TupleType(t0), |
11959 | _pNames(0) |
11960 | { |
11961 | init(); |
11962 | } |
11963 | |
11964 | NamedTuple(const NameVecPtr& rNames, |
11965 | typename TypeWrapper<T0>::CONSTTYPE& t0): |
11966 | TupleType(t0) |
11967 | { |
11968 | if (rNames->size() != TupleType::length) |
11969 | throw InvalidArgumentException("Wrong names vector length." ); |
11970 | |
11971 | _pNames = rNames; |
11972 | } |
11973 | |
11974 | NamedTuple(const std::string& n0, typename TypeWrapper<T0>::CONSTTYPE& t0): |
11975 | TupleType(t0), |
11976 | _pNames(0) |
11977 | { |
11978 | init(n0); |
11979 | } |
11980 | |
11981 | const DynamicAny get(const std::string& name) const |
11982 | { |
11983 | NameVec::const_iterator it = _pNames->begin(); |
11984 | NameVec::const_iterator itEnd = _pNames->end(); |
11985 | |
11986 | for(std::size_t counter = 0; it != itEnd; ++it, ++counter) |
11987 | { |
11988 | if (name == *it) |
11989 | { |
11990 | switch (counter) |
11991 | { |
11992 | case 0: return TupleType::template get<0>(); |
11993 | default: throw RangeException(); |
11994 | } |
11995 | } |
11996 | } |
11997 | |
11998 | throw NotFoundException("Name not found: " + name); |
11999 | } |
12000 | |
12001 | const DynamicAny operator [] (const std::string& name) const |
12002 | { |
12003 | return get(name); |
12004 | } |
12005 | |
12006 | template<int N> |
12007 | typename TypeGetter<N, Type>::ConstHeadType& get() const |
12008 | { |
12009 | return TupleType::template get<N>(); |
12010 | } |
12011 | |
12012 | template<int N> |
12013 | typename TypeGetter<N, Type>::HeadType& get() |
12014 | { |
12015 | return TupleType::template get<N>(); |
12016 | } |
12017 | |
12018 | template<int N> |
12019 | void set(typename TypeGetter<N, Type>::ConstHeadType& val) |
12020 | { |
12021 | return TupleType::template set<N>(val); |
12022 | } |
12023 | |
12024 | const NameVecPtr& names() |
12025 | { |
12026 | return _pNames; |
12027 | } |
12028 | |
12029 | void setName(std::size_t index, const std::string& name) |
12030 | { |
12031 | if (index >= _pNames->size()) |
12032 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
12033 | |
12034 | (*_pNames)[index] = name; |
12035 | } |
12036 | |
12037 | const std::string& getName(std::size_t index) |
12038 | { |
12039 | if (index >= _pNames->size()) |
12040 | throw InvalidArgumentException(format("Invalid index: %z" , index)); |
12041 | |
12042 | return (*_pNames)[index]; |
12043 | } |
12044 | |
12045 | bool operator == (const NamedTuple& other) const |
12046 | { |
12047 | return TupleType(*this) == TupleType(other) && _pNames == other._pNames; |
12048 | } |
12049 | |
12050 | bool operator != (const NamedTuple& other) const |
12051 | { |
12052 | return !(*this == other); |
12053 | } |
12054 | |
12055 | bool operator < (const NamedTuple& other) const |
12056 | { |
12057 | TupleType th(*this); |
12058 | TupleType oth(other); |
12059 | |
12060 | return (th < oth && _pNames == other._pNames) || |
12061 | (th == oth && _pNames < other._pNames) || |
12062 | (th < oth && _pNames < other._pNames); |
12063 | } |
12064 | |
12065 | private: |
12066 | void init(const std::string& n0 = "A" ) |
12067 | { |
12068 | if (!_pNames) |
12069 | { |
12070 | _pNames = new NameVec; |
12071 | _pNames->push_back(n0); |
12072 | } |
12073 | } |
12074 | |
12075 | NameVecPtr _pNames; |
12076 | }; |
12077 | |
12078 | |
12079 | } // namespace Poco |
12080 | |
12081 | |
12082 | #endif // Foundation_Tuple_INCLUDED |
12083 | |