// Copyright (c) 2001-2010 Hartmut Kaiser // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #if !defined(BOOST_SPIRIT_KARMA_PHOENIX_ATTRIBUTES_OCT_01_2009_1128AM) #define BOOST_SPIRIT_KARMA_PHOENIX_ATTRIBUTES_OCT_01_2009_1128AM #if defined(_MSC_VER) #pragma once #endif #include // we support Phoenix attributes only starting with V2.2 #if SPIRIT_VERSION >= 0x2020 #include #include #include #include /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { namespace traits { /////////////////////////////////////////////////////////////////////////// // Provide customization points allowing the use of phoenix expressions as // generator functions in the context of generators expecting a container // attribute (Kleene, plus, list, repeat, etc.) /////////////////////////////////////////////////////////////////////////// template struct is_container const> : is_container()>::type> {}; template struct container_iterator const> { typedef phoenix::actor const& type; }; template struct begin_container const> { typedef phoenix::actor const& type; static type call(phoenix::actor const& f) { return f; } }; template struct end_container const> { typedef phoenix::actor const& type; static type call(phoenix::actor const& f) { return f; } }; template struct deref_iterator const> { typedef typename boost::result_of()>::type type; static type call(phoenix::actor const& f) { return f(); } }; template struct next_iterator const> { typedef phoenix::actor const& type; static type call(phoenix::actor const& f) { return f; } }; template struct compare_iterators const> { static bool call(phoenix::actor const&, phoenix::actor const&) { return false; } }; /////////////////////////////////////////////////////////////////////////// // Handle Phoenix actors as attributes, just invoke the function object // and deal with the result as the attribute. /////////////////////////////////////////////////////////////////////////// template struct extract_from_attribute, Exposed> { typedef typename boost::result_of()>::type type; template static type call(phoenix::actor const& f, Context& context) { return f(unused, context); } }; }}} #endif #endif