Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:47:40

0001 //  Copyright (c) 2001-2011 Hartmut Kaiser
0002 // 
0003 //  Distributed under the Boost Software License, Version 1.0. (See accompanying 
0004 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 #if !defined(BOOST_SPIRIT_KARMA_PHOENIX_ATTRIBUTES_OCT_01_2009_1128AM)
0007 #define BOOST_SPIRIT_KARMA_PHOENIX_ATTRIBUTES_OCT_01_2009_1128AM
0008 
0009 #if defined(_MSC_VER)
0010 #pragma once
0011 #endif
0012 
0013 #include <boost/spirit/home/karma/detail/attributes.hpp>
0014 #include <boost/spirit/home/karma/detail/indirect_iterator.hpp>
0015 #include <boost/spirit/home/support/container.hpp>
0016 
0017 #include <boost/utility/result_of.hpp>
0018 
0019 ///////////////////////////////////////////////////////////////////////////////
0020 namespace boost { namespace phoenix
0021 {
0022     template <typename Expr>
0023     struct actor;
0024 }}
0025 
0026 ///////////////////////////////////////////////////////////////////////////////
0027 namespace boost { namespace spirit { namespace traits
0028 {
0029     ///////////////////////////////////////////////////////////////////////////
0030     // Provide customization points allowing the use of phoenix expressions as 
0031     // generator functions in the context of generators expecting a container 
0032     // attribute (Kleene, plus, list, repeat, etc.)
0033     ///////////////////////////////////////////////////////////////////////////
0034     template <typename Eval>
0035     struct is_container<phoenix::actor<Eval> const>
0036       : is_container<typename boost::result_of<phoenix::actor<Eval>()>::type>
0037     {};
0038 
0039     template <typename Eval>
0040     struct container_iterator<phoenix::actor<Eval> const>
0041     {
0042         typedef phoenix::actor<Eval> const& type;
0043     };
0044 
0045     template <typename Eval>
0046     struct begin_container<phoenix::actor<Eval> const>
0047     {
0048         typedef phoenix::actor<Eval> const& type;
0049         static type call(phoenix::actor<Eval> const& f)
0050         {
0051             return f;
0052         }
0053     };
0054 
0055     template <typename Eval>
0056     struct end_container<phoenix::actor<Eval> const>
0057     {
0058         typedef phoenix::actor<Eval> const& type;
0059         static type call(phoenix::actor<Eval> const& f)
0060         {
0061             return f;
0062         }
0063     };
0064 
0065     template <typename Eval>
0066     struct deref_iterator<phoenix::actor<Eval> const>
0067     {
0068         typedef typename boost::result_of<phoenix::actor<Eval>()>::type type;
0069         static type call(phoenix::actor<Eval> const& f)
0070         {
0071             return f();
0072         }
0073     };
0074 
0075     template <typename Eval>
0076     struct next_iterator<phoenix::actor<Eval> const>
0077     {
0078         typedef phoenix::actor<Eval> const& type;
0079         static type call(phoenix::actor<Eval> const& f)
0080         {
0081             return f;
0082         }
0083     };
0084 
0085     template <typename Eval>
0086     struct compare_iterators<phoenix::actor<Eval> const>
0087     {
0088         static bool 
0089         call(phoenix::actor<Eval> const&, phoenix::actor<Eval> const&)
0090         {
0091             return false;
0092         }
0093     };
0094 
0095     template <typename Eval>
0096     struct container_value<phoenix::actor<Eval> >
0097     {
0098         typedef phoenix::actor<Eval> const& type;
0099     };
0100 
0101     template <typename Eval>
0102     struct make_indirect_iterator<phoenix::actor<Eval> const>
0103     {
0104         typedef phoenix::actor<Eval> const& type;
0105     };
0106 
0107     ///////////////////////////////////////////////////////////////////////////
0108     // Handle Phoenix actors as attributes, just invoke the function object
0109     // and deal with the result as the attribute.
0110     ///////////////////////////////////////////////////////////////////////////
0111     template <typename Eval, typename Exposed>
0112     struct extract_from_attribute<phoenix::actor<Eval>, Exposed>
0113     {
0114         typedef typename boost::result_of<phoenix::actor<Eval>()>::type type;
0115 
0116         template <typename Context>
0117         static type call(phoenix::actor<Eval> const& f, Context& context)
0118         {
0119             return f(unused, context);
0120         }
0121     };
0122 }}}
0123 
0124 #endif