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 formatters/named_scope.hpp Chris@16: * \author Andrey Semashev Chris@16: * \date 11.11.2012 Chris@16: * Chris@16: * The header contains a formatter function for named scope attribute values. Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_LOG_EXPRESSIONS_FORMATTERS_NAMED_SCOPE_HPP_INCLUDED_ Chris@16: #define BOOST_LOG_EXPRESSIONS_FORMATTERS_NAMED_SCOPE_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: #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: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@101: #include Chris@101: #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 expressions { Chris@16: Chris@16: //! Scope iteration directions Chris@16: enum scope_iteration_direction Chris@16: { Chris@16: forward, //!< Iterate through scopes from outermost to innermost Chris@16: reverse //!< Iterate through scopes from innermost to outermost Chris@16: }; Chris@16: Chris@16: namespace aux { Chris@16: Chris@16: #ifdef BOOST_LOG_USE_CHAR Chris@16: //! Parses the named scope format string and constructs the formatter function Chris@16: BOOST_LOG_API boost::log::aux::light_function< void (basic_formatting_ostream< char >&, attributes::named_scope::value_type::value_type const&) > Chris@16: parse_named_scope_format(const char* begin, const char* end); Chris@16: #endif Chris@16: Chris@16: #ifdef BOOST_LOG_USE_WCHAR_T Chris@16: //! Parses the named scope format string and constructs the formatter function Chris@16: BOOST_LOG_API boost::log::aux::light_function< void (basic_formatting_ostream< wchar_t >&, attributes::named_scope::value_type::value_type const&) > Chris@16: parse_named_scope_format(const wchar_t* begin, const wchar_t* end); Chris@16: #endif Chris@16: Chris@16: //! Parses the named scope format string and constructs the formatter function Chris@16: template< typename CharT > Chris@16: inline boost::log::aux::light_function< void (basic_formatting_ostream< CharT >&, attributes::named_scope::value_type::value_type const&) > Chris@16: parse_named_scope_format(const CharT* format) Chris@16: { Chris@16: return parse_named_scope_format(format, format + std::char_traits< CharT >::length(format)); Chris@16: } Chris@16: Chris@16: //! Parses the named scope format string and constructs the formatter function Chris@16: template< typename CharT, typename TraitsT, typename AllocatorT > Chris@16: inline boost::log::aux::light_function< void (basic_formatting_ostream< CharT >&, attributes::named_scope::value_type::value_type const&) > Chris@16: parse_named_scope_format(std::basic_string< CharT, TraitsT, AllocatorT > const& format) Chris@16: { Chris@16: const CharT* p = format.c_str(); Chris@16: return parse_named_scope_format(p, p + format.size()); Chris@16: } Chris@16: Chris@16: //! Parses the named scope format string and constructs the formatter function Chris@16: template< typename CharT, typename TraitsT > Chris@16: inline boost::log::aux::light_function< void (basic_formatting_ostream< CharT >&, attributes::named_scope::value_type::value_type const&) > Chris@16: parse_named_scope_format(basic_string_literal< CharT, TraitsT > const& format) Chris@16: { Chris@16: const CharT* p = format.c_str(); Chris@16: return parse_named_scope_format(p, p + format.size()); Chris@16: } Chris@16: Chris@16: template< typename CharT > Chris@16: class format_named_scope_impl Chris@16: { Chris@16: public: Chris@16: //! Function result type Chris@16: typedef void result_type; Chris@16: Chris@16: //! Character type Chris@16: typedef CharT char_type; Chris@16: //! String type Chris@16: typedef std::basic_string< char_type > string_type; Chris@16: //! Formatting stream type Chris@16: typedef basic_formatting_ostream< char_type > stream_type; Chris@16: //! Attribute value type Chris@16: typedef attributes::named_scope::value_type value_type; Chris@16: //! Named scope formatter Chris@16: typedef boost::log::aux::light_function< void (stream_type&, value_type::value_type const&) > element_formatter_type; Chris@16: Chris@16: private: Chris@16: //! Element formatting function Chris@16: element_formatter_type m_element_formatter; Chris@16: //! Element delimiter Chris@16: string_type m_delimiter; Chris@101: //! Incomplete list marker Chris@101: string_type m_incomplete_marker; Chris@101: //! Empty list marker Chris@101: string_type m_empty_marker; Chris@16: //! Maximum number of elements to output Chris@16: value_type::size_type m_depth; Chris@16: //! Iteration direction Chris@16: scope_iteration_direction m_direction; Chris@16: Chris@16: public: Chris@16: //! Initializing constructor Chris@101: format_named_scope_impl Chris@101: ( Chris@101: element_formatter_type const& element_formatter, Chris@101: string_type const& delimiter, Chris@101: string_type const& incomplete_marker, Chris@101: string_type const& empty_marker, Chris@101: value_type::size_type depth, Chris@101: scope_iteration_direction direction Chris@101: ) : Chris@16: m_element_formatter(element_formatter), Chris@16: m_delimiter(delimiter), Chris@101: m_incomplete_marker(incomplete_marker), Chris@101: m_empty_marker(empty_marker), Chris@16: m_depth(depth), Chris@16: m_direction(direction) Chris@16: { Chris@16: } Chris@16: //! Copy constructor Chris@16: format_named_scope_impl(format_named_scope_impl const& that) : Chris@16: m_element_formatter(that.m_element_formatter), Chris@16: m_delimiter(that.m_delimiter), Chris@101: m_incomplete_marker(that.m_incomplete_marker), Chris@101: m_empty_marker(that.m_empty_marker), Chris@16: m_depth(that.m_depth), Chris@16: m_direction(that.m_direction) Chris@16: { Chris@16: } Chris@16: Chris@16: //! Formatting operator Chris@16: result_type operator() (stream_type& strm, value_type const& scopes) const Chris@16: { Chris@101: if (!scopes.empty()) Chris@101: { Chris@101: if (m_direction == expressions::forward) Chris@101: format_forward(strm, scopes); Chris@101: else Chris@101: format_reverse(strm, scopes); Chris@101: } Chris@16: else Chris@101: { Chris@101: strm << m_empty_marker; Chris@101: } Chris@16: } Chris@16: Chris@16: private: Chris@16: //! The function performs formatting of the extracted scope stack in forward direction Chris@16: void format_forward(stream_type& strm, value_type const& scopes) const Chris@16: { Chris@16: value_type::const_iterator it, end = scopes.end(); Chris@16: if (m_depth > 0) Chris@16: { Chris@16: value_type::size_type const scopes_to_iterate = (std::min)(m_depth, scopes.size()); Chris@16: it = scopes.end(); Chris@16: std::advance(it, -static_cast< value_type::difference_type >(scopes_to_iterate)); Chris@16: } Chris@16: else Chris@16: { Chris@16: it = scopes.begin(); Chris@16: } Chris@16: Chris@16: if (it != end) Chris@16: { Chris@16: if (it != scopes.begin()) Chris@101: strm << m_incomplete_marker; Chris@16: Chris@16: m_element_formatter(strm, *it); Chris@16: for (++it; it != end; ++it) Chris@16: { Chris@16: strm << m_delimiter; Chris@16: m_element_formatter(strm, *it); Chris@16: } Chris@16: } Chris@16: } Chris@16: //! The function performs formatting of the extracted scope stack in reverse direction Chris@16: void format_reverse(stream_type& strm, value_type const& scopes) const Chris@16: { Chris@16: value_type::const_reverse_iterator it = scopes.rbegin(), end; Chris@16: if (m_depth > 0) Chris@16: { Chris@16: value_type::size_type const scopes_to_iterate = (std::min)(m_depth, scopes.size()); Chris@16: end = it; Chris@16: std::advance(end, static_cast< value_type::difference_type >(scopes_to_iterate)); Chris@16: } Chris@16: else Chris@16: { Chris@16: end = scopes.rend(); Chris@16: } Chris@16: Chris@16: if (it != end) Chris@16: { Chris@16: m_element_formatter(strm, *it); Chris@16: for (++it; it != end; ++it) Chris@16: { Chris@16: strm << m_delimiter; Chris@16: m_element_formatter(strm, *it); Chris@16: } Chris@16: Chris@16: if (it != scopes.rend()) Chris@101: strm << m_incomplete_marker; Chris@16: } Chris@16: } Chris@16: }; Chris@16: Chris@16: } // namespace aux Chris@16: Chris@16: /*! Chris@16: * Named scope formatter terminal. Chris@16: */ Chris@16: template< typename FallbackPolicyT, typename CharT > Chris@16: class format_named_scope_terminal Chris@16: { Chris@16: public: Chris@16: //! Internal typedef for type categorization Chris@16: typedef void _is_boost_log_terminal; Chris@16: Chris@16: //! Attribute value type Chris@16: typedef attributes::named_scope::value_type value_type; Chris@16: //! Fallback policy Chris@16: typedef FallbackPolicyT fallback_policy; Chris@16: //! Character type Chris@16: typedef CharT char_type; Chris@16: //! String type Chris@16: typedef std::basic_string< char_type > string_type; Chris@16: //! Formatting stream type Chris@16: typedef basic_formatting_ostream< char_type > stream_type; Chris@16: //! Formatter function Chris@16: typedef aux::format_named_scope_impl< char_type > formatter_function_type; Chris@16: Chris@16: //! Function result type Chris@16: typedef string_type result_type; Chris@16: Chris@16: private: Chris@16: //! Attribute value visitor invoker Chris@16: typedef value_visitor_invoker< value_type, fallback_policy > visitor_invoker_type; Chris@16: Chris@16: private: Chris@16: //! Attribute name Chris@16: attribute_name m_name; Chris@16: //! Formatter function Chris@16: formatter_function_type m_formatter; Chris@16: //! Attribute value visitor invoker Chris@16: visitor_invoker_type m_visitor_invoker; Chris@16: Chris@16: public: Chris@16: //! Initializing constructor Chris@16: template< typename FormatT > Chris@101: format_named_scope_terminal Chris@101: ( Chris@101: attribute_name const& name, Chris@101: fallback_policy const& fallback, Chris@101: FormatT const& element_format, Chris@101: string_type const& delimiter, Chris@101: string_type const& incomplete_marker, Chris@101: string_type const& empty_marker, Chris@101: value_type::size_type depth, Chris@101: scope_iteration_direction direction Chris@101: ) : Chris@101: m_name(name), m_formatter(aux::parse_named_scope_format(element_format), delimiter, incomplete_marker, empty_marker, depth, direction), m_visitor_invoker(fallback) Chris@16: { Chris@16: } Chris@16: //! Copy constructor Chris@16: format_named_scope_terminal(format_named_scope_terminal const& that) : Chris@16: m_name(that.m_name), m_formatter(that.m_formatter), m_visitor_invoker(that.m_visitor_invoker) Chris@16: { Chris@16: } Chris@16: Chris@16: //! Returns attribute name Chris@16: attribute_name get_name() const Chris@16: { Chris@16: return m_name; Chris@16: } Chris@16: Chris@16: //! Returns fallback policy Chris@16: fallback_policy const& get_fallback_policy() const Chris@16: { Chris@16: return m_visitor_invoker.get_fallback_policy(); Chris@16: } Chris@16: Chris@16: //! Retruns formatter function Chris@16: formatter_function_type const& get_formatter_function() const Chris@16: { Chris@16: return m_formatter; Chris@16: } Chris@16: Chris@16: //! Invokation operator Chris@16: template< typename ContextT > Chris@16: result_type operator() (ContextT const& ctx) Chris@16: { Chris@16: string_type str; Chris@16: stream_type strm(str); Chris@16: m_visitor_invoker(m_name, fusion::at_c< 0 >(phoenix::env(ctx).args()), binder1st< formatter_function_type&, stream_type& >(m_formatter, strm)); Chris@16: strm.flush(); Chris@16: return boost::move(str); Chris@16: } Chris@16: Chris@16: //! Invokation operator Chris@16: template< typename ContextT > Chris@16: result_type operator() (ContextT const& ctx) const Chris@16: { Chris@16: string_type str; Chris@16: stream_type strm(str); Chris@16: m_visitor_invoker(m_name, fusion::at_c< 0 >(phoenix::env(ctx).args()), binder1st< formatter_function_type const&, stream_type& >(m_formatter, strm)); Chris@16: strm.flush(); Chris@16: return boost::move(str); Chris@16: } Chris@16: Chris@16: BOOST_DELETED_FUNCTION(format_named_scope_terminal()) Chris@16: }; Chris@16: Chris@16: /*! Chris@16: * Named scope formatter actor. Chris@16: */ Chris@16: template< typename FallbackPolicyT, typename CharT, template< typename > class ActorT = phoenix::actor > Chris@16: class format_named_scope_actor : Chris@16: public ActorT< format_named_scope_terminal< FallbackPolicyT, CharT > > Chris@16: { Chris@16: public: Chris@16: //! Character type Chris@16: typedef CharT char_type; Chris@16: //! Fallback policy Chris@16: typedef FallbackPolicyT fallback_policy; Chris@16: //! Base terminal type Chris@16: typedef format_named_scope_terminal< fallback_policy, char_type > terminal_type; Chris@16: //! Attribute value type Chris@16: typedef typename terminal_type::value_type value_type; Chris@16: //! Formatter function Chris@16: typedef typename terminal_type::formatter_function_type formatter_function_type; Chris@16: Chris@16: //! Base actor type Chris@16: typedef ActorT< terminal_type > base_type; Chris@16: Chris@16: public: Chris@16: //! Initializing constructor Chris@16: explicit format_named_scope_actor(base_type const& act) : base_type(act) Chris@16: { Chris@16: } Chris@16: Chris@16: /*! Chris@16: * \returns The attribute name Chris@16: */ Chris@16: attribute_name get_name() const Chris@16: { Chris@16: return this->proto_expr_.child0.get_name(); Chris@16: } Chris@16: Chris@16: /*! Chris@16: * \returns Fallback policy Chris@16: */ Chris@16: fallback_policy const& get_fallback_policy() const Chris@16: { Chris@16: return this->proto_expr_.child0.get_fallback_policy(); Chris@16: } Chris@16: Chris@16: /*! Chris@16: * \returns Formatter function Chris@16: */ Chris@16: formatter_function_type const& get_formatter_function() const Chris@16: { Chris@16: return this->proto_expr_.child0.get_formatter_function(); Chris@16: } Chris@16: }; Chris@16: Chris@16: #ifndef BOOST_LOG_DOXYGEN_PASS Chris@16: Chris@16: #define BOOST_LOG_AUX_OVERLOAD(left_ref, right_ref)\ Chris@16: template< typename LeftExprT, typename FallbackPolicyT, typename CharT >\ Chris@16: BOOST_FORCEINLINE phoenix::actor< aux::attribute_output_terminal< phoenix::actor< LeftExprT >, attributes::named_scope::value_type, FallbackPolicyT, typename format_named_scope_actor< FallbackPolicyT, CharT >::formatter_function_type > >\ Chris@16: operator<< (phoenix::actor< LeftExprT > left_ref left, format_named_scope_actor< FallbackPolicyT, CharT > right_ref right)\ Chris@16: {\ Chris@16: typedef aux::attribute_output_terminal< phoenix::actor< LeftExprT >, attributes::named_scope::value_type, FallbackPolicyT, typename format_named_scope_actor< FallbackPolicyT, CharT >::formatter_function_type > terminal_type;\ Chris@16: phoenix::actor< terminal_type > actor = {{ terminal_type(left, right.get_name(), right.get_formatter_function(), right.get_fallback_policy()) }};\ Chris@16: return actor;\ Chris@16: } Chris@16: Chris@16: #include Chris@16: Chris@16: #undef BOOST_LOG_AUX_OVERLOAD Chris@16: Chris@16: #endif // BOOST_LOG_DOXYGEN_PASS Chris@16: Chris@16: namespace aux { Chris@16: Chris@101: //! Auxiliary traits to acquire default formatter parameters depending on the character type Chris@16: template< typename CharT > Chris@101: struct default_named_scope_params; Chris@16: Chris@16: #ifdef BOOST_LOG_USE_CHAR Chris@16: template< > Chris@101: struct default_named_scope_params< char > Chris@16: { Chris@101: static const char* forward_delimiter() { return "->"; } Chris@101: static const char* reverse_delimiter() { return "<-"; } Chris@101: static const char* incomplete_marker() { return "..."; } Chris@101: static const char* empty_marker() { return ""; } Chris@16: }; Chris@16: #endif Chris@16: #ifdef BOOST_LOG_USE_WCHAR_T Chris@16: template< > Chris@101: struct default_named_scope_params< wchar_t > Chris@16: { Chris@101: static const wchar_t* forward_delimiter() { return L"->"; } Chris@101: static const wchar_t* reverse_delimiter() { return L"<-"; } Chris@101: static const wchar_t* incomplete_marker() { return L"..."; } Chris@101: static const wchar_t* empty_marker() { return L""; } Chris@16: }; Chris@16: #endif Chris@16: Chris@16: template< typename CharT, template< typename > class ActorT, typename FallbackPolicyT, typename ArgsT > Chris@16: BOOST_FORCEINLINE format_named_scope_actor< FallbackPolicyT, CharT, ActorT > format_named_scope(attribute_name const& name, FallbackPolicyT const& fallback, ArgsT const& args) Chris@16: { Chris@16: typedef format_named_scope_actor< FallbackPolicyT, CharT, ActorT > actor_type; Chris@16: typedef typename actor_type::terminal_type terminal_type; Chris@101: typedef default_named_scope_params< CharT > default_params; Chris@16: scope_iteration_direction dir = args[keywords::iteration | expressions::forward]; Chris@101: const CharT* default_delimiter = (dir == expressions::forward ? default_params::forward_delimiter() : default_params::reverse_delimiter()); Chris@16: typename actor_type::base_type act = Chris@16: {{ Chris@16: terminal_type Chris@16: ( Chris@16: name, Chris@16: fallback, Chris@16: args[keywords::format], Chris@16: args[keywords::delimiter | default_delimiter], Chris@101: args[keywords::incomplete_marker | default_params::incomplete_marker()], Chris@101: args[keywords::empty_marker | default_params::empty_marker()], Chris@16: args[keywords::depth | static_cast< attributes::named_scope::value_type::size_type >(0)], Chris@16: dir Chris@16: ) Chris@16: }}; Chris@16: return actor_type(act); Chris@16: } Chris@16: Chris@16: } // namespace aux Chris@16: Chris@16: /*! Chris@16: * The function generates a manipulator node in a template expression. The manipulator must participate in a formatting Chris@16: * expression (stream output or \c format placeholder filler). Chris@16: * Chris@16: * \param name Attribute name Chris@16: * \param element_format Format string for a single named scope Chris@16: */ Chris@16: template< typename CharT > Chris@16: BOOST_FORCEINLINE format_named_scope_actor< fallback_to_none, CharT > format_named_scope(attribute_name const& name, const CharT* element_format) Chris@16: { Chris@16: typedef format_named_scope_actor< fallback_to_none, CharT > actor_type; Chris@16: typedef typename actor_type::terminal_type terminal_type; Chris@16: typename actor_type::base_type act = {{ terminal_type(name, fallback_to_none(), element_format) }}; Chris@16: return actor_type(act); Chris@16: } Chris@16: Chris@16: /*! Chris@16: * The function generates a manipulator node in a template expression. The manipulator must participate in a formatting Chris@16: * expression (stream output or \c format placeholder filler). Chris@16: * Chris@16: * \param name Attribute name Chris@16: * \param element_format Format string for a single named scope Chris@16: */ Chris@16: template< typename CharT > Chris@16: BOOST_FORCEINLINE format_named_scope_actor< fallback_to_none, CharT > format_named_scope(attribute_name const& name, std::basic_string< CharT > const& element_format) Chris@16: { Chris@16: typedef format_named_scope_actor< fallback_to_none, CharT > actor_type; Chris@16: typedef typename actor_type::terminal_type terminal_type; Chris@16: typename actor_type::base_type act = {{ terminal_type(name, fallback_to_none(), element_format) }}; Chris@16: return actor_type(act); Chris@16: } Chris@16: Chris@16: /*! Chris@16: * The function generates a manipulator node in a template expression. The manipulator must participate in a formatting Chris@16: * expression (stream output or \c format placeholder filler). Chris@16: * Chris@16: * \param keyword Attribute keyword Chris@16: * \param element_format Format string for a single named scope Chris@16: */ Chris@16: template< typename DescriptorT, template< typename > class ActorT, typename CharT > Chris@16: BOOST_FORCEINLINE format_named_scope_actor< fallback_to_none, CharT, ActorT > Chris@16: format_named_scope(attribute_keyword< DescriptorT, ActorT > const& keyword, const CharT* element_format) Chris@16: { Chris@16: BOOST_STATIC_ASSERT_MSG((is_same< typename DescriptorT::value_type, attributes::named_scope::value_type >::value),\ Chris@16: "Boost.Log: Named scope formatter only accepts attribute values of type attributes::named_scope::value_type."); Chris@16: Chris@16: typedef format_named_scope_actor< fallback_to_none, CharT, ActorT > actor_type; Chris@16: typedef typename actor_type::terminal_type terminal_type; Chris@16: typename actor_type::base_type act = {{ terminal_type(keyword.get_name(), fallback_to_none(), element_format) }}; Chris@16: return actor_type(act); Chris@16: } Chris@16: Chris@16: /*! Chris@16: * The function generates a manipulator node in a template expression. The manipulator must participate in a formatting Chris@16: * expression (stream output or \c format placeholder filler). Chris@16: * Chris@16: * \param keyword Attribute keyword Chris@16: * \param element_format Format string for a single named scope Chris@16: */ Chris@16: template< typename DescriptorT, template< typename > class ActorT, typename CharT > Chris@16: BOOST_FORCEINLINE format_named_scope_actor< fallback_to_none, CharT, ActorT > Chris@16: format_named_scope(attribute_keyword< DescriptorT, ActorT > const& keyword, std::basic_string< CharT > const& element_format) Chris@16: { Chris@16: BOOST_STATIC_ASSERT_MSG((is_same< typename DescriptorT::value_type, attributes::named_scope::value_type >::value),\ Chris@16: "Boost.Log: Named scope formatter only accepts attribute values of type attributes::named_scope::value_type."); Chris@16: Chris@16: typedef format_named_scope_actor< fallback_to_none, CharT, ActorT > actor_type; Chris@16: typedef typename actor_type::terminal_type terminal_type; Chris@16: typename actor_type::base_type act = {{ terminal_type(keyword.get_name(), fallback_to_none(), element_format) }}; Chris@16: return actor_type(act); Chris@16: } Chris@16: Chris@16: /*! Chris@16: * The function generates a manipulator node in a template expression. The manipulator must participate in a formatting Chris@16: * expression (stream output or \c format placeholder filler). Chris@16: * Chris@16: * \param placeholder Attribute placeholder Chris@16: * \param element_format Format string for a single named scope Chris@16: */ Chris@16: template< typename T, typename FallbackPolicyT, typename TagT, template< typename > class ActorT, typename CharT > Chris@16: BOOST_FORCEINLINE format_named_scope_actor< FallbackPolicyT, CharT, ActorT > Chris@16: format_named_scope(attribute_actor< T, FallbackPolicyT, TagT, ActorT > const& placeholder, const CharT* element_format) Chris@16: { Chris@16: BOOST_STATIC_ASSERT_MSG((is_same< T, attributes::named_scope::value_type >::value),\ Chris@16: "Boost.Log: Named scope formatter only accepts attribute values of type attributes::named_scope::value_type."); Chris@16: Chris@16: typedef format_named_scope_actor< FallbackPolicyT, CharT, ActorT > actor_type; Chris@16: typedef typename actor_type::terminal_type terminal_type; Chris@16: typename actor_type::base_type act = {{ terminal_type(placeholder.get_name(), placeholder.get_fallback_policy(), element_format) }}; Chris@16: return actor_type(act); Chris@16: } Chris@16: Chris@16: /*! Chris@16: * The function generates a manipulator node in a template expression. The manipulator must participate in a formatting Chris@16: * expression (stream output or \c format placeholder filler). Chris@16: * Chris@16: * \param placeholder Attribute placeholder Chris@16: * \param element_format Format string for a single named scope Chris@16: */ Chris@16: template< typename T, typename FallbackPolicyT, typename TagT, template< typename > class ActorT, typename CharT > Chris@16: BOOST_FORCEINLINE format_named_scope_actor< FallbackPolicyT, CharT, ActorT > Chris@16: format_named_scope(attribute_actor< T, FallbackPolicyT, TagT, ActorT > const& placeholder, std::basic_string< CharT > const& element_format) Chris@16: { Chris@16: BOOST_STATIC_ASSERT_MSG((is_same< T, attributes::named_scope::value_type >::value),\ Chris@16: "Boost.Log: Named scope formatter only accepts attribute values of type attributes::named_scope::value_type."); Chris@16: Chris@16: typedef format_named_scope_actor< FallbackPolicyT, CharT, ActorT > actor_type; Chris@16: typedef typename actor_type::terminal_type terminal_type; Chris@16: typename actor_type::base_type act = {{ terminal_type(placeholder.get_name(), placeholder.get_fallback_policy(), element_format) }}; Chris@16: return actor_type(act); Chris@16: } Chris@16: Chris@16: #if !defined(BOOST_LOG_DOXYGEN_PASS) Chris@16: Chris@16: # define BOOST_PP_FILENAME_1 Chris@101: # define BOOST_PP_ITERATION_LIMITS (1, 6) Chris@16: # include BOOST_PP_ITERATE() Chris@16: Chris@16: #else // BOOST_LOG_DOXYGEN_PASS Chris@16: Chris@16: /*! Chris@16: * Formatter generator. Construct the named scope formatter with the specified formatting parameters. Chris@16: * Chris@16: * \param name Attribute name Chris@16: * \param args An set of named parameters. Supported parameters: Chris@16: * \li \c format - A format string for named scopes. The string can contain "%n", "%f" and "%l" placeholders for the scope name, file and line number, respectively. This parameter is mandatory. Chris@16: * \li \c delimiter - A string that is used to delimit the formatted scope names. Default: "->" or "<-", depending on the iteration direction. Chris@101: * \li \c incomplete_marker - A string that is used to indicate that the list was printed incomplete because of depth limitation. Default: "...". Chris@101: * \li \c empty_marker - A string that is output in case if the scope list is empty. Default: "", i.e. nothing is output. Chris@16: * \li \c iteration - Iteration direction, see \c scope_iteration_direction enumeration. Default: forward. Chris@16: * \li \c depth - Iteration depth. Default: unlimited. Chris@16: */ Chris@16: template< typename... ArgsT > Chris@16: unspecified format_named_scope(attribute_name const& name, ArgsT... const& args); Chris@16: Chris@16: /*! \overload */ Chris@16: template< typename DescriptorT, template< typename > class ActorT, typename... ArgsT > Chris@16: unspecified format_named_scope(attribute_keyword< DescriptorT, ActorT > const& keyword, ArgsT... const& args); Chris@16: Chris@16: /*! \overload */ Chris@16: template< typename T, typename FallbackPolicyT, typename TagT, template< typename > class ActorT, typename... ArgsT > Chris@16: unspecified format_named_scope(attribute_actor< T, FallbackPolicyT, TagT, ActorT > const& placeholder, ArgsT... const& args); Chris@16: Chris@16: #endif // BOOST_LOG_DOXYGEN_PASS Chris@16: Chris@16: } // namespace expressions Chris@16: Chris@16: BOOST_LOG_CLOSE_NAMESPACE // namespace log Chris@16: Chris@16: #ifndef BOOST_LOG_DOXYGEN_PASS Chris@16: Chris@16: namespace phoenix { Chris@16: Chris@16: namespace result_of { Chris@16: Chris@16: template< typename FallbackPolicyT, typename CharT > Chris@16: struct is_nullary< custom_terminal< boost::log::expressions::format_named_scope_terminal< FallbackPolicyT, CharT > > > : Chris@16: public mpl::false_ Chris@16: { Chris@16: }; Chris@16: Chris@16: } // namespace result_of Chris@16: Chris@16: } // namespace phoenix Chris@16: Chris@16: #endif Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif // BOOST_LOG_EXPRESSIONS_FORMATTERS_NAMED_SCOPE_HPP_INCLUDED_