7 #ifndef __FWTOOLS_TYPEMAPPING_HPP__ 8 #define __FWTOOLS_TYPEMAPPING_HPP__ 10 #include <boost/mpl/bool.hpp> 11 #include <boost/mpl/empty.hpp> 12 #include <boost/mpl/front.hpp> 13 #include <boost/mpl/if.hpp> 14 #include <boost/mpl/is_sequence.hpp> 15 #include <boost/mpl/pop_front.hpp> 16 #include <boost/mpl/size.hpp> 17 #include <boost/static_assert.hpp> 26 template<
class TSEQ,
class KeyTypeContainer >
29 template<
class T,
class KeyType >
55 template<
class TSingle_or_TSEQ,
class KeyType_or_KeyTypeContainer >
56 bool isMapping(
const KeyType_or_KeyTypeContainer& key)
58 namespace mpl = ::boost::mpl;
59 typedef BOOST_DEDUCED_TYPENAME mpl::if_<
60 mpl::is_sequence< TSingle_or_TSEQ >,
64 return typex::evaluate(key);
75 template<
class T,
class KeyType >
82 FwCoreNotUsedMacro(key);
83 BOOST_STATIC_ASSERT(
sizeof(T) == 0);
86 std::string msg(
"isMapping<TYPE>::(const KEYTYPE &key) not specializated for TYPE and/or KEYTYPE!!!");
87 throw std::invalid_argument(msg);
97 template<
class TSEQ,
class KeyTypeContainer >
106 template<
class KeyTypeContainer >
111 static bool evaluate(
typename KeyTypeContainer::const_iterator& begin,
112 typename KeyTypeContainer::const_iterator& end)
114 assert( begin == end );
124 template<
class TSEQ,
class KeyTypeContainer >
128 static bool evaluate(
typename KeyTypeContainer::const_iterator& begin,
129 typename KeyTypeContainer::const_iterator& end);
133 static bool evaluate(
const KeyTypeContainer& keys)
136 namespace mpl = ::boost::mpl;
138 if ( keys.size() !=
static_cast<unsigned long>(mpl::size<TSEQ>::value) )
140 std::string msg(
"isMappingMulti TypeList & KeyType container does not have the same size !!!");
141 throw std::invalid_argument(msg);
145 typename KeyTypeContainer::const_iterator begin = keys.begin();
146 typename KeyTypeContainer::const_iterator end = keys.end();
155 template<
class TSEQ,
class KeyTypeContainer >
158 typename KeyTypeContainer::const_iterator& end)
160 namespace mpl = ::boost::mpl;
162 typedef BOOST_DEDUCED_TYPENAME mpl::front<TSEQ>::type Head;
163 typedef BOOST_DEDUCED_TYPENAME mpl::pop_front<TSEQ>::type Tail;
165 typedef BOOST_DEDUCED_TYPENAME mpl::if_<
171 bool firstKeyIsOK = isMapping< Head >( *begin );
173 if ( firstKeyIsOK ==
false )
178 bool otherKeys = typex::evaluate( ++begin, end );
179 return firstKeyIsOK && otherKeys;