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

source code of boost/libs/log/include/boost/log/detail/attr_output_impl.hpp