1 //  Copyright (c) 2001-2011 Hartmut Kaiser
2 //
3 //  Distributed under the Boost Software License, Version 1.0. (See accompanying
4 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 
6 #if !defined(BOOST_SPIRIT_KARMA_DETAIL_GENERATE_TO_FEB_20_2007_0417PM)
7 #define BOOST_SPIRIT_KARMA_DETAIL_GENERATE_TO_FEB_20_2007_0417PM
8 
9 #if defined(_MSC_VER)
10 #pragma once
11 #endif
12 
13 #include <boost/spirit/home/support/unused.hpp>
14 #include <boost/spirit/home/support/char_class.hpp>
15 #include <boost/spirit/home/karma/detail/output_iterator.hpp>
16 
17 namespace boost { namespace spirit { namespace karma { namespace detail
18 {
19     ///////////////////////////////////////////////////////////////////////////
20     //  These utility functions insert the given parameter into the supplied
21     //  output iterator.
22     //  If the attribute is spirit's unused_type, this is a no_op.
23     ///////////////////////////////////////////////////////////////////////////
24     template <
25         typename OutputIterator, typename Attribute, typename CharEncoding
26       , typename Tag>
27     inline bool
generate_to(OutputIterator & sink,Attribute const & p,CharEncoding,Tag)28     generate_to(OutputIterator& sink, Attribute const& p, CharEncoding, Tag)
29     {
30         *sink = spirit::char_class::convert<CharEncoding>::to(Tag(), p);
31         ++sink;
32         return detail::sink_is_good(sink);
33     }
34 
35     template <typename OutputIterator, typename Attribute>
36     inline bool
generate_to(OutputIterator & sink,Attribute const & p,unused_type,unused_type)37     generate_to(OutputIterator& sink, Attribute const& p, unused_type, unused_type)
38     {
39         *sink = p;
40         ++sink;
41         return detail::sink_is_good(sink);
42     }
43 
44     template <typename OutputIterator, typename CharEncoding, typename Tag>
generate_to(OutputIterator &,unused_type,CharEncoding,Tag)45     inline bool generate_to(OutputIterator&, unused_type, CharEncoding, Tag)
46     {
47         return true;
48     }
49 
50     template <typename OutputIterator, typename Attribute>
51     inline bool
generate_to(OutputIterator & sink,Attribute const & p)52     generate_to(OutputIterator& sink, Attribute const& p)
53     {
54         *sink = p;
55         ++sink;
56         return detail::sink_is_good(sink);
57     }
58 
59     template <typename OutputIterator>
generate_to(OutputIterator &,unused_type)60     inline bool generate_to(OutputIterator&, unused_type)
61     {
62         return true;
63     }
64 
65 }}}}   // namespace boost::spirit::karma::detail
66 
67 #endif  // KARMA_CORE_DETAIL_INSERT_TO_HPP
68