2
* Copyright Andrey Semashev 2007 - 2013.
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)
8
* \file support/xpressive.hpp
9
* \author Andrey Semashev
12
* This header enables Boost.Xpressive support for Boost.Log.
15
#ifndef BOOST_LOG_SUPPORT_XPRESSIVE_HPP_INCLUDED_
16
#define BOOST_LOG_SUPPORT_XPRESSIVE_HPP_INCLUDED_
18
#include <boost/mpl/bool.hpp>
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>
26
#ifdef BOOST_LOG_HAS_PRAGMA_ONCE
32
BOOST_LOG_OPEN_NAMESPACE
36
//! The trait verifies if the type can be converted to a Boost.Xpressive regex
37
template< typename T >
38
struct is_xpressive_regex< T, true >
41
typedef char yes_type;
42
struct no_type { char dummy[2]; };
44
template< typename U >
45
static yes_type check_xpressive_regex(xpressive::basic_regex< U > const&);
46
static no_type check_xpressive_regex(...);
50
enum { value = sizeof(check_xpressive_regex(get_T())) == sizeof(yes_type) };
51
typedef mpl::bool_< value > type;
54
//! The regex matching functor implementation
56
struct matches_fun_impl< boost_xpressive_expression_tag >
58
template< typename StringT, typename T >
61
xpressive::basic_regex< T > const& expr,
62
xpressive::regex_constants::match_flag_type flags = xpressive::regex_constants::match_default)
64
return xpressive::regex_match(str, expr, flags);
67
template< typename StringT >
70
xpressive::basic_regex< typename StringT::value_type* > const& expr,
71
xpressive::regex_constants::match_flag_type flags = xpressive::regex_constants::match_default)
73
return xpressive::regex_match(str.c_str(), expr, flags);
76
template< typename StringT >
79
xpressive::basic_regex< typename StringT::value_type const* > const& expr,
80
xpressive::regex_constants::match_flag_type flags = xpressive::regex_constants::match_default)
82
return xpressive::regex_match(str.c_str(), expr, flags);
88
BOOST_LOG_CLOSE_NAMESPACE // namespace log
92
#include <boost/log/detail/footer.hpp>
94
#endif // BOOST_LOG_SUPPORT_XPRESSIVE_HPP_INCLUDED_