mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-29 12:18:01 +01:00
Removed TYPELIST_... macros
This commit is contained in:
@@ -143,39 +143,6 @@ struct TypeList
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define POCO_TYPELIST_1(T0) TypeList<T0, NullTypeList>
|
|
||||||
#define POCO_TYPELIST_2(T0, T1) TypeList<T0, POCO_TYPELIST_1(T1) >
|
|
||||||
#define POCO_TYPELIST_3(T0, T1, T2) TypeList<T0, POCO_TYPELIST_2(T1, T2) >
|
|
||||||
#define POCO_TYPELIST_4(T0, T1, T2, T3) TypeList<T0, POCO_TYPELIST_3(T1, T2, T3) >
|
|
||||||
#define POCO_TYPELIST_5(T0, T1, T2, T3, T4) TypeList<T0, POCO_TYPELIST_4(T1, T2, T3, T4) >
|
|
||||||
#define POCO_TYPELIST_6(T0, T1, T2, T3, T4, T5) TypeList<T0, POCO_TYPELIST_5(T1, T2, T3, T4, T5) >
|
|
||||||
#define POCO_TYPELIST_7(T0, T1, T2, T3, T4, T5, T6) TypeList<T0, POCO_TYPELIST_6(T1, T2, T3, T4, T5, T6) >
|
|
||||||
#define POCO_TYPELIST_8(T0, T1, T2, T3, T4, T5, T6, T7) TypeList<T0, POCO_TYPELIST_7(T1, T2, T3, T4, T5, T6, T7) >
|
|
||||||
#define POCO_TYPELIST_9(T0, T1, T2, T3, T4, T5, T6, T7, T8) TypeList<T0, POCO_TYPELIST_8(T1, T2, T3, T4, T5, T6, T7, T8) >
|
|
||||||
#define POCO_TYPELIST_10(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9) \
|
|
||||||
TypeList<T0, POCO_TYPELIST_9(T1, T2, T3, T4, T5, T6, T7, T8, T9) >
|
|
||||||
#define POCO_TYPELIST_11(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) \
|
|
||||||
TypeList<T0, POCO_TYPELIST_10(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) >
|
|
||||||
#define POCO_TYPELIST_12(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) \
|
|
||||||
TypeList<T0, POCO_TYPELIST_11(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) >
|
|
||||||
#define POCO_TYPELIST_13(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) \
|
|
||||||
TypeList<T0, POCO_TYPELIST_12(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) >
|
|
||||||
#define POCO_TYPELIST_14(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) \
|
|
||||||
TypeList<T0, POCO_TYPELIST_13(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) >
|
|
||||||
#define POCO_TYPELIST_15(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) \
|
|
||||||
TypeList<T0, POCO_TYPELIST_14(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) >
|
|
||||||
#define POCO_TYPELIST_16(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) \
|
|
||||||
TypeList<T0, POCO_TYPELIST_15(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) >
|
|
||||||
#define POCO_TYPELIST_17(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) \
|
|
||||||
TypeList<T0, POCO_TYPELIST_16(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) >
|
|
||||||
#define POCO_TYPELIST_18(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17) \
|
|
||||||
TypeList<T0, POCO_TYPELIST_17(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17) >
|
|
||||||
#define POCO_TYPELIST_19(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18) \
|
|
||||||
TypeList<T0, POCO_TYPELIST_18(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18) >
|
|
||||||
#define POCO_TYPELIST_20(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19) \
|
|
||||||
TypeList<T0, POCO_TYPELIST_19(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19) >
|
|
||||||
|
|
||||||
|
|
||||||
template <typename T0 = NullTypeList,
|
template <typename T0 = NullTypeList,
|
||||||
typename T1 = NullTypeList,
|
typename T1 = NullTypeList,
|
||||||
typename T2 = NullTypeList,
|
typename T2 = NullTypeList,
|
||||||
@@ -336,7 +303,7 @@ struct TypeAppender<NullTypeList, NullTypeList>
|
|||||||
template <class T>
|
template <class T>
|
||||||
struct TypeAppender<NullTypeList, T>
|
struct TypeAppender<NullTypeList, T>
|
||||||
{
|
{
|
||||||
typedef POCO_TYPELIST_1(T) HeadType;
|
typedef TypeList<T, NullTypeList> HeadType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include "CppUnit/TestSuite.h"
|
#include "CppUnit/TestSuite.h"
|
||||||
#include "Poco/Tuple.h"
|
#include "Poco/Tuple.h"
|
||||||
#include "Poco/Void.h"
|
#include "Poco/Void.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
using Poco::TypeList;
|
using Poco::TypeList;
|
||||||
@@ -475,6 +476,45 @@ void TuplesTest::testTuple20()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TuplesTest::testTupleOrder()
|
||||||
|
{
|
||||||
|
typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int,
|
||||||
|
std::string, int, bool, float, char, long, double, short, std::string, int> TupleType;
|
||||||
|
|
||||||
|
TupleType aTuple;
|
||||||
|
assert (aTuple.length == 20);
|
||||||
|
|
||||||
|
TupleType aTuple2("1", 1, true, 3.14f, 'c', 999, 33.14, 32700, "2", 2, "1", 1, true, 3.14f, 'c', 999, 33.14, 32700, "2", 2);
|
||||||
|
assert (aTuple != aTuple2);
|
||||||
|
aTuple = aTuple2;
|
||||||
|
assert (aTuple == aTuple2);
|
||||||
|
aTuple2.get<1>()++;
|
||||||
|
assert (aTuple < aTuple2);
|
||||||
|
|
||||||
|
TupleType aTuple3;
|
||||||
|
aTuple3 = aTuple2;
|
||||||
|
aTuple3.get<1>()++;
|
||||||
|
assert (aTuple2 < aTuple3);
|
||||||
|
|
||||||
|
testTupleStrictWeak(aTuple, aTuple2, aTuple3);
|
||||||
|
|
||||||
|
std::vector<TupleType> tv;
|
||||||
|
tv.push_back(aTuple3);
|
||||||
|
tv.push_back(aTuple);
|
||||||
|
tv.push_back(aTuple2);
|
||||||
|
|
||||||
|
assert (tv[0] == aTuple3);
|
||||||
|
assert (tv[1] == aTuple);
|
||||||
|
assert (tv[2] == aTuple2);
|
||||||
|
|
||||||
|
std::sort(tv.begin(), tv.end());
|
||||||
|
|
||||||
|
assert (tv[0] == aTuple);
|
||||||
|
assert (tv[1] == aTuple2);
|
||||||
|
assert (tv[2] == aTuple3);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void TuplesTest::testMemOverhead()
|
void TuplesTest::testMemOverhead()
|
||||||
{
|
{
|
||||||
Tuple<short> small(0);
|
Tuple<short> small(0);
|
||||||
@@ -520,6 +560,7 @@ CppUnit::Test* TuplesTest::suite()
|
|||||||
CppUnit_addTest(pSuite, TuplesTest, testTuple18);
|
CppUnit_addTest(pSuite, TuplesTest, testTuple18);
|
||||||
CppUnit_addTest(pSuite, TuplesTest, testTuple19);
|
CppUnit_addTest(pSuite, TuplesTest, testTuple19);
|
||||||
CppUnit_addTest(pSuite, TuplesTest, testTuple20);
|
CppUnit_addTest(pSuite, TuplesTest, testTuple20);
|
||||||
|
CppUnit_addTest(pSuite, TuplesTest, testTupleOrder);
|
||||||
CppUnit_addTest(pSuite, TuplesTest, testMemOverhead);
|
CppUnit_addTest(pSuite, TuplesTest, testMemOverhead);
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ public:
|
|||||||
void testTuple18();
|
void testTuple18();
|
||||||
void testTuple19();
|
void testTuple19();
|
||||||
void testTuple20();
|
void testTuple20();
|
||||||
|
void testTupleOrder();
|
||||||
void testMemOverhead();
|
void testMemOverhead();
|
||||||
void setUp();
|
void setUp();
|
||||||
void tearDown();
|
void tearDown();
|
||||||
@@ -73,6 +74,14 @@ public:
|
|||||||
static CppUnit::Test* suite();
|
static CppUnit::Test* suite();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void testTupleStrictWeak(const T& t1, const T& t2, const T& t3)
|
||||||
|
{
|
||||||
|
assert (t1 < t2 && !(t2 < t1)); // antisymmetric
|
||||||
|
assert (t1 < t2 && t2 < t3 && t1 < t3); // transitive
|
||||||
|
assert (!(t1 < t1)); // irreflexive
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -78,159 +78,7 @@ TypeListTest::~TypeListTest()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TypeListTest::testTypeListMacro()
|
void TypeListTest::testTypeList()
|
||||||
{
|
|
||||||
typedef POCO_TYPELIST_15(Int8,
|
|
||||||
UInt8,
|
|
||||||
Int16,
|
|
||||||
UInt16,
|
|
||||||
Int32,
|
|
||||||
UInt32,
|
|
||||||
float,
|
|
||||||
double,
|
|
||||||
Int8,
|
|
||||||
UInt8,
|
|
||||||
Int16,
|
|
||||||
UInt16,
|
|
||||||
Int32,
|
|
||||||
UInt32,
|
|
||||||
float) Type15;
|
|
||||||
|
|
||||||
Tuple<TypeGetter<0, Type15>::HeadType,
|
|
||||||
TypeGetter<1, Type15>::HeadType,
|
|
||||||
TypeGetter<2, Type15>::HeadType,
|
|
||||||
TypeGetter<3, Type15>::HeadType,
|
|
||||||
TypeGetter<4, Type15>::HeadType,
|
|
||||||
TypeGetter<5, Type15>::HeadType,
|
|
||||||
TypeGetter<6, Type15>::HeadType,
|
|
||||||
TypeGetter<7, Type15>::HeadType,
|
|
||||||
TypeGetter<8, Type15>::HeadType,
|
|
||||||
TypeGetter<9, Type15>::HeadType> tuple;
|
|
||||||
|
|
||||||
static TypeLocator<Type15, Int8> pos0;
|
|
||||||
static TypeLocator<Type15, UInt8> pos1;
|
|
||||||
static TypeLocator<Type15, Int16> pos2;
|
|
||||||
static TypeLocator<Type15, UInt16> pos3;
|
|
||||||
static TypeLocator<Type15, Int32> pos4;
|
|
||||||
static TypeLocator<Type15, UInt32> pos5;
|
|
||||||
static TypeLocator<Type15, float> pos6;
|
|
||||||
static TypeLocator<Type15, double> pos7;
|
|
||||||
static TypeLocator<Type15, Int8> pos8;
|
|
||||||
static TypeLocator<Type15, std::string> posUnknown;
|
|
||||||
|
|
||||||
assert (pos0.value == 0);
|
|
||||||
assert (pos1.value == 1);
|
|
||||||
assert (pos2.value == 2);
|
|
||||||
assert (pos3.value == 3);
|
|
||||||
assert (pos4.value == 4);
|
|
||||||
assert (pos5.value == 5);
|
|
||||||
assert (pos6.value == 6);
|
|
||||||
assert (pos7.value == 7);
|
|
||||||
assert (pos8.value == 0);
|
|
||||||
assert (posUnknown.value == -1);
|
|
||||||
|
|
||||||
tuple.set<TypeLocator<Type15, Int32>::value >(-123);
|
|
||||||
assert (-123 == tuple.get<4>());
|
|
||||||
|
|
||||||
assert (typeid(TypeGetter<0, Type15>::HeadType) == typeid(Int8));
|
|
||||||
assert (typeid(TypeGetter<0, Type15>::ConstHeadType) == typeid(const Int8));
|
|
||||||
assert (typeid(TypeGetter<1, Type15>::HeadType) == typeid(UInt8));
|
|
||||||
assert (typeid(TypeGetter<1, Type15>::ConstHeadType) == typeid(const UInt8));
|
|
||||||
assert (typeid(TypeGetter<2, Type15>::HeadType) == typeid(Int16));
|
|
||||||
assert (typeid(TypeGetter<2, Type15>::ConstHeadType) == typeid(const Int16));
|
|
||||||
assert (typeid(TypeGetter<3, Type15>::HeadType) == typeid(UInt16));
|
|
||||||
assert (typeid(TypeGetter<3, Type15>::ConstHeadType) == typeid(const UInt16));
|
|
||||||
assert (typeid(TypeGetter<4, Type15>::HeadType) == typeid(Int32));
|
|
||||||
assert (typeid(TypeGetter<4, Type15>::ConstHeadType) == typeid(const Int32));
|
|
||||||
assert (typeid(TypeGetter<5, Type15>::HeadType) == typeid(UInt32));
|
|
||||||
assert (typeid(TypeGetter<5, Type15>::ConstHeadType) == typeid(const UInt32));
|
|
||||||
assert (typeid(TypeGetter<6, Type15>::HeadType) == typeid(float));
|
|
||||||
assert (typeid(TypeGetter<6, Type15>::ConstHeadType) == typeid(const float));
|
|
||||||
assert (typeid(TypeGetter<7, Type15>::HeadType) == typeid(double));
|
|
||||||
assert (typeid(TypeGetter<7, Type15>::ConstHeadType) == typeid(const double));
|
|
||||||
assert (typeid(TypeGetter<8, Type15>::HeadType) == typeid(Int8));
|
|
||||||
assert (typeid(TypeGetter<8, Type15>::ConstHeadType) == typeid(const Int8));
|
|
||||||
assert (typeid(TypeGetter<9, Type15>::HeadType) == typeid(UInt8));
|
|
||||||
assert (typeid(TypeGetter<9, Type15>::ConstHeadType) == typeid(const UInt8));
|
|
||||||
assert (typeid(TypeGetter<10, Type15>::HeadType) == typeid(Int16));
|
|
||||||
assert (typeid(TypeGetter<10, Type15>::ConstHeadType) == typeid(const Int16));
|
|
||||||
assert (typeid(TypeGetter<11, Type15>::HeadType) == typeid(UInt16));
|
|
||||||
assert (typeid(TypeGetter<11, Type15>::ConstHeadType) == typeid(const UInt16));
|
|
||||||
assert (typeid(TypeGetter<12, Type15>::HeadType) == typeid(Int32));
|
|
||||||
assert (typeid(TypeGetter<12, Type15>::ConstHeadType) == typeid(const Int32));
|
|
||||||
assert (typeid(TypeGetter<13, Type15>::HeadType) == typeid(UInt32));
|
|
||||||
assert (typeid(TypeGetter<13, Type15>::ConstHeadType) == typeid(const UInt32));
|
|
||||||
assert (typeid(TypeGetter<14, Type15>::HeadType) == typeid(float));
|
|
||||||
assert (typeid(TypeGetter<14, Type15>::ConstHeadType) == typeid(const float));
|
|
||||||
|
|
||||||
typedef POCO_TYPELIST_1(Int8) Type1;
|
|
||||||
assert (1 == Type1::length);
|
|
||||||
typedef POCO_TYPELIST_2(Int16, Int32) Type2;
|
|
||||||
assert (2 == Type2::length);
|
|
||||||
typedef TypeAppender<Type1, Type2>::HeadType Type3;
|
|
||||||
assert (3 == Type3::length);
|
|
||||||
|
|
||||||
assert (typeid(TypeGetter<0, Type3>::HeadType) == typeid(Int8));
|
|
||||||
assert (typeid(TypeGetter<1, Type3>::HeadType) == typeid(Int16));
|
|
||||||
assert (typeid(TypeGetter<2, Type3>::HeadType) == typeid(Int32));
|
|
||||||
|
|
||||||
static TypeLocator<Type3, Int8> posNo1;
|
|
||||||
static TypeLocator<Type3, Int16> posNo2;
|
|
||||||
static TypeLocator<Type3, Int32> posNo3;
|
|
||||||
|
|
||||||
assert (posNo1.value == 0);
|
|
||||||
assert (posNo2.value == 1);
|
|
||||||
assert (posNo3.value == 2);
|
|
||||||
|
|
||||||
typedef TypeOneEraser<Type3, Int8>::HeadType TypeEraser1;
|
|
||||||
assert (2 == TypeEraser1::length);
|
|
||||||
assert (typeid(TypeGetter<0, TypeEraser1>::HeadType) == typeid(Int16));
|
|
||||||
assert (typeid(TypeGetter<1, TypeEraser1>::HeadType) == typeid(Int32));
|
|
||||||
|
|
||||||
typedef TypeOneEraser<Type3, Int16>::HeadType TypeEraser2;
|
|
||||||
assert (2 == TypeEraser2::length);
|
|
||||||
assert (typeid(TypeGetter<0, TypeEraser2>::HeadType) == typeid(Int8));
|
|
||||||
assert (typeid(TypeGetter<1, TypeEraser2>::HeadType) == typeid(Int32));
|
|
||||||
|
|
||||||
typedef TypeOneEraser<Type3, Int32>::HeadType TypeEraser3;
|
|
||||||
assert (2 == TypeEraser3::length);
|
|
||||||
assert (typeid(TypeGetter<0, TypeEraser3>::HeadType) == typeid(Int8));
|
|
||||||
assert (typeid(TypeGetter<1, TypeEraser3>::HeadType) == typeid(Int16));
|
|
||||||
|
|
||||||
typedef POCO_TYPELIST_5(Int8,
|
|
||||||
Int16,
|
|
||||||
Int8,
|
|
||||||
Int16,
|
|
||||||
Int8) Type5;
|
|
||||||
typedef TypeAllEraser<Type5, Int8>::HeadType TypeAllEraser3;
|
|
||||||
assert (2 == TypeAllEraser3::length);
|
|
||||||
assert (typeid(TypeGetter<0, TypeAllEraser3>::HeadType) == typeid(Int16));
|
|
||||||
assert (typeid(TypeGetter<1, TypeAllEraser3>::HeadType) == typeid(Int16));
|
|
||||||
|
|
||||||
typedef TypeDuplicateEraser<Type5>::HeadType TypeDuplicateEraser1;
|
|
||||||
assert (2 == TypeDuplicateEraser1::length);
|
|
||||||
assert (typeid(TypeGetter<0, TypeDuplicateEraser1>::HeadType) == typeid(Int8));
|
|
||||||
assert (typeid(TypeGetter<1, TypeDuplicateEraser1>::HeadType) == typeid(Int16));
|
|
||||||
|
|
||||||
typedef TypeOneReplacer<Type5, Int8, Int32>::HeadType TypeOneReplacer1;
|
|
||||||
assert (5 == TypeOneReplacer1::length);
|
|
||||||
assert (typeid(TypeGetter<0, TypeOneReplacer1>::HeadType) == typeid(Int32));
|
|
||||||
assert (typeid(TypeGetter<1, TypeOneReplacer1>::HeadType) == typeid(Int16));
|
|
||||||
assert (typeid(TypeGetter<2, TypeOneReplacer1>::HeadType) == typeid(Int8));
|
|
||||||
assert (typeid(TypeGetter<3, TypeOneReplacer1>::HeadType) == typeid(Int16));
|
|
||||||
assert (typeid(TypeGetter<4, TypeOneReplacer1>::HeadType) == typeid(Int8));
|
|
||||||
|
|
||||||
typedef TypeAllReplacer<Type5, Int8, Int32>::HeadType TypeAllReplacer1;
|
|
||||||
assert (5 == TypeAllReplacer1::length);
|
|
||||||
assert (typeid(TypeGetter<0, TypeAllReplacer1>::HeadType) == typeid(Int32));
|
|
||||||
assert (typeid(TypeGetter<1, TypeAllReplacer1>::HeadType) == typeid(Int16));
|
|
||||||
assert (typeid(TypeGetter<2, TypeAllReplacer1>::HeadType) == typeid(Int32));
|
|
||||||
assert (typeid(TypeGetter<3, TypeAllReplacer1>::HeadType) == typeid(Int16));
|
|
||||||
assert (typeid(TypeGetter<4, TypeAllReplacer1>::HeadType) == typeid(Int32));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void TypeListTest::testTypeListTemplate()
|
|
||||||
{
|
{
|
||||||
typedef TypeListType<Int8,
|
typedef TypeListType<Int8,
|
||||||
UInt8,
|
UInt8,
|
||||||
@@ -469,8 +317,7 @@ CppUnit::Test* TypeListTest::suite()
|
|||||||
{
|
{
|
||||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("TypeListTest");
|
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("TypeListTest");
|
||||||
|
|
||||||
CppUnit_addTest(pSuite, TypeListTest, testTypeListMacro);
|
CppUnit_addTest(pSuite, TypeListTest, testTypeList);
|
||||||
CppUnit_addTest(pSuite, TypeListTest, testTypeListTemplate);
|
|
||||||
|
|
||||||
return pSuite;
|
return pSuite;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,8 +46,7 @@ public:
|
|||||||
TypeListTest(const std::string& name);
|
TypeListTest(const std::string& name);
|
||||||
~TypeListTest();
|
~TypeListTest();
|
||||||
|
|
||||||
void testTypeListMacro();
|
void testTypeList();
|
||||||
void testTypeListTemplate();
|
|
||||||
void setUp();
|
void setUp();
|
||||||
void tearDown();
|
void tearDown();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user