]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/log/detail/sink_init_helpers.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / log / detail / sink_init_helpers.hpp
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 sink_init_helpers.hpp
9 * \author Andrey Semashev
10 * \date 14.03.2009
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_SINK_INIT_HELPERS_HPP_INCLUDED_
17 #define BOOST_LOG_DETAIL_SINK_INIT_HELPERS_HPP_INCLUDED_
18
19 #include <string>
20 #include <boost/mpl/bool.hpp>
21 #include <boost/parameter/binding.hpp>
22 #include <boost/type_traits/is_void.hpp>
23 #include <boost/type_traits/is_array.hpp>
24 #include <boost/core/enable_if.hpp>
25 #include <boost/utility/string_view_fwd.hpp>
26 #include <boost/log/detail/config.hpp>
27 #if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
28 #include <string_view>
29 #endif
30 #include <boost/log/core/core.hpp>
31 #include <boost/log/expressions/filter.hpp>
32 #include <boost/log/expressions/formatter.hpp>
33 #include <boost/log/utility/setup/filter_parser.hpp>
34 #include <boost/log/utility/setup/formatter_parser.hpp>
35 #include <boost/log/keywords/filter.hpp>
36 #include <boost/log/keywords/format.hpp>
37 #include <boost/log/detail/is_character_type.hpp>
38 #include <boost/log/detail/header.hpp>
39
40 #ifdef BOOST_HAS_PRAGMA_ONCE
41 #pragma once
42 #endif
43
44 namespace boost {
45
46 BOOST_LOG_OPEN_NAMESPACE
47
48 namespace aux {
49
50 // The function creates a filter functional object from the provided argument
51 template< typename CharT >
52 inline typename boost::enable_if_c<
53 log::aux::is_character_type< CharT >::value,
54 filter
55 >::type acquire_filter(const CharT* filter)
56 {
57 return boost::log::parse_filter(filter);
58 }
59
60 template< typename CharT, typename TraitsT, typename AllocatorT >
61 inline filter acquire_filter(std::basic_string< CharT, TraitsT, AllocatorT > const& filter)
62 {
63 return boost::log::parse_filter(filter);
64 }
65
66 #if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
67 template< typename CharT, typename TraitsT >
68 inline filter acquire_filter(std::basic_string_view< CharT, TraitsT > const& filter)
69 {
70 const CharT* p = filter.data();
71 return boost::log::parse_filter(p, p + filter.size());
72 }
73 #endif // !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
74
75 template< typename CharT, typename TraitsT >
76 inline filter acquire_filter(boost::basic_string_view< CharT, TraitsT > const& filter)
77 {
78 const CharT* p = filter.data();
79 return boost::log::parse_filter(p, p + filter.size());
80 }
81
82 template< typename FilterT >
83 inline typename boost::disable_if_c<
84 boost::is_array< FilterT >::value,
85 FilterT const&
86 >::type acquire_filter(FilterT const& filter)
87 {
88 return filter;
89 }
90
91 // The function installs filter into the sink, if provided in the arguments pack
92 template< typename SinkT, typename ArgsT >
93 inline void setup_filter(SinkT&, ArgsT const&, mpl::true_)
94 {
95 }
96
97 template< typename SinkT, typename ArgsT >
98 inline void setup_filter(SinkT& s, ArgsT const& args, mpl::false_)
99 {
100 s.set_filter(aux::acquire_filter(args[keywords::filter]));
101 }
102
103
104 // The function creates a formatter functional object from the provided argument
105 template< typename CharT >
106 inline typename boost::enable_if_c<
107 log::aux::is_character_type< CharT >::value,
108 basic_formatter< CharT >
109 >::type acquire_formatter(const CharT* formatter)
110 {
111 return boost::log::parse_formatter(formatter);
112 }
113
114 template< typename CharT, typename TraitsT, typename AllocatorT >
115 inline basic_formatter< CharT > acquire_formatter(std::basic_string< CharT, TraitsT, AllocatorT > const& formatter)
116 {
117 return boost::log::parse_formatter(formatter);
118 }
119
120 #if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
121 template< typename CharT, typename TraitsT >
122 inline basic_formatter< CharT > acquire_formatter(std::basic_string_view< CharT, TraitsT > const& formatter)
123 {
124 const CharT* p = formatter.data();
125 return boost::log::parse_formatter(p, p + formatter.size());
126 }
127 #endif // !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
128
129 template< typename CharT, typename TraitsT >
130 inline basic_formatter< CharT > acquire_formatter(boost::basic_string_view< CharT, TraitsT > const& formatter)
131 {
132 const CharT* p = formatter.data();
133 return boost::log::parse_formatter(p, p + formatter.size());
134 }
135
136 template< typename FormatterT >
137 inline typename boost::disable_if_c<
138 boost::is_array< FormatterT >::value,
139 FormatterT const&
140 >::type acquire_formatter(FormatterT const& formatter)
141 {
142 return formatter;
143 }
144
145 // The function installs filter into the sink, if provided in the arguments pack
146 template< typename SinkT, typename ArgsT >
147 inline void setup_formatter(SinkT&, ArgsT const&, mpl::true_)
148 {
149 }
150
151 template< typename SinkT, typename ArgsT >
152 inline void setup_formatter(SinkT& s, ArgsT const& args, mpl::false_)
153 {
154 s.set_formatter(aux::acquire_formatter(args[keywords::format]));
155 }
156
157 } // namespace aux
158
159 BOOST_LOG_CLOSE_NAMESPACE // namespace log
160
161 } // namespace boost
162
163 #include <boost/log/detail/footer.hpp>
164
165 #endif // BOOST_LOG_DETAIL_SINK_INIT_HELPERS_HPP_INCLUDED_