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