2005-12-07 11:51:00 +01:00
|
|
|
#ifndef ARABICA_UTILS_GET_PARAM_HPP
|
|
|
|
#define ARABICA_UTILS_GET_PARAM_HPP
|
|
|
|
|
2011-11-26 00:26:39 +01:00
|
|
|
#ifdef ARABICA_HAVE_BOOST
|
2005-12-07 11:51:00 +01:00
|
|
|
#include <boost/mpl/if.hpp>
|
|
|
|
#include <boost/type_traits/is_base_and_derived.hpp>
|
2006-09-13 23:56:21 +02:00
|
|
|
#endif
|
2005-12-07 11:51:00 +01:00
|
|
|
|
|
|
|
namespace Arabica
|
|
|
|
{
|
|
|
|
|
2006-09-13 23:56:21 +02:00
|
|
|
struct nil_t { };
|
|
|
|
|
2011-11-26 00:26:39 +01:00
|
|
|
#ifdef ARABICA_HAVE_BOOST
|
2005-12-07 11:51:00 +01:00
|
|
|
template <typename BaseT, typename DefaultT, typename T0, typename T1>
|
|
|
|
struct get_param
|
|
|
|
{
|
|
|
|
typedef typename boost::mpl::if_<
|
|
|
|
boost::is_base_and_derived<BaseT, T0>
|
|
|
|
, T0
|
|
|
|
, typename boost::mpl::if_<
|
|
|
|
boost::is_base_and_derived<BaseT, T1>
|
|
|
|
, T1
|
|
|
|
, DefaultT
|
|
|
|
>::type
|
|
|
|
>::type type;
|
|
|
|
}; // get_param
|
2006-09-13 23:56:21 +02:00
|
|
|
#else
|
2008-06-26 15:34:00 +02:00
|
|
|
template <typename T0, typename DefaultT>
|
|
|
|
struct chosen_type { typedef T0 type; };
|
|
|
|
|
|
|
|
template <typename DefaultT>
|
|
|
|
struct chosen_type<Arabica::nil_t, DefaultT> { typedef DefaultT type; };
|
|
|
|
|
2006-09-13 23:56:21 +02:00
|
|
|
template <typename BaseT, typename DefaultT, typename T0, typename T1>
|
|
|
|
struct get_param
|
|
|
|
{
|
2008-06-26 15:34:00 +02:00
|
|
|
typedef typename chosen_type<T0, DefaultT>::type type;
|
2006-09-13 23:56:21 +02:00
|
|
|
};
|
|
|
|
#endif
|
2005-12-07 11:51:00 +01:00
|
|
|
|
2008-07-16 10:08:59 +02:00
|
|
|
template <typename string_type, typename T0, typename T1>
|
|
|
|
struct get_string_adaptor
|
|
|
|
{
|
|
|
|
typedef typename get_param<Arabica::string_adaptor_tag,
|
|
|
|
Arabica::default_string_adaptor<string_type>,
|
|
|
|
T0,
|
|
|
|
T1>::type type;
|
|
|
|
};
|
|
|
|
|
2005-12-07 11:51:00 +01:00
|
|
|
} // namespace Arabica
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|