]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/log/support/xpressive.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / log / support / xpressive.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 support/xpressive.hpp
9 * \author Andrey Semashev
10 * \date 18.07.2009
11 *
12 * This header enables Boost.Xpressive support for Boost.Log.
13 */
14
15 #ifndef BOOST_LOG_SUPPORT_XPRESSIVE_HPP_INCLUDED_
16 #define BOOST_LOG_SUPPORT_XPRESSIVE_HPP_INCLUDED_
17
18 #include <string>
19 #include <boost/xpressive/basic_regex.hpp>
20 #include <boost/xpressive/regex_constants.hpp>
21 #include <boost/xpressive/regex_algorithms.hpp>
22 #include <boost/log/detail/config.hpp>
23 #include <boost/log/utility/functional/matches.hpp>
24 #include <boost/log/detail/header.hpp>
25
26 #ifdef BOOST_HAS_PRAGMA_ONCE
27 #pragma once
28 #endif
29
30 namespace boost {
31
32 BOOST_LOG_OPEN_NAMESPACE
33
34 namespace aux {
35
36 //! This tag type is used if an expression is recognized as a Boost.Xpressive expression
37 struct boost_xpressive_expression_tag;
38
39 //! The metafunction detects the matching expression kind and returns a tag that is used to specialize \c match_traits
40 template< typename T >
41 struct matching_expression_kind< xpressive::basic_regex< T > >
42 {
43 typedef boost_xpressive_expression_tag type;
44 };
45
46 //! The matching function implementation
47 template< typename ExpressionT >
48 struct match_traits< ExpressionT, boost_xpressive_expression_tag >
49 {
50 typedef ExpressionT compiled_type;
51 static compiled_type compile(ExpressionT const& expr) { return expr; }
52
53 template< typename StringT, typename T >
54 static bool matches(StringT const& str, xpressive::basic_regex< T > const& expr, xpressive::regex_constants::match_flag_type flags = xpressive::regex_constants::match_default)
55 {
56 return xpressive::regex_match(str, expr, flags);
57 }
58
59 template< typename CharT, typename TraitsT, typename AllocatorT >
60 static bool matches(std::basic_string< CharT, TraitsT, AllocatorT > const& str, xpressive::basic_regex< const CharT* > const& expr, xpressive::regex_constants::match_flag_type flags = xpressive::regex_constants::match_default)
61 {
62 const CharT* p = str.c_str();
63 return xpressive::regex_match(p, p + str.size(), expr, flags);
64 }
65 };
66
67 } // namespace aux
68
69 BOOST_LOG_CLOSE_NAMESPACE // namespace log
70
71 } // namespace boost
72
73 #include <boost/log/detail/footer.hpp>
74
75 #endif // BOOST_LOG_SUPPORT_XPRESSIVE_HPP_INCLUDED_