We now have a current svn snapshot of libqxt in our contrib dir, and
[quassel.git] / src / contrib / libqxt-2007-10-24 / src / core / qxttypelist.h
1 /****************************************************************************
2 **
3 ** Copyright (C) Qxt Foundation. Some rights reserved.
4 **
5 ** This file is part of the QxtCore module of the Qt eXTension library
6 **
7 ** This library is free software; you can redistribute it and/or modify it
8 ** under the terms of th Common Public License, version 1.0, as published by
9 ** IBM.
10 **
11 ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY
12 ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
13 ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
14 ** FITNESS FOR A PARTICULAR PURPOSE.
15 **
16 ** You should have received a copy of the CPL along with this file.
17 ** See the LICENSE file and the cpl1.0.txt file included with the source
18 ** distribution for more information. If you did not receive a copy of the
19 ** license, contact the Qxt Foundation.
20 **
21 ** <http://libqxt.sourceforge.net>  <foundation@libqxt.org>
22 **
23 ****************************************************************************/
24 #ifndef QXTTYPELIST_H
25 #define QXTTYPELIST_H
26 #include <qxtnull.h>
27
28 namespace QxtType
29 {
30 struct NoExtend
31 {
32     typedef QxtNull head;
33     enum { length = 0, extends = false };
34 };
35
36 template <typename T1 = QxtNull, typename T2 = QxtNull, typename T3 = QxtNull, typename T4 = QxtNull, typename T5 = QxtNull,
37 typename T6 = QxtNull, typename T7 = QxtNull, typename T8 = QxtNull, typename T9 = QxtNull, typename EXTEND = QxtType::NoExtend>
38 struct QxtTypeList;
39
40 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename EXTEND>
41 struct QxtTypeList
42 {
43     typedef T1 head;
44     typedef QxtTypeList<T2, T3, T4, T5, T6, T7, T8, T9, NoExtend, EXTEND> tail;
45     typedef EXTEND extend;
46     enum { length = tail::length + 1, extends = EXTEND::extends };
47 };
48
49 template<typename EXTEND>
50 struct QxtTypeList<NoExtend, NoExtend, NoExtend, NoExtend, NoExtend, NoExtend, NoExtend, NoExtend, NoExtend, EXTEND>
51 {
52     typedef typename EXTEND::head head;
53     typedef typename EXTEND::tail tail;
54     typedef EXTEND extend;
55     enum { length = EXTEND::length, extends = EXTEND::extends };
56 };
57
58 template<>
59 struct QxtTypeList<NoExtend, NoExtend, NoExtend, NoExtend, NoExtend, NoExtend, NoExtend, NoExtend, NoExtend, QxtType::NoExtend>
60 {
61     typedef QxtNull extend;
62     enum { length = 0, extends = false };
63 };
64 }
65
66 #ifndef QXT_NO_USING
67 using QxtType::QxtTypeList;
68 #endif
69
70 #ifndef QXT_NO_MACROS
71 /*! \relates QxtTypeList
72  * Declares a one-column tuple.
73  */
74 #define Qxt1TypeList(a) QxtTypeList<a >
75
76 /*! \relates QxtTypeList
77  * Declares a two-column tuple, similar to QPair.
78  */
79 #define Qxt2TypeList(a, b) QxtTypeList<a, b >
80
81 /*! \relates QxtTypeList
82  * Declares a three-column tuple, similar to QxtTriple.
83  */
84 #define Qxt3TypeList(a, b, c) QxtTypeList<a, b, c >
85
86 /*! \relates QxtTypeList
87  * Declares a four-column tuple.
88  */
89 #define Qxt4TypeList(a, b, c, d) QxtTypeList<a, b, c, d >
90
91 /*! \relates QxtTypeList
92  * Declares a five-column tuple.
93  */
94 #define Qxt5TypeList(a, b, c, d, e) QxtTypeList<a, b, c, d, e >
95
96 /*! \relates QxtTypeList
97  * Declares a six-column tuple.
98  */
99 #define Qxt6TypeList(a, b, c, d, e, f) QxtTypeList<a, b, c, d, e, f >
100
101 /*! \relates QxtTypeList
102  * Declares a seven-column tuple.
103  */
104 #define Qxt7TypeList(a, b, c, d, e, f, g) QxtTypeList<a, b, c, d, e, f, g >
105
106 /*! \relates QxtTypeList
107  * Declares an eight-column tuple.
108  */
109 #define Qxt8TypeList(a, b, c, d, e, f, g, h) QxtTypeList<a, b, c, d, e, f, g, h >
110
111 /*! \relates QxtTypeList
112  * Declares a nine-column tuple.
113  */
114 #define Qxt9TypeList(a, b, c, d, e, f, g, h, i) QxtTypeList<a, b, c, d, e, f, g, h, i >
115
116 /*! \relates QxtTypeList
117  * Declares an extended tuple with ten or more columns. Pay special attention to the syntax of the tenth parameter, which
118  * must be a QxtTypeList, not a storage type.
119 \code
120 QxtLongTypeList(int, int, int, int, int, int, int, int, int, Qxt1TypeList(int)) tuple; // correct way to implement a 10-tuple
121 QxtLongTypeList(int, int, int, int, int, int, int, int, int, int) tuple;              // this will produce a (very long) compile-time error
122 \endcode
123  */
124 #define QxtLongTypeList(a, b, c, d, e, f, g, h, i, extend) QxtTypeList<a, b, c, d, e, f, g, h, i, extend >
125 #endif
126
127 #endif