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 ends_with.hpp Chris@16: * \author Andrey Semashev Chris@16: * \date 02.09.2012 Chris@16: * Chris@16: * The header contains implementation of a \c ends_with predicate in template expressions. Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_LOG_EXPRESSIONS_PREDICATES_ENDS_WITH_HPP_INCLUDED_ Chris@16: #define BOOST_LOG_EXPRESSIONS_PREDICATES_ENDS_WITH_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: 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: /*! Chris@16: * The predicate checks if the attribute value ends with a substring. The attribute value is assumed to be of a string type. Chris@16: */ Chris@16: #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) Chris@16: Chris@16: template< typename T, typename SubstringT, typename FallbackPolicyT = fallback_to_none > Chris@16: using attribute_ends_with = aux::attribute_predicate< T, SubstringT, ends_with_fun, FallbackPolicyT >; Chris@16: Chris@16: #else // !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) Chris@16: Chris@16: template< typename T, typename SubstringT, typename FallbackPolicyT = fallback_to_none > Chris@16: class attribute_ends_with : Chris@16: public aux::attribute_predicate< T, SubstringT, ends_with_fun, FallbackPolicyT > Chris@16: { Chris@16: typedef aux::attribute_predicate< T, SubstringT, ends_with_fun, FallbackPolicyT > base_type; Chris@16: Chris@16: public: Chris@16: /*! Chris@16: * Initializing constructor Chris@16: * Chris@16: * \param name Attribute name Chris@16: * \param substring The expected attribute value ending Chris@16: */ Chris@16: attribute_ends_with(attribute_name const& name, SubstringT const& substring) : base_type(name, substring) Chris@16: { Chris@16: } Chris@16: Chris@16: /*! Chris@16: * Initializing constructor Chris@16: * Chris@16: * \param name Attribute name Chris@16: * \param substring The expected attribute value ending Chris@16: * \param arg Additional parameter for the fallback policy Chris@16: */ Chris@16: template< typename U > Chris@16: attribute_ends_with(attribute_name const& name, SubstringT const& substring, U const& arg) : base_type(name, substring, arg) Chris@16: { Chris@16: } Chris@16: }; Chris@16: Chris@16: #endif // !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) Chris@16: Chris@16: /*! Chris@16: * The function generates a terminal node in a template expression. The node will check if the attribute value, Chris@16: * which is assumed to be a string, ends with the specified substring. Chris@16: */ Chris@16: template< typename T, typename FallbackPolicyT, typename TagT, template< typename > class ActorT, typename SubstringT > Chris@16: BOOST_FORCEINLINE ActorT< aux::unary_function_terminal< attribute_ends_with< T, typename boost::log::aux::make_embedded_string_type< SubstringT >::type, FallbackPolicyT > > > Chris@16: ends_with(attribute_actor< T, FallbackPolicyT, TagT, ActorT > const& attr, SubstringT const& substring) Chris@16: { Chris@16: typedef aux::unary_function_terminal< attribute_ends_with< T, typename boost::log::aux::make_embedded_string_type< SubstringT >::type, FallbackPolicyT > > terminal_type; Chris@16: ActorT< terminal_type > act = {{ terminal_type(attr.get_name(), substring, attr.get_fallback_policy()) }}; Chris@16: return act; Chris@16: } Chris@16: Chris@16: /*! Chris@16: * The function generates a terminal node in a template expression. The node will check if the attribute value, Chris@16: * which is assumed to be a string, ends with the specified substring. Chris@16: */ Chris@16: template< typename DescriptorT, template< typename > class ActorT, typename SubstringT > Chris@16: BOOST_FORCEINLINE ActorT< aux::unary_function_terminal< attribute_ends_with< typename DescriptorT::value_type, typename boost::log::aux::make_embedded_string_type< SubstringT >::type > > > Chris@16: ends_with(attribute_keyword< DescriptorT, ActorT > const&, SubstringT const& substring) Chris@16: { Chris@16: typedef aux::unary_function_terminal< attribute_ends_with< typename DescriptorT::value_type, typename boost::log::aux::make_embedded_string_type< SubstringT >::type > > terminal_type; Chris@16: ActorT< terminal_type > act = {{ terminal_type(DescriptorT::get_name(), substring) }}; Chris@16: return act; Chris@16: } Chris@16: Chris@16: /*! Chris@16: * The function generates a terminal node in a template expression. The node will check if the attribute value, Chris@16: * which is assumed to be a string, ends with the specified substring. Chris@16: */ Chris@16: template< typename T, typename SubstringT > Chris@16: BOOST_FORCEINLINE phoenix::actor< aux::unary_function_terminal< attribute_ends_with< T, typename boost::log::aux::make_embedded_string_type< SubstringT >::type > > > Chris@16: ends_with(attribute_name const& name, SubstringT const& substring) Chris@16: { Chris@16: typedef aux::unary_function_terminal< attribute_ends_with< T, typename boost::log::aux::make_embedded_string_type< SubstringT >::type > > terminal_type; Chris@16: phoenix::actor< terminal_type > act = {{ terminal_type(name, substring) }}; Chris@16: return act; Chris@16: } Chris@16: Chris@16: } // namespace expressions 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_EXPRESSIONS_PREDICATES_ENDS_WITH_HPP_INCLUDED_