| 1 | // Copyright (c) 2001-2011 Hartmut Kaiser |
| 2 | // Copyright (c) 2001-2011 Joel de Guzman |
| 3 | // |
| 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 6 | |
| 7 | #ifndef BOOST_SPIRIT_KARMA_DETAIL_FAIL_FUNCTION_HPP |
| 8 | #define BOOST_SPIRIT_KARMA_DETAIL_FAIL_FUNCTION_HPP |
| 9 | |
| 10 | #if defined(_MSC_VER) |
| 11 | #pragma once |
| 12 | #endif |
| 13 | |
| 14 | #include <boost/spirit/home/support/unused.hpp> |
| 15 | #include <boost/config.hpp> |
| 16 | |
| 17 | namespace boost { namespace spirit { namespace karma { namespace detail |
| 18 | { |
| 19 | #ifdef _MSC_VER |
| 20 | # pragma warning(push) |
| 21 | # pragma warning(disable: 4512) // assignment operator could not be generated. |
| 22 | #endif |
| 23 | template <typename OutputIterator, typename Context, typename Delimiter> |
| 24 | struct fail_function |
| 25 | { |
| 26 | typedef Context context_type; |
| 27 | |
| 28 | fail_function(OutputIterator& sink_, Context& context_ |
| 29 | , Delimiter const& delim_) |
| 30 | : sink(sink_), ctx(context_), delim(delim_) |
| 31 | {} |
| 32 | |
| 33 | template <typename Component, typename Attribute> |
| 34 | bool operator()(Component const& component, Attribute const& attr) const |
| 35 | { |
| 36 | #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600)) |
| 37 | (void)component; // suppresses warning: C4100: 'component' : unreferenced formal parameter |
| 38 | #endif |
| 39 | // return true if any of the generators fail |
| 40 | return !component.generate(sink, ctx, delim, attr); |
| 41 | } |
| 42 | |
| 43 | template <typename Component> |
| 44 | bool operator()(Component const& component) const |
| 45 | { |
| 46 | #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600)) |
| 47 | (void)component; // suppresses warning: C4100: 'component' : unreferenced formal parameter |
| 48 | #endif |
| 49 | // return true if any of the generators fail |
| 50 | return !component.generate(sink, ctx, delim, unused); |
| 51 | } |
| 52 | |
| 53 | OutputIterator& sink; |
| 54 | Context& ctx; |
| 55 | Delimiter const& delim; |
| 56 | }; |
| 57 | #ifdef _MSC_VER |
| 58 | # pragma warning(pop) |
| 59 | #endif |
| 60 | |
| 61 | }}}} |
| 62 | |
| 63 | #endif |
| 64 | |