comparison DEPENDENCIES/generic/include/boost/log/support/xpressive.hpp @ 101:c530137014c0

Update Boost headers (1.58.0)
author Chris Cannam
date Mon, 07 Sep 2015 11:12:49 +0100
parents 2665513ce2d3
children
comparison
equal deleted inserted replaced
100:793467b5e61c 101:c530137014c0
1 /* 1 /*
2 * Copyright Andrey Semashev 2007 - 2013. 2 * Copyright Andrey Semashev 2007 - 2015.
3 * Distributed under the Boost Software License, Version 1.0. 3 * Distributed under the Boost Software License, Version 1.0.
4 * (See accompanying file LICENSE_1_0.txt or copy at 4 * (See accompanying file LICENSE_1_0.txt or copy at
5 * http://www.boost.org/LICENSE_1_0.txt) 5 * http://www.boost.org/LICENSE_1_0.txt)
6 */ 6 */
7 /*! 7 /*!
13 */ 13 */
14 14
15 #ifndef BOOST_LOG_SUPPORT_XPRESSIVE_HPP_INCLUDED_ 15 #ifndef BOOST_LOG_SUPPORT_XPRESSIVE_HPP_INCLUDED_
16 #define BOOST_LOG_SUPPORT_XPRESSIVE_HPP_INCLUDED_ 16 #define BOOST_LOG_SUPPORT_XPRESSIVE_HPP_INCLUDED_
17 17
18 #include <boost/mpl/bool.hpp> 18 #include <string>
19 #include <boost/xpressive/basic_regex.hpp> 19 #include <boost/xpressive/basic_regex.hpp>
20 #include <boost/xpressive/regex_constants.hpp> 20 #include <boost/xpressive/regex_constants.hpp>
21 #include <boost/xpressive/regex_algorithms.hpp> 21 #include <boost/xpressive/regex_algorithms.hpp>
22 #include <boost/log/detail/config.hpp> 22 #include <boost/log/detail/config.hpp>
23 #include <boost/log/utility/functional/matches.hpp> 23 #include <boost/log/utility/functional/matches.hpp>
31 31
32 BOOST_LOG_OPEN_NAMESPACE 32 BOOST_LOG_OPEN_NAMESPACE
33 33
34 namespace aux { 34 namespace aux {
35 35
36 //! The trait verifies if the type can be converted to a Boost.Xpressive regex 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
37 template< typename T > 40 template< typename T >
38 struct is_xpressive_regex< T, true > 41 struct matching_expression_kind< xpressive::basic_regex< T > >
39 { 42 {
40 private: 43 typedef boost_xpressive_expression_tag type;
41 typedef char yes_type;
42 struct no_type { char dummy[2]; };
43
44 template< typename U >
45 static yes_type check_xpressive_regex(xpressive::basic_regex< U > const&);
46 static no_type check_xpressive_regex(...);
47 static T& get_T();
48
49 public:
50 enum { value = sizeof(check_xpressive_regex(get_T())) == sizeof(yes_type) };
51 typedef mpl::bool_< value > type;
52 }; 44 };
53 45
54 //! The regex matching functor implementation 46 //! The matching function implementation
55 template< > 47 template< typename ExpressionT >
56 struct matches_fun_impl< boost_xpressive_expression_tag > 48 struct match_traits< ExpressionT, boost_xpressive_expression_tag >
57 { 49 {
50 typedef ExpressionT compiled_type;
51 static compiled_type compile(ExpressionT const& expr) { return expr; }
52
58 template< typename StringT, typename T > 53 template< typename StringT, typename T >
59 static bool matches( 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)
60 StringT const& str,
61 xpressive::basic_regex< T > const& expr,
62 xpressive::regex_constants::match_flag_type flags = xpressive::regex_constants::match_default)
63 { 55 {
64 return xpressive::regex_match(str, expr, flags); 56 return xpressive::regex_match(str, expr, flags);
65 } 57 }
66 58
67 template< typename StringT > 59 template< typename CharT, typename TraitsT, typename AllocatorT >
68 static bool matches( 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)
69 StringT const& str,
70 xpressive::basic_regex< typename StringT::value_type* > const& expr,
71 xpressive::regex_constants::match_flag_type flags = xpressive::regex_constants::match_default)
72 { 61 {
73 return xpressive::regex_match(str.c_str(), expr, flags); 62 const CharT* p = str.c_str();
74 } 63 return xpressive::regex_match(p, p + str.size(), expr, flags);
75
76 template< typename StringT >
77 static bool matches(
78 StringT const& str,
79 xpressive::basic_regex< typename StringT::value_type const* > const& expr,
80 xpressive::regex_constants::match_flag_type flags = xpressive::regex_constants::match_default)
81 {
82 return xpressive::regex_match(str.c_str(), expr, flags);
83 } 64 }
84 }; 65 };
85 66
86 } // namespace aux 67 } // namespace aux
87 68