// Copyright (c) 2001-2008 Hartmut Kaiser // Copyright (c) 2001-2007 Joel de Guzman // // 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(SPIRIT_KARMA_ALTERNATIVE_MAR_01_2007_1117AM) #define SPIRIT_KARMA_ALTERNATIVE_MAR_01_2007_1117AM #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 #include #include #include #include namespace boost { namespace spirit { namespace karma { struct alternative { template struct transform_child : mpl::identity {}; template struct build_container { // Ok, now make a variant over the attribute_sequence. It's // a pity that make_variant_over does not support forward MPL // sequences. We use our own conversion metaprogram (as_variant). typedef typename as_variant::type type; }; template struct attribute : build_fusion_sequence { }; template static bool generate(Component const& component, OutputIterator& sink, Context& ctx, Delimiter const& d, Parameter const& param) { typedef detail::alternative_generate_functor< OutputIterator, Context, Delimiter, Parameter > functor; // f return true if *any* of the parser succeeds functor f (sink, ctx, d, param); return fusion::any(component.elements, f); } template static std::string what(Component const& component, Context const& ctx) { std::string result = "alternatives["; fusion::for_each(component.elements, spirit::detail::what_function(result, ctx)); result += "]"; return result; } }; }}} #endif