Chris@16
|
1 // Copyright (c) 2001-2011 Hartmut Kaiser
|
Chris@16
|
2 //
|
Chris@16
|
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
5
|
Chris@16
|
6 #if !defined(BOOST_SPIRIT_KARMA_EOL_JUL_08_2008_1014AM)
|
Chris@16
|
7 #define BOOST_SPIRIT_KARMA_EOL_JUL_08_2008_1014AM
|
Chris@16
|
8
|
Chris@16
|
9 #if defined(_MSC_VER)
|
Chris@16
|
10 #pragma once
|
Chris@16
|
11 #endif
|
Chris@16
|
12
|
Chris@16
|
13 #include <boost/spirit/home/support/common_terminals.hpp>
|
Chris@16
|
14 #include <boost/spirit/home/support/info.hpp>
|
Chris@16
|
15 #include <boost/spirit/home/support/unused.hpp>
|
Chris@16
|
16 #include <boost/spirit/home/karma/detail/attributes.hpp>
|
Chris@16
|
17 #include <boost/spirit/home/karma/domain.hpp>
|
Chris@16
|
18 #include <boost/spirit/home/karma/meta_compiler.hpp>
|
Chris@16
|
19 #include <boost/spirit/home/karma/delimit_out.hpp>
|
Chris@16
|
20 #include <boost/spirit/home/karma/detail/generate_to.hpp>
|
Chris@16
|
21
|
Chris@16
|
22 namespace boost { namespace spirit
|
Chris@16
|
23 {
|
Chris@16
|
24 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
25 // Enablers
|
Chris@16
|
26 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
27 template <>
|
Chris@16
|
28 struct use_terminal<karma::domain, tag::eol> // enables eol
|
Chris@16
|
29 : mpl::true_ {};
|
Chris@16
|
30
|
Chris@16
|
31 }}
|
Chris@16
|
32
|
Chris@16
|
33 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
34 namespace boost { namespace spirit { namespace karma
|
Chris@16
|
35 {
|
Chris@16
|
36 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
|
Chris@16
|
37 using boost::spirit::eol;
|
Chris@16
|
38 #endif
|
Chris@16
|
39 using boost::spirit::eol_type;
|
Chris@16
|
40
|
Chris@16
|
41 struct eol_generator : primitive_generator<eol_generator>
|
Chris@16
|
42 {
|
Chris@16
|
43 template <typename Context, typename Unused>
|
Chris@16
|
44 struct attribute
|
Chris@16
|
45 {
|
Chris@16
|
46 typedef unused_type type;
|
Chris@16
|
47 };
|
Chris@16
|
48
|
Chris@16
|
49 template <
|
Chris@16
|
50 typename OutputIterator, typename Context, typename Delimiter
|
Chris@16
|
51 , typename Attribute>
|
Chris@16
|
52 static bool generate(OutputIterator& sink, Context&, Delimiter const& d
|
Chris@16
|
53 , Attribute const& /*attr*/)
|
Chris@16
|
54 {
|
Chris@16
|
55 return detail::generate_to(sink, '\n') &&
|
Chris@16
|
56 karma::delimit_out(sink, d); // always do post-delimiting
|
Chris@16
|
57 }
|
Chris@16
|
58
|
Chris@16
|
59 template <typename Context>
|
Chris@16
|
60 info what(Context const& /*context*/) const
|
Chris@16
|
61 {
|
Chris@16
|
62 return info("eol");
|
Chris@16
|
63 }
|
Chris@16
|
64 };
|
Chris@16
|
65
|
Chris@16
|
66 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
67 // Generator generators: make_xxx function (objects)
|
Chris@16
|
68 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
69 template <typename Modifiers>
|
Chris@16
|
70 struct make_primitive<tag::eol, Modifiers>
|
Chris@16
|
71 {
|
Chris@16
|
72 typedef eol_generator result_type;
|
Chris@16
|
73 result_type operator()(unused_type, unused_type) const
|
Chris@16
|
74 {
|
Chris@16
|
75 return result_type();
|
Chris@16
|
76 }
|
Chris@16
|
77 };
|
Chris@16
|
78
|
Chris@16
|
79 }}}
|
Chris@16
|
80
|
Chris@16
|
81 #endif
|