Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:39:21

0001 /*
0002  *          Copyright Andrey Semashev 2007 - 2015.
0003  * Distributed under the Boost Software License, Version 1.0.
0004  *    (See accompanying file LICENSE_1_0.txt or copy at
0005  *          http://www.boost.org/LICENSE_1_0.txt)
0006  */
0007 /*!
0008  * \file   sink_init_helpers.hpp
0009  * \author Andrey Semashev
0010  * \date   14.03.2009
0011  *
0012  * \brief  This header is the Boost.Log library implementation, see the library documentation
0013  *         at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
0014  */
0015 
0016 #ifndef BOOST_LOG_DETAIL_SINK_INIT_HELPERS_HPP_INCLUDED_
0017 #define BOOST_LOG_DETAIL_SINK_INIT_HELPERS_HPP_INCLUDED_
0018 
0019 #include <string>
0020 #include <boost/parameter/binding.hpp>
0021 #include <boost/type_traits/is_void.hpp>
0022 #include <boost/type_traits/is_array.hpp>
0023 #include <boost/type_traits/integral_constant.hpp>
0024 #include <boost/core/enable_if.hpp>
0025 #include <boost/utility/string_view_fwd.hpp>
0026 #include <boost/log/detail/config.hpp>
0027 #if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
0028 #include <string_view>
0029 #endif
0030 #include <boost/log/core/core.hpp>
0031 #include <boost/log/expressions/filter.hpp>
0032 #include <boost/log/expressions/formatter.hpp>
0033 #include <boost/log/utility/setup/filter_parser.hpp>
0034 #include <boost/log/utility/setup/formatter_parser.hpp>
0035 #include <boost/log/keywords/filter.hpp>
0036 #include <boost/log/keywords/format.hpp>
0037 #include <boost/log/detail/is_character_type.hpp>
0038 #include <boost/log/detail/header.hpp>
0039 
0040 #ifdef BOOST_HAS_PRAGMA_ONCE
0041 #pragma once
0042 #endif
0043 
0044 namespace boost {
0045 
0046 BOOST_LOG_OPEN_NAMESPACE
0047 
0048 namespace aux {
0049 
0050 // The function creates a filter functional object from the provided argument
0051 template< typename CharT >
0052 inline typename boost::enable_if_c<
0053     log::aux::is_character_type< CharT >::value,
0054     filter
0055 >::type acquire_filter(const CharT* filter)
0056 {
0057     return boost::log::parse_filter(filter);
0058 }
0059 
0060 template< typename CharT, typename TraitsT, typename AllocatorT >
0061 inline filter acquire_filter(std::basic_string< CharT, TraitsT, AllocatorT > const& filter)
0062 {
0063     return boost::log::parse_filter(filter);
0064 }
0065 
0066 #if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
0067 template< typename CharT, typename TraitsT >
0068 inline filter acquire_filter(std::basic_string_view< CharT, TraitsT > const& filter)
0069 {
0070     const CharT* p = filter.data();
0071     return boost::log::parse_filter(p, p + filter.size());
0072 }
0073 #endif // !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
0074 
0075 template< typename CharT, typename TraitsT >
0076 inline filter acquire_filter(boost::basic_string_view< CharT, TraitsT > const& filter)
0077 {
0078     const CharT* p = filter.data();
0079     return boost::log::parse_filter(p, p + filter.size());
0080 }
0081 
0082 template< typename FilterT >
0083 inline typename boost::disable_if_c<
0084     boost::is_array< FilterT >::value,
0085     FilterT const&
0086 >::type acquire_filter(FilterT const& filter)
0087 {
0088     return filter;
0089 }
0090 
0091 // The function installs filter into the sink, if provided in the arguments pack
0092 template< typename SinkT, typename ArgsT >
0093 inline void setup_filter(SinkT&, ArgsT const&, boost::true_type)
0094 {
0095 }
0096 
0097 template< typename SinkT, typename ArgsT >
0098 inline void setup_filter(SinkT& s, ArgsT const& args, boost::false_type)
0099 {
0100     s.set_filter(aux::acquire_filter(args[keywords::filter]));
0101 }
0102 
0103 
0104 // The function creates a formatter functional object from the provided argument
0105 template< typename CharT >
0106 inline typename boost::enable_if_c<
0107     log::aux::is_character_type< CharT >::value,
0108     basic_formatter< CharT >
0109 >::type acquire_formatter(const CharT* formatter)
0110 {
0111     return boost::log::parse_formatter(formatter);
0112 }
0113 
0114 template< typename CharT, typename TraitsT, typename AllocatorT >
0115 inline basic_formatter< CharT > acquire_formatter(std::basic_string< CharT, TraitsT, AllocatorT > const& formatter)
0116 {
0117     return boost::log::parse_formatter(formatter);
0118 }
0119 
0120 #if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
0121 template< typename CharT, typename TraitsT >
0122 inline basic_formatter< CharT > acquire_formatter(std::basic_string_view< CharT, TraitsT > const& formatter)
0123 {
0124     const CharT* p = formatter.data();
0125     return boost::log::parse_formatter(p, p + formatter.size());
0126 }
0127 #endif // !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
0128 
0129 template< typename CharT, typename TraitsT >
0130 inline basic_formatter< CharT > acquire_formatter(boost::basic_string_view< CharT, TraitsT > const& formatter)
0131 {
0132     const CharT* p = formatter.data();
0133     return boost::log::parse_formatter(p, p + formatter.size());
0134 }
0135 
0136 template< typename FormatterT >
0137 inline typename boost::disable_if_c<
0138     boost::is_array< FormatterT >::value,
0139     FormatterT const&
0140 >::type acquire_formatter(FormatterT const& formatter)
0141 {
0142     return formatter;
0143 }
0144 
0145 // The function installs filter into the sink, if provided in the arguments pack
0146 template< typename SinkT, typename ArgsT >
0147 inline void setup_formatter(SinkT&, ArgsT const&, boost::true_type)
0148 {
0149 }
0150 
0151 template< typename SinkT, typename ArgsT >
0152 inline void setup_formatter(SinkT& s, ArgsT const& args, boost::false_type)
0153 {
0154     s.set_formatter(aux::acquire_formatter(args[keywords::format]));
0155 }
0156 
0157 } // namespace aux
0158 
0159 BOOST_LOG_CLOSE_NAMESPACE // namespace log
0160 
0161 } // namespace boost
0162 
0163 #include <boost/log/detail/footer.hpp>
0164 
0165 #endif // BOOST_LOG_DETAIL_SINK_INIT_HELPERS_HPP_INCLUDED_