Warning, file /include/boost/spirit/home/support/nonterminal/extract_param.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009 #if !defined(BOOST_SPIRIT_EXTRACT_PARAM_AUGUST_08_2009_0848AM)
0010 #define BOOST_SPIRIT_EXTRACT_PARAM_AUGUST_08_2009_0848AM
0011
0012 #if defined(_MSC_VER)
0013 #pragma once
0014 #endif
0015
0016 #include <boost/spirit/home/support/meta_compiler.hpp>
0017 #include <boost/spirit/home/support/nonterminal/locals.hpp>
0018 #include <boost/spirit/home/support/unused.hpp>
0019 #include <boost/spirit/home/support/common_terminals.hpp>
0020
0021 #include <boost/function_types/is_function.hpp>
0022 #include <boost/function_types/parameter_types.hpp>
0023 #include <boost/function_types/result_type.hpp>
0024 #include <boost/fusion/include/as_list.hpp>
0025 #include <boost/fusion/include/as_vector.hpp>
0026 #include <boost/mpl/deref.hpp>
0027 #include <boost/mpl/end.hpp>
0028 #include <boost/mpl/eval_if.hpp>
0029 #include <boost/mpl/find_if.hpp>
0030 #include <boost/mpl/identity.hpp>
0031 #include <boost/mpl/if.hpp>
0032 #include <boost/mpl/or.hpp>
0033 #include <boost/mpl/and.hpp>
0034 #include <boost/mpl/placeholders.hpp>
0035 #include <boost/type_traits/is_same.hpp>
0036
0037 namespace boost { namespace spirit { namespace detail
0038 {
0039
0040
0041
0042
0043 template <typename Types, typename Pred, typename Default>
0044 struct extract_param
0045 {
0046 typedef typename mpl::find_if<Types, Pred>::type pos;
0047
0048 typedef typename
0049 mpl::eval_if<
0050 is_same<pos, typename mpl::end<Types>::type>
0051 , mpl::identity<Default>
0052 , mpl::deref<pos>
0053 >::type
0054 type;
0055 };
0056
0057
0058 template <typename Types>
0059 struct extract_locals
0060 : fusion::result_of::as_vector<
0061 typename extract_param<
0062 Types
0063 , is_locals<mpl::_>
0064 , locals<>
0065 >::type
0066 >
0067 {};
0068
0069
0070 template <typename Domain, typename Types>
0071 struct extract_component
0072 : spirit::result_of::compile<
0073 Domain
0074 , typename extract_param<
0075 Types
0076 , traits::matches<Domain, mpl::_>
0077 , unused_type
0078 >::type
0079 >
0080 {};
0081
0082
0083 template <typename T>
0084 struct make_function_type : mpl::identity<T()> {};
0085
0086
0087 template <typename Types, typename Encoding, typename Domain>
0088 struct extract_sig
0089 {
0090 typedef typename
0091 extract_param<
0092 Types
0093 , mpl::or_<
0094 function_types::is_function<mpl::_>
0095 , mpl::and_<
0096 mpl::not_<is_locals<mpl::_> >
0097 , mpl::not_<is_same<mpl::_, Encoding> >
0098 , mpl::not_<traits::matches<Domain, mpl::_> >
0099 , mpl::not_<is_same<mpl::_, unused_type> >
0100 >
0101 >
0102 , void()
0103 >::type
0104 attr_of_ftype;
0105
0106 typedef typename
0107 mpl::eval_if<
0108 function_types::is_function<attr_of_ftype>
0109 , mpl::identity<attr_of_ftype>
0110 , make_function_type<attr_of_ftype>
0111 >::type
0112 type;
0113 };
0114
0115 template <typename Sig>
0116 struct attr_from_sig
0117 {
0118 typedef typename function_types::result_type<Sig>::type attr;
0119
0120 typedef typename
0121 mpl::if_<
0122 is_same<attr, void>
0123 , unused_type
0124 , attr
0125 >::type
0126 type;
0127 };
0128
0129 template <typename Sig>
0130 struct params_from_sig
0131 {
0132 typedef typename function_types::parameter_types<Sig>::type params;
0133
0134 typedef typename fusion::result_of::as_list<params>::type type;
0135 };
0136
0137
0138 template <typename Types>
0139 struct extract_encoding
0140 : extract_param<
0141 Types
0142 , is_char_encoding<mpl::_>
0143 , unused_type
0144 >
0145 {};
0146 }}}
0147
0148 #endif