// Copyright (c) 2001-2008 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_ACTION_MAR_07_2007_0851AM) #define BOOST_SPIRIT_KARMA_ACTION_MAR_07_2007_0851AM #if defined(_MSC_VER) && (_MSC_VER >= 1020) #pragma once // MS compatible compilers support #pragma once #endif #include #include #include #include #include #include #include #include #include #include namespace boost { namespace spirit { namespace karma { /////////////////////////////////////////////////////////////////////////// struct sequence; // forward declaration only /////////////////////////////////////////////////////////////////////////// struct action { template struct attribute : traits::attribute_of< karma::domain, typename result_of::left::type, Context > { }; template static bool generate(Component const& component, OutputIterator& sink, Context& ctx, Delimiter const& d, Parameter const& param) { typedef typename result_of::left::type::director director; typedef typename is_same::type is_sequence; typedef typename attribute::type param_type; // create a parameter if one is not supplied // this creates a _copy_ of the parameter because the semantic // action likely will change parts of this typename mpl::if_< is_same::type, unused_type>, param_type, Parameter >::type p = spirit::detail::make_value::call(param); // call the function, passing the parameter, the context // and a bool flag that the client can set to false to // fail generating. // The client can return false to fail parsing. bool pass = spirit::detail::action_dispatch( spirit::right(component), p, ctx, is_sequence()); return pass && director::generate(spirit::left(component), sink, ctx, d, p); } template static std::string what(Component const& component, Context const& ctx) { typedef typename spirit::result_of::left::type::director director; return director::what(spirit::left(component), ctx); } }; }}} #endif