Chris@16: /* Chris@101: * Copyright Andrey Semashev 2007 - 2015. Chris@16: * Distributed under the Boost Software License, Version 1.0. Chris@16: * (See accompanying file LICENSE_1_0.txt or copy at Chris@16: * http://www.boost.org/LICENSE_1_0.txt) Chris@16: */ Chris@16: /*! Chris@16: * \file sink_init_helpers.hpp Chris@16: * \author Andrey Semashev Chris@16: * \date 14.03.2009 Chris@16: * Chris@16: * \brief This header is the Boost.Log library implementation, see the library documentation Chris@16: * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html. Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_LOG_DETAIL_SINK_INIT_HELPERS_HPP_INCLUDED_ Chris@16: #define BOOST_LOG_DETAIL_SINK_INIT_HELPERS_HPP_INCLUDED_ Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #ifdef BOOST_HAS_PRAGMA_ONCE Chris@16: #pragma once Chris@16: #endif Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: BOOST_LOG_OPEN_NAMESPACE Chris@16: Chris@16: namespace aux { Chris@16: Chris@16: // The function creates a filter functional object from the provided argument Chris@16: template< typename CharT > Chris@16: inline filter acquire_filter(const CharT* filter) Chris@16: { Chris@16: return boost::log::parse_filter(filter); Chris@16: } Chris@16: template< typename CharT, typename TraitsT, typename AllocatorT > Chris@16: inline filter acquire_filter(std::basic_string< CharT, TraitsT, AllocatorT > const& filter) Chris@16: { Chris@16: return boost::log::parse_filter(filter); Chris@16: } Chris@16: template< typename FilterT > Chris@16: inline typename enable_if< Chris@16: phoenix::is_actor< FilterT >, Chris@16: FilterT const& Chris@16: >::type acquire_filter(FilterT const& filter) Chris@16: { Chris@16: return filter; Chris@16: } Chris@16: Chris@16: // The function installs filter into the sink, if provided in the arguments pack Chris@16: template< typename SinkT, typename ArgsT > Chris@16: inline void setup_filter(SinkT&, ArgsT const&, mpl::true_) Chris@16: { Chris@16: } Chris@16: Chris@16: template< typename SinkT, typename ArgsT > Chris@16: inline void setup_filter(SinkT& s, ArgsT const& args, mpl::false_) Chris@16: { Chris@16: s.set_filter(aux::acquire_filter(args[keywords::filter])); Chris@16: } Chris@16: Chris@16: Chris@16: // The function creates a filter functional object from the provided argument Chris@16: template< typename CharT > Chris@16: inline basic_formatter< CharT > acquire_formatter(const CharT* formatter) Chris@16: { Chris@16: return boost::log::parse_formatter(formatter); Chris@16: } Chris@16: template< typename CharT, typename TraitsT, typename AllocatorT > Chris@16: inline basic_formatter< CharT > acquire_formatter(std::basic_string< CharT, TraitsT, AllocatorT > const& formatter) Chris@16: { Chris@16: return boost::log::parse_formatter(formatter); Chris@16: } Chris@16: template< typename FormatterT > Chris@16: inline typename enable_if< Chris@16: phoenix::is_actor< FormatterT >, Chris@16: FormatterT const& Chris@16: >::type acquire_formatter(FormatterT const& formatter) Chris@16: { Chris@16: return formatter; Chris@16: } Chris@16: Chris@16: // The function installs filter into the sink, if provided in the arguments pack Chris@16: template< typename SinkT, typename ArgsT > Chris@16: inline void setup_formatter(SinkT&, ArgsT const&, mpl::true_) Chris@16: { Chris@16: } Chris@16: Chris@16: template< typename SinkT, typename ArgsT > Chris@16: inline void setup_formatter(SinkT& s, ArgsT const& args, mpl::false_) Chris@16: { Chris@16: s.set_formatter(aux::acquire_formatter(args[keywords::format])); Chris@16: } Chris@16: Chris@16: } // namespace aux Chris@16: Chris@16: BOOST_LOG_CLOSE_NAMESPACE // namespace log Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif // BOOST_LOG_DETAIL_SINK_INIT_HELPERS_HPP_INCLUDED_