Back to home page

EIC code displayed by LXR

 
 

    


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

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   begins_with.hpp
0009  * \author Andrey Semashev
0010  * \date   02.09.2012
0011  *
0012  * The header contains implementation of a \c begins_with predicate in template expressions.
0013  */
0014 
0015 #ifndef BOOST_LOG_EXPRESSIONS_PREDICATES_BEGINS_WITH_HPP_INCLUDED_
0016 #define BOOST_LOG_EXPRESSIONS_PREDICATES_BEGINS_WITH_HPP_INCLUDED_
0017 
0018 #include <boost/phoenix/core/actor.hpp>
0019 #include <boost/log/detail/config.hpp>
0020 #include <boost/log/detail/embedded_string_type.hpp>
0021 #include <boost/log/detail/unary_function_terminal.hpp>
0022 #include <boost/log/detail/attribute_predicate.hpp>
0023 #include <boost/log/attributes/attribute_name.hpp>
0024 #include <boost/log/attributes/fallback_policy.hpp>
0025 #include <boost/log/expressions/attr_fwd.hpp>
0026 #include <boost/log/expressions/keyword_fwd.hpp>
0027 #include <boost/log/utility/functional/begins_with.hpp>
0028 #include <boost/log/detail/header.hpp>
0029 
0030 #ifdef BOOST_HAS_PRAGMA_ONCE
0031 #pragma once
0032 #endif
0033 
0034 namespace boost {
0035 
0036 BOOST_LOG_OPEN_NAMESPACE
0037 
0038 namespace expressions {
0039 
0040 /*!
0041  * The predicate checks if the attribute value begins with a substring. The attribute value is assumed to be of a string type.
0042  */
0043 #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
0044 
0045 template< typename T, typename SubstringT, typename FallbackPolicyT = fallback_to_none >
0046 using attribute_begins_with = aux::attribute_predicate< T, SubstringT, begins_with_fun, FallbackPolicyT >;
0047 
0048 #else // !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
0049 
0050 template< typename T, typename SubstringT, typename FallbackPolicyT = fallback_to_none >
0051 class attribute_begins_with :
0052     public aux::attribute_predicate< T, SubstringT, begins_with_fun, FallbackPolicyT >
0053 {
0054     typedef aux::attribute_predicate< T, SubstringT, begins_with_fun, FallbackPolicyT > base_type;
0055 
0056 public:
0057     /*!
0058      * Initializing constructor
0059      *
0060      * \param name Attribute name
0061      * \param substring The expected attribute value beginning
0062      */
0063     attribute_begins_with(attribute_name const& name, SubstringT const& substring) : base_type(name, substring)
0064     {
0065     }
0066 
0067     /*!
0068      * Initializing constructor
0069      *
0070      * \param name Attribute name
0071      * \param substring The expected attribute value beginning
0072      * \param arg Additional parameter for the fallback policy
0073      */
0074     template< typename U >
0075     attribute_begins_with(attribute_name const& name, SubstringT const& substring, U const& arg) : base_type(name, substring, arg)
0076     {
0077     }
0078 };
0079 
0080 #endif // !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
0081 
0082 /*!
0083  * The function generates a terminal node in a template expression. The node will check if the attribute value,
0084  * which is assumed to be a string, begins with the specified substring.
0085  */
0086 template< typename T, typename FallbackPolicyT, typename TagT, template< typename > class ActorT, typename SubstringT >
0087 BOOST_FORCEINLINE ActorT< aux::unary_function_terminal< attribute_begins_with< T, typename boost::log::aux::make_embedded_string_type< SubstringT >::type, FallbackPolicyT > > >
0088 begins_with(attribute_actor< T, FallbackPolicyT, TagT, ActorT > const& attr, SubstringT const& substring)
0089 {
0090     typedef aux::unary_function_terminal< attribute_begins_with< T, typename boost::log::aux::make_embedded_string_type< SubstringT >::type, FallbackPolicyT > > terminal_type;
0091     ActorT< terminal_type > act = {{ terminal_type(attr.get_name(), substring, attr.get_fallback_policy()) }};
0092     return act;
0093 }
0094 
0095 /*!
0096  * The function generates a terminal node in a template expression. The node will check if the attribute value,
0097  * which is assumed to be a string, begins with the specified substring.
0098  */
0099 template< typename DescriptorT, template< typename > class ActorT, typename SubstringT >
0100 BOOST_FORCEINLINE ActorT< aux::unary_function_terminal< attribute_begins_with< typename DescriptorT::value_type, typename boost::log::aux::make_embedded_string_type< SubstringT >::type > > >
0101 begins_with(attribute_keyword< DescriptorT, ActorT > const&, SubstringT const& substring)
0102 {
0103     typedef aux::unary_function_terminal< attribute_begins_with< typename DescriptorT::value_type, typename boost::log::aux::make_embedded_string_type< SubstringT >::type > > terminal_type;
0104     ActorT< terminal_type > act = {{ terminal_type(DescriptorT::get_name(), substring) }};
0105     return act;
0106 }
0107 
0108 /*!
0109  * The function generates a terminal node in a template expression. The node will check if the attribute value,
0110  * which is assumed to be a string, begins with the specified substring.
0111  */
0112 template< typename T, typename SubstringT >
0113 BOOST_FORCEINLINE phoenix::actor< aux::unary_function_terminal< attribute_begins_with< T, typename boost::log::aux::make_embedded_string_type< SubstringT >::type > > >
0114 begins_with(attribute_name const& name, SubstringT const& substring)
0115 {
0116     typedef aux::unary_function_terminal< attribute_begins_with< T, typename boost::log::aux::make_embedded_string_type< SubstringT >::type > > terminal_type;
0117     phoenix::actor< terminal_type > act = {{ terminal_type(name, substring) }};
0118     return act;
0119 }
0120 
0121 } // namespace expressions
0122 
0123 BOOST_LOG_CLOSE_NAMESPACE // namespace log
0124 
0125 } // namespace boost
0126 
0127 #include <boost/log/detail/footer.hpp>
0128 
0129 #endif // BOOST_LOG_EXPRESSIONS_PREDICATES_BEGINS_WITH_HPP_INCLUDED_