Chris@16
|
1 /*
|
Chris@101
|
2 * Copyright Andrey Semashev 2007 - 2015.
|
Chris@16
|
3 * Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
4 * (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
5 * http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 */
|
Chris@16
|
7 /*!
|
Chris@16
|
8 * \file ends_with.hpp
|
Chris@16
|
9 * \author Andrey Semashev
|
Chris@16
|
10 * \date 02.09.2012
|
Chris@16
|
11 *
|
Chris@16
|
12 * The header contains implementation of a \c ends_with predicate in template expressions.
|
Chris@16
|
13 */
|
Chris@16
|
14
|
Chris@16
|
15 #ifndef BOOST_LOG_EXPRESSIONS_PREDICATES_ENDS_WITH_HPP_INCLUDED_
|
Chris@16
|
16 #define BOOST_LOG_EXPRESSIONS_PREDICATES_ENDS_WITH_HPP_INCLUDED_
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/phoenix/core/actor.hpp>
|
Chris@16
|
19 #include <boost/log/detail/config.hpp>
|
Chris@16
|
20 #include <boost/log/detail/embedded_string_type.hpp>
|
Chris@16
|
21 #include <boost/log/detail/unary_function_terminal.hpp>
|
Chris@16
|
22 #include <boost/log/detail/attribute_predicate.hpp>
|
Chris@16
|
23 #include <boost/log/expressions/attr_fwd.hpp>
|
Chris@16
|
24 #include <boost/log/expressions/keyword_fwd.hpp>
|
Chris@16
|
25 #include <boost/log/attributes/attribute_name.hpp>
|
Chris@16
|
26 #include <boost/log/attributes/fallback_policy.hpp>
|
Chris@16
|
27 #include <boost/log/utility/functional/ends_with.hpp>
|
Chris@16
|
28 #include <boost/log/detail/header.hpp>
|
Chris@16
|
29
|
Chris@16
|
30 #ifdef BOOST_HAS_PRAGMA_ONCE
|
Chris@16
|
31 #pragma once
|
Chris@16
|
32 #endif
|
Chris@16
|
33
|
Chris@16
|
34 namespace boost {
|
Chris@16
|
35
|
Chris@16
|
36 BOOST_LOG_OPEN_NAMESPACE
|
Chris@16
|
37
|
Chris@16
|
38 namespace expressions {
|
Chris@16
|
39
|
Chris@16
|
40 /*!
|
Chris@16
|
41 * The predicate checks if the attribute value ends with a substring. The attribute value is assumed to be of a string type.
|
Chris@16
|
42 */
|
Chris@16
|
43 #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
Chris@16
|
44
|
Chris@16
|
45 template< typename T, typename SubstringT, typename FallbackPolicyT = fallback_to_none >
|
Chris@16
|
46 using attribute_ends_with = aux::attribute_predicate< T, SubstringT, ends_with_fun, FallbackPolicyT >;
|
Chris@16
|
47
|
Chris@16
|
48 #else // !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
Chris@16
|
49
|
Chris@16
|
50 template< typename T, typename SubstringT, typename FallbackPolicyT = fallback_to_none >
|
Chris@16
|
51 class attribute_ends_with :
|
Chris@16
|
52 public aux::attribute_predicate< T, SubstringT, ends_with_fun, FallbackPolicyT >
|
Chris@16
|
53 {
|
Chris@16
|
54 typedef aux::attribute_predicate< T, SubstringT, ends_with_fun, FallbackPolicyT > base_type;
|
Chris@16
|
55
|
Chris@16
|
56 public:
|
Chris@16
|
57 /*!
|
Chris@16
|
58 * Initializing constructor
|
Chris@16
|
59 *
|
Chris@16
|
60 * \param name Attribute name
|
Chris@16
|
61 * \param substring The expected attribute value ending
|
Chris@16
|
62 */
|
Chris@16
|
63 attribute_ends_with(attribute_name const& name, SubstringT const& substring) : base_type(name, substring)
|
Chris@16
|
64 {
|
Chris@16
|
65 }
|
Chris@16
|
66
|
Chris@16
|
67 /*!
|
Chris@16
|
68 * Initializing constructor
|
Chris@16
|
69 *
|
Chris@16
|
70 * \param name Attribute name
|
Chris@16
|
71 * \param substring The expected attribute value ending
|
Chris@16
|
72 * \param arg Additional parameter for the fallback policy
|
Chris@16
|
73 */
|
Chris@16
|
74 template< typename U >
|
Chris@16
|
75 attribute_ends_with(attribute_name const& name, SubstringT const& substring, U const& arg) : base_type(name, substring, arg)
|
Chris@16
|
76 {
|
Chris@16
|
77 }
|
Chris@16
|
78 };
|
Chris@16
|
79
|
Chris@16
|
80 #endif // !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
Chris@16
|
81
|
Chris@16
|
82 /*!
|
Chris@16
|
83 * The function generates a terminal node in a template expression. The node will check if the attribute value,
|
Chris@16
|
84 * which is assumed to be a string, ends with the specified substring.
|
Chris@16
|
85 */
|
Chris@16
|
86 template< typename T, typename FallbackPolicyT, typename TagT, template< typename > class ActorT, typename SubstringT >
|
Chris@16
|
87 BOOST_FORCEINLINE ActorT< aux::unary_function_terminal< attribute_ends_with< T, typename boost::log::aux::make_embedded_string_type< SubstringT >::type, FallbackPolicyT > > >
|
Chris@16
|
88 ends_with(attribute_actor< T, FallbackPolicyT, TagT, ActorT > const& attr, SubstringT const& substring)
|
Chris@16
|
89 {
|
Chris@16
|
90 typedef aux::unary_function_terminal< attribute_ends_with< T, typename boost::log::aux::make_embedded_string_type< SubstringT >::type, FallbackPolicyT > > terminal_type;
|
Chris@16
|
91 ActorT< terminal_type > act = {{ terminal_type(attr.get_name(), substring, attr.get_fallback_policy()) }};
|
Chris@16
|
92 return act;
|
Chris@16
|
93 }
|
Chris@16
|
94
|
Chris@16
|
95 /*!
|
Chris@16
|
96 * The function generates a terminal node in a template expression. The node will check if the attribute value,
|
Chris@16
|
97 * which is assumed to be a string, ends with the specified substring.
|
Chris@16
|
98 */
|
Chris@16
|
99 template< typename DescriptorT, template< typename > class ActorT, typename SubstringT >
|
Chris@16
|
100 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
|
101 ends_with(attribute_keyword< DescriptorT, ActorT > const&, SubstringT const& substring)
|
Chris@16
|
102 {
|
Chris@16
|
103 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
|
104 ActorT< terminal_type > act = {{ terminal_type(DescriptorT::get_name(), substring) }};
|
Chris@16
|
105 return act;
|
Chris@16
|
106 }
|
Chris@16
|
107
|
Chris@16
|
108 /*!
|
Chris@16
|
109 * The function generates a terminal node in a template expression. The node will check if the attribute value,
|
Chris@16
|
110 * which is assumed to be a string, ends with the specified substring.
|
Chris@16
|
111 */
|
Chris@16
|
112 template< typename T, typename SubstringT >
|
Chris@16
|
113 BOOST_FORCEINLINE phoenix::actor< aux::unary_function_terminal< attribute_ends_with< T, typename boost::log::aux::make_embedded_string_type< SubstringT >::type > > >
|
Chris@16
|
114 ends_with(attribute_name const& name, SubstringT const& substring)
|
Chris@16
|
115 {
|
Chris@16
|
116 typedef aux::unary_function_terminal< attribute_ends_with< T, typename boost::log::aux::make_embedded_string_type< SubstringT >::type > > terminal_type;
|
Chris@16
|
117 phoenix::actor< terminal_type > act = {{ terminal_type(name, substring) }};
|
Chris@16
|
118 return act;
|
Chris@16
|
119 }
|
Chris@16
|
120
|
Chris@16
|
121 } // namespace expressions
|
Chris@16
|
122
|
Chris@16
|
123 BOOST_LOG_CLOSE_NAMESPACE // namespace log
|
Chris@16
|
124
|
Chris@16
|
125 } // namespace boost
|
Chris@16
|
126
|
Chris@16
|
127 #include <boost/log/detail/footer.hpp>
|
Chris@16
|
128
|
Chris@16
|
129 #endif // BOOST_LOG_EXPRESSIONS_PREDICATES_ENDS_WITH_HPP_INCLUDED_
|