PageRenderTime 16ms CodeModel.GetById 9ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/spirit/home/support/nonterminal/extract_param.hpp

http://hadesmem.googlecode.com/
C++ Header | 123 lines | 93 code | 14 blank | 16 comment | 0 complexity | 8b35a81c867726a7bf5d64c81d0944e9 MD5 | raw file
  1/*=============================================================================
  2    Copyright (c) 2001-2011 Joel de Guzman
  3    Copyright (c) 2001-2011 Hartmut Kaiser
  4    Copyright (c) 2009 Francois Barel
  5
  6    Distributed under the Boost Software License, Version 1.0. (See accompanying
  7    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  8==============================================================================*/
  9#if !defined(BOOST_SPIRIT_EXTRACT_PARAM_AUGUST_08_2009_0848AM)
 10#define BOOST_SPIRIT_EXTRACT_PARAM_AUGUST_08_2009_0848AM
 11
 12#if defined(_MSC_VER)
 13#pragma once
 14#endif
 15
 16#include <boost/spirit/home/support/meta_compiler.hpp>
 17#include <boost/spirit/home/support/nonterminal/locals.hpp>
 18#include <boost/spirit/home/support/unused.hpp>
 19#include <boost/spirit/home/support/common_terminals.hpp>
 20
 21#include <boost/function_types/is_function.hpp>
 22#include <boost/function_types/parameter_types.hpp>
 23#include <boost/function_types/result_type.hpp>
 24#include <boost/fusion/include/as_list.hpp>
 25#include <boost/fusion/include/as_vector.hpp>
 26#include <boost/mpl/deref.hpp>
 27#include <boost/mpl/end.hpp>
 28#include <boost/mpl/eval_if.hpp>
 29#include <boost/mpl/find_if.hpp>
 30#include <boost/mpl/identity.hpp>
 31#include <boost/mpl/if.hpp>
 32#include <boost/mpl/placeholders.hpp>
 33#include <boost/type_traits/is_same.hpp>
 34
 35namespace boost { namespace spirit { namespace detail
 36{
 37    ///////////////////////////////////////////////////////////////////////////
 38    // Helpers to extract params (locals, attributes, ...) from nonterminal
 39    // template arguments
 40    ///////////////////////////////////////////////////////////////////////////
 41    template <typename Types, typename Pred, typename Default>
 42    struct extract_param
 43    {
 44        typedef typename mpl::find_if<Types, Pred>::type pos;
 45
 46        typedef typename
 47            mpl::eval_if<
 48                is_same<pos, typename mpl::end<Types>::type>
 49              , mpl::identity<Default>
 50              , mpl::deref<pos>
 51            >::type
 52        type;
 53    };
 54
 55    ///////////////////////////////////////////////////////////////////////////
 56    template <typename Types>
 57    struct extract_locals
 58      : fusion::result_of::as_vector<
 59            typename extract_param<
 60                Types
 61              , is_locals<mpl::_>
 62              , locals<>
 63            >::type
 64        >
 65    {};
 66
 67    ///////////////////////////////////////////////////////////////////////////
 68    template <typename Domain, typename Types>
 69    struct extract_component
 70      : spirit::result_of::compile<
 71            Domain
 72          , typename extract_param<
 73                Types
 74              , traits::matches<Domain, mpl::_>
 75              , unused_type
 76            >::type
 77        >
 78    {};
 79
 80    ///////////////////////////////////////////////////////////////////////////
 81    template <typename Types>
 82    struct extract_sig
 83      : extract_param<
 84            Types
 85          , function_types::is_function<mpl::_>
 86          , void()
 87        >
 88    {};
 89
 90    template <typename Sig>
 91    struct attr_from_sig
 92    {
 93        typedef typename function_types::result_type<Sig>::type attr;
 94
 95        typedef typename
 96            mpl::if_<
 97                is_same<attr, void>
 98              , unused_type
 99              , attr
100            >::type
101        type;
102    };
103
104    template <typename Sig>
105    struct params_from_sig
106    {
107        typedef typename function_types::parameter_types<Sig>::type params;
108
109        typedef typename fusion::result_of::as_list<params>::type type;
110    };
111
112    ///////////////////////////////////////////////////////////////////////////
113    template <typename Types>
114    struct extract_encoding
115      : extract_param<
116            Types
117          , is_char_encoding<mpl::_>
118          , unused_type
119        >
120    {};
121}}}
122
123#endif