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 sink_init_helpers.hpp
|
Chris@16
|
9 * \author Andrey Semashev
|
Chris@16
|
10 * \date 14.03.2009
|
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_SINK_INIT_HELPERS_HPP_INCLUDED_
|
Chris@16
|
17 #define BOOST_LOG_DETAIL_SINK_INIT_HELPERS_HPP_INCLUDED_
|
Chris@16
|
18
|
Chris@16
|
19 #include <string>
|
Chris@16
|
20 #include <boost/mpl/bool.hpp>
|
Chris@16
|
21 #include <boost/parameter/binding.hpp>
|
Chris@16
|
22 #include <boost/type_traits/is_void.hpp>
|
Chris@16
|
23 #include <boost/utility/enable_if.hpp>
|
Chris@16
|
24 #include <boost/phoenix/core/is_actor.hpp>
|
Chris@16
|
25 #include <boost/log/detail/config.hpp>
|
Chris@16
|
26 #include <boost/log/core/core.hpp>
|
Chris@16
|
27 #include <boost/log/expressions/filter.hpp>
|
Chris@16
|
28 #include <boost/log/expressions/formatter.hpp>
|
Chris@16
|
29 #include <boost/log/utility/setup/filter_parser.hpp>
|
Chris@16
|
30 #include <boost/log/utility/setup/formatter_parser.hpp>
|
Chris@16
|
31 #include <boost/log/keywords/filter.hpp>
|
Chris@16
|
32 #include <boost/log/keywords/format.hpp>
|
Chris@16
|
33 #include <boost/log/detail/header.hpp>
|
Chris@16
|
34
|
Chris@16
|
35 #ifdef BOOST_HAS_PRAGMA_ONCE
|
Chris@16
|
36 #pragma once
|
Chris@16
|
37 #endif
|
Chris@16
|
38
|
Chris@16
|
39 namespace boost {
|
Chris@16
|
40
|
Chris@16
|
41 BOOST_LOG_OPEN_NAMESPACE
|
Chris@16
|
42
|
Chris@16
|
43 namespace aux {
|
Chris@16
|
44
|
Chris@16
|
45 // The function creates a filter functional object from the provided argument
|
Chris@16
|
46 template< typename CharT >
|
Chris@16
|
47 inline filter acquire_filter(const CharT* filter)
|
Chris@16
|
48 {
|
Chris@16
|
49 return boost::log::parse_filter(filter);
|
Chris@16
|
50 }
|
Chris@16
|
51 template< typename CharT, typename TraitsT, typename AllocatorT >
|
Chris@16
|
52 inline filter acquire_filter(std::basic_string< CharT, TraitsT, AllocatorT > const& filter)
|
Chris@16
|
53 {
|
Chris@16
|
54 return boost::log::parse_filter(filter);
|
Chris@16
|
55 }
|
Chris@16
|
56 template< typename FilterT >
|
Chris@16
|
57 inline typename enable_if<
|
Chris@16
|
58 phoenix::is_actor< FilterT >,
|
Chris@16
|
59 FilterT const&
|
Chris@16
|
60 >::type acquire_filter(FilterT const& filter)
|
Chris@16
|
61 {
|
Chris@16
|
62 return filter;
|
Chris@16
|
63 }
|
Chris@16
|
64
|
Chris@16
|
65 // The function installs filter into the sink, if provided in the arguments pack
|
Chris@16
|
66 template< typename SinkT, typename ArgsT >
|
Chris@16
|
67 inline void setup_filter(SinkT&, ArgsT const&, mpl::true_)
|
Chris@16
|
68 {
|
Chris@16
|
69 }
|
Chris@16
|
70
|
Chris@16
|
71 template< typename SinkT, typename ArgsT >
|
Chris@16
|
72 inline void setup_filter(SinkT& s, ArgsT const& args, mpl::false_)
|
Chris@16
|
73 {
|
Chris@16
|
74 s.set_filter(aux::acquire_filter(args[keywords::filter]));
|
Chris@16
|
75 }
|
Chris@16
|
76
|
Chris@16
|
77
|
Chris@16
|
78 // The function creates a filter functional object from the provided argument
|
Chris@16
|
79 template< typename CharT >
|
Chris@16
|
80 inline basic_formatter< CharT > acquire_formatter(const CharT* formatter)
|
Chris@16
|
81 {
|
Chris@16
|
82 return boost::log::parse_formatter(formatter);
|
Chris@16
|
83 }
|
Chris@16
|
84 template< typename CharT, typename TraitsT, typename AllocatorT >
|
Chris@16
|
85 inline basic_formatter< CharT > acquire_formatter(std::basic_string< CharT, TraitsT, AllocatorT > const& formatter)
|
Chris@16
|
86 {
|
Chris@16
|
87 return boost::log::parse_formatter(formatter);
|
Chris@16
|
88 }
|
Chris@16
|
89 template< typename FormatterT >
|
Chris@16
|
90 inline typename enable_if<
|
Chris@16
|
91 phoenix::is_actor< FormatterT >,
|
Chris@16
|
92 FormatterT const&
|
Chris@16
|
93 >::type acquire_formatter(FormatterT const& formatter)
|
Chris@16
|
94 {
|
Chris@16
|
95 return formatter;
|
Chris@16
|
96 }
|
Chris@16
|
97
|
Chris@16
|
98 // The function installs filter into the sink, if provided in the arguments pack
|
Chris@16
|
99 template< typename SinkT, typename ArgsT >
|
Chris@16
|
100 inline void setup_formatter(SinkT&, ArgsT const&, mpl::true_)
|
Chris@16
|
101 {
|
Chris@16
|
102 }
|
Chris@16
|
103
|
Chris@16
|
104 template< typename SinkT, typename ArgsT >
|
Chris@16
|
105 inline void setup_formatter(SinkT& s, ArgsT const& args, mpl::false_)
|
Chris@16
|
106 {
|
Chris@16
|
107 s.set_formatter(aux::acquire_formatter(args[keywords::format]));
|
Chris@16
|
108 }
|
Chris@16
|
109
|
Chris@16
|
110 } // namespace aux
|
Chris@16
|
111
|
Chris@16
|
112 BOOST_LOG_CLOSE_NAMESPACE // namespace log
|
Chris@16
|
113
|
Chris@16
|
114 } // namespace boost
|
Chris@16
|
115
|
Chris@16
|
116 #include <boost/log/detail/footer.hpp>
|
Chris@16
|
117
|
Chris@16
|
118 #endif // BOOST_LOG_DETAIL_SINK_INIT_HELPERS_HPP_INCLUDED_
|