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     template <typename OutputIterator, typename Context, typename Delimiter>
20     struct fail_function
21     {
22         typedef Context context_type;
23 
fail_functionboost::spirit::karma::detail::fail_function24         fail_function(OutputIterator& sink_, Context& context_
25             , Delimiter const& delim_)
26           : sink(sink_), ctx(context_), delim(delim_)
27         {}
28 
29         template <typename Component, typename Attribute>
operator ()boost::spirit::karma::detail::fail_function30         bool operator()(Component const& component, Attribute const& attr) const
31         {
32 #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
33             component; // suppresses warning: C4100: 'component' : unreferenced formal parameter
34 #endif
35             // return true if any of the generators fail
36             return !component.generate(sink, ctx, delim, attr);
37         }
38 
39         template <typename Component>
operator ()boost::spirit::karma::detail::fail_function40         bool operator()(Component const& component) const
41         {
42 #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
43             component; // suppresses warning: C4100: 'component' : unreferenced formal parameter
44 #endif
45             // return true if any of the generators fail
46             return !component.generate(sink, ctx, delim, unused);
47         }
48 
49         OutputIterator& sink;
50         Context& ctx;
51         Delimiter const& delim;
52 
53         // silence MSVC warning C4512: assignment operator could not be generated
54         BOOST_DELETED_FUNCTION(fail_function& operator= (fail_function const&))
55     };
56 
57 }}}}
58 
59 #endif
60