comparison DEPENDENCIES/generic/include/boost/log/detail/attr_output_terminal.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
comparison
equal deleted inserted replaced
15:663ca0da4350 16:2665513ce2d3
1 /*
2 * Copyright Andrey Semashev 2007 - 2013.
3 * Distributed under the Boost Software License, Version 1.0.
4 * (See accompanying file LICENSE_1_0.txt or copy at
5 * http://www.boost.org/LICENSE_1_0.txt)
6 */
7 /*!
8 * \file attribute_output_terminal.hpp
9 * \author Andrey Semashev
10 * \date 06.11.2012
11 *
12 * The header contains implementation of a generic output manipulator in template expressions.
13 */
14
15 #ifndef BOOST_LOG_DETAIL_ATTR_OUTPUT_TERMINAL_HPP_INCLUDED_
16 #define BOOST_LOG_DETAIL_ATTR_OUTPUT_TERMINAL_HPP_INCLUDED_
17
18 #include <boost/mpl/bool.hpp>
19 #include <boost/phoenix/core/actor.hpp>
20 #include <boost/phoenix/core/meta_grammar.hpp>
21 #include <boost/phoenix/core/environment.hpp>
22 #include <boost/phoenix/core/terminal_fwd.hpp>
23 #include <boost/phoenix/core/is_nullary.hpp>
24 #include <boost/type_traits/remove_cv.hpp>
25 #include <boost/type_traits/remove_reference.hpp>
26 #include <boost/fusion/sequence/intrinsic/at.hpp>
27 #include <boost/log/detail/config.hpp>
28 #include <boost/log/detail/custom_terminal_spec.hpp>
29 #include <boost/log/attributes/attribute_name.hpp>
30 #include <boost/log/attributes/value_visitation.hpp>
31 #include <boost/log/utility/functional/bind.hpp>
32 #include <boost/log/detail/header.hpp>
33
34 #ifdef BOOST_HAS_PRAGMA_ONCE
35 #pragma once
36 #endif
37
38 namespace boost {
39
40 BOOST_LOG_OPEN_NAMESPACE
41
42 namespace expressions {
43
44 namespace aux {
45
46 //! Attribute stream output expression
47 template< typename LeftT, typename T, typename FallbackPolicyT, typename ImplT >
48 class attribute_output_terminal
49 {
50 private:
51 //! Self type
52 typedef attribute_output_terminal< LeftT, T, FallbackPolicyT, ImplT > this_type;
53 //! Attribute value visitor invoker
54 typedef value_visitor_invoker< T, FallbackPolicyT > visitor_invoker_type;
55 //! Manipulator implementation
56 typedef ImplT impl_type;
57
58 public:
59 //! Internal typedef for type categorization
60 typedef void _is_boost_log_terminal;
61
62 //! Result type definition
63 template< typename >
64 struct result;
65
66 template< typename ContextT >
67 struct result< this_type(ContextT) >
68 {
69 typedef typename remove_cv< typename remove_reference< ContextT >::type >::type context_type;
70 typedef typename phoenix::evaluator::impl<
71 typename LeftT::proto_base_expr&,
72 context_type,
73 phoenix::unused
74 >::result_type type;
75 };
76
77 template< typename ContextT >
78 struct result< const this_type(ContextT) >
79 {
80 typedef typename remove_cv< typename remove_reference< ContextT >::type >::type context_type;
81 typedef typename phoenix::evaluator::impl<
82 typename LeftT::proto_base_expr const&,
83 context_type,
84 phoenix::unused
85 >::result_type type;
86 };
87
88 private:
89 //! Left argument actor
90 LeftT m_left;
91 //! Attribute name
92 const attribute_name m_name;
93 //! Attribute value visitor invoker
94 visitor_invoker_type m_visitor_invoker;
95 //! Manipulator implementation
96 impl_type m_impl;
97
98 public:
99 //! Initializing constructor
100 attribute_output_terminal(LeftT const& left, attribute_name const& name) : m_left(left), m_name(name)
101 {
102 }
103
104 //! Initializing constructor
105 attribute_output_terminal(LeftT const& left, attribute_name const& name, impl_type const& impl) : m_left(left), m_name(name), m_impl(impl)
106 {
107 }
108
109 //! Initializing constructor
110 template< typename U >
111 attribute_output_terminal(LeftT const& left, attribute_name const& name, impl_type const& impl, U const& arg) :
112 m_left(left), m_name(name), m_visitor_invoker(arg), m_impl(impl)
113 {
114 }
115
116 //! Copy constructor
117 attribute_output_terminal(attribute_output_terminal const& that) :
118 m_left(that.m_left), m_name(that.m_name), m_visitor_invoker(that.m_visitor_invoker), m_impl(that.m_impl)
119 {
120 }
121
122 //! Invokation operator
123 template< typename ContextT >
124 typename result< this_type(ContextT const&) >::type operator() (ContextT const& ctx)
125 {
126 typedef typename result< this_type(ContextT const&) >::type result_type;
127 result_type strm = phoenix::eval(m_left, ctx);
128 m_visitor_invoker(m_name, fusion::at_c< 0 >(phoenix::env(ctx).args()), binder1st< impl_type&, result_type >(m_impl, strm));
129 return strm;
130 }
131
132 //! Invokation operator
133 template< typename ContextT >
134 typename result< const this_type(ContextT const&) >::type operator() (ContextT const& ctx) const
135 {
136 typedef typename result< const this_type(ContextT const&) >::type result_type;
137 result_type strm = phoenix::eval(m_left, ctx);
138 m_visitor_invoker(m_name, fusion::at_c< 0 >(phoenix::env(ctx).args()), binder1st< impl_type const&, result_type >(m_impl, strm));
139 return strm;
140 }
141
142 BOOST_DELETED_FUNCTION(attribute_output_terminal())
143 };
144
145 } // namespace aux
146
147 } // namespace expressions
148
149 BOOST_LOG_CLOSE_NAMESPACE // namespace log
150
151 #ifndef BOOST_LOG_DOXYGEN_PASS
152
153 namespace phoenix {
154
155 namespace result_of {
156
157 template< typename LeftT, typename T, typename FallbackPolicyT, typename ImplT >
158 struct is_nullary< custom_terminal< boost::log::expressions::aux::attribute_output_terminal< LeftT, T, FallbackPolicyT, ImplT > > > :
159 public mpl::false_
160 {
161 };
162
163 } // namespace result_of
164
165 } // namespace phoenix
166
167 #endif // !defined(BOOST_LOG_DOXYGEN_PASS)
168
169 } // namespace boost
170
171 #include <boost/log/detail/footer.hpp>
172
173 #endif // BOOST_LOG_DETAIL_ATTR_OUTPUT_TERMINAL_HPP_INCLUDED_