Chris@16
|
1 /*
|
Chris@101
|
2 * Copyright Andrey Semashev 2007 - 2015.
|
Chris@16
|
3 * Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
4 * (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
5 * http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 */
|
Chris@16
|
7 /*!
|
Chris@16
|
8 * \file attr_output_impl.hpp
|
Chris@16
|
9 * \author Andrey Semashev
|
Chris@16
|
10 * \date 12.08.2012
|
Chris@16
|
11 *
|
Chris@16
|
12 * \brief This header is the Boost.Log library implementation, see the library documentation
|
Chris@16
|
13 * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
|
Chris@16
|
14 */
|
Chris@16
|
15
|
Chris@16
|
16 #ifndef BOOST_LOG_DETAIL_ATTR_OUTPUT_IMPL_HPP_INCLUDED_
|
Chris@16
|
17 #define BOOST_LOG_DETAIL_ATTR_OUTPUT_IMPL_HPP_INCLUDED_
|
Chris@16
|
18
|
Chris@16
|
19 #include <boost/mpl/is_sequence.hpp>
|
Chris@16
|
20 #include <boost/phoenix/core/actor.hpp>
|
Chris@16
|
21 #include <boost/log/detail/config.hpp>
|
Chris@16
|
22 #include <boost/log/expressions/attr.hpp>
|
Chris@16
|
23 #include <boost/log/utility/functional/bind_to_log.hpp>
|
Chris@16
|
24 #include <boost/log/detail/attr_output_terminal.hpp>
|
Chris@16
|
25 #include <boost/log/detail/header.hpp>
|
Chris@16
|
26
|
Chris@16
|
27 #ifdef BOOST_HAS_PRAGMA_ONCE
|
Chris@16
|
28 #pragma once
|
Chris@16
|
29 #endif
|
Chris@16
|
30
|
Chris@16
|
31 namespace boost {
|
Chris@16
|
32
|
Chris@16
|
33 BOOST_LOG_OPEN_NAMESPACE
|
Chris@16
|
34
|
Chris@16
|
35 namespace expressions {
|
Chris@16
|
36
|
Chris@16
|
37 namespace aux {
|
Chris@16
|
38
|
Chris@16
|
39 template< typename LeftT, typename T, typename FallbackPolicyT, typename TagT >
|
Chris@16
|
40 struct make_output_expression
|
Chris@16
|
41 {
|
Chris@16
|
42 //! Resulting expression
|
Chris@16
|
43 typedef attribute_output_terminal< LeftT, T, FallbackPolicyT, to_log_fun< TagT > > type;
|
Chris@16
|
44
|
Chris@16
|
45 //! Creates the output expression
|
Chris@16
|
46 template< typename RightT >
|
Chris@16
|
47 static BOOST_FORCEINLINE type make(LeftT const& left, RightT const& right)
|
Chris@16
|
48 {
|
Chris@16
|
49 return type(left, right.get_name(), to_log_fun< TagT >(), right.get_fallback_policy());
|
Chris@16
|
50 }
|
Chris@16
|
51 };
|
Chris@16
|
52
|
Chris@16
|
53 template< typename LeftT, typename RightT, typename ValueT = typename RightT::value_type, bool IsSequenceV = mpl::is_sequence< ValueT >::value >
|
Chris@16
|
54 struct make_output_actor;
|
Chris@16
|
55
|
Chris@16
|
56 template< template< typename > class ActorT, typename LeftExprT, typename RightT, typename ValueT >
|
Chris@16
|
57 struct make_output_actor< ActorT< LeftExprT >, RightT, ValueT, false >
|
Chris@16
|
58 {
|
Chris@16
|
59 typedef make_output_expression<
|
Chris@16
|
60 ActorT< LeftExprT >,
|
Chris@16
|
61 ValueT,
|
Chris@16
|
62 typename RightT::fallback_policy,
|
Chris@16
|
63 typename RightT::tag_type
|
Chris@16
|
64 > make_expression;
|
Chris@16
|
65
|
Chris@16
|
66 typedef ActorT< typename make_expression::type > type;
|
Chris@16
|
67
|
Chris@16
|
68 static BOOST_FORCEINLINE type make(ActorT< LeftExprT > const& left, RightT const& right)
|
Chris@16
|
69 {
|
Chris@16
|
70 type res = {{ make_expression::make(left, right) }};
|
Chris@16
|
71 return res;
|
Chris@16
|
72 }
|
Chris@16
|
73 };
|
Chris@16
|
74
|
Chris@16
|
75 template< template< typename > class ActorT, typename LeftExprT, typename RightT, typename ValueT >
|
Chris@16
|
76 struct make_output_actor< ActorT< LeftExprT >, RightT, ValueT, true >
|
Chris@16
|
77 {
|
Chris@16
|
78 typedef attribute_output_terminal< ActorT< LeftExprT >, ValueT, typename RightT::fallback_policy, to_log_fun< typename RightT::tag_type > > expression_type;
|
Chris@16
|
79
|
Chris@16
|
80 typedef ActorT< expression_type > type;
|
Chris@16
|
81
|
Chris@16
|
82 static BOOST_FORCEINLINE type make(ActorT< LeftExprT > const& left, RightT const& right)
|
Chris@16
|
83 {
|
Chris@16
|
84 type res = {{ expression_type(left, right.get_name(), to_log_fun< typename RightT::tag_type >(), right.get_fallback_policy()) }};
|
Chris@16
|
85 return res;
|
Chris@16
|
86 }
|
Chris@16
|
87 };
|
Chris@16
|
88
|
Chris@16
|
89 } // namespace aux
|
Chris@16
|
90
|
Chris@16
|
91 #define BOOST_LOG_AUX_OVERLOAD(left_ref, right_ref)\
|
Chris@16
|
92 template< typename LeftExprT, typename T, typename FallbackPolicyT, typename TagT >\
|
Chris@16
|
93 BOOST_FORCEINLINE typename aux::make_output_actor< phoenix::actor< LeftExprT >, attribute_actor< T, FallbackPolicyT, TagT, phoenix::actor > >::type\
|
Chris@16
|
94 operator<< (phoenix::actor< LeftExprT > left_ref left, attribute_actor< T, FallbackPolicyT, TagT, phoenix::actor > right_ref right)\
|
Chris@16
|
95 {\
|
Chris@16
|
96 return aux::make_output_actor< phoenix::actor< LeftExprT >, attribute_actor< T, FallbackPolicyT, TagT, phoenix::actor > >::make(left, right);\
|
Chris@16
|
97 }
|
Chris@16
|
98
|
Chris@16
|
99 #include <boost/log/detail/generate_overloads.hpp>
|
Chris@16
|
100
|
Chris@16
|
101 #undef BOOST_LOG_AUX_OVERLOAD
|
Chris@16
|
102
|
Chris@16
|
103 } // namespace expressions
|
Chris@16
|
104
|
Chris@16
|
105 BOOST_LOG_CLOSE_NAMESPACE // namespace log
|
Chris@16
|
106
|
Chris@16
|
107 } // namespace boost
|
Chris@16
|
108
|
Chris@16
|
109 #include <boost/log/detail/footer.hpp>
|
Chris@16
|
110
|
Chris@16
|
111 #endif // BOOST_LOG_DETAIL_ATTR_OUTPUT_IMPL_HPP_INCLUDED_
|