Chris@16: /* Chris@101: * Copyright Andrey Semashev 2007 - 2015. Chris@16: * Distributed under the Boost Software License, Version 1.0. Chris@16: * (See accompanying file LICENSE_1_0.txt or copy at Chris@16: * http://www.boost.org/LICENSE_1_0.txt) Chris@16: */ Chris@16: /*! Chris@16: * \file support/regex.hpp Chris@16: * \author Andrey Semashev Chris@16: * \date 18.07.2009 Chris@16: * Chris@16: * This header enables Boost.Regex support for Boost.Log. Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_LOG_SUPPORT_REGEX_HPP_INCLUDED_ Chris@16: #define BOOST_LOG_SUPPORT_REGEX_HPP_INCLUDED_ Chris@16: Chris@101: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #ifdef BOOST_HAS_PRAGMA_ONCE Chris@16: #pragma once Chris@16: #endif Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: BOOST_LOG_OPEN_NAMESPACE Chris@16: Chris@16: namespace aux { Chris@16: Chris@101: //! This tag type is used if an expression is recognized as a Boost.Regex expression Chris@101: struct boost_regex_expression_tag; Chris@101: Chris@101: //! The metafunction detects the matching expression kind and returns a tag that is used to specialize \c match_traits Chris@101: template< typename CharT, typename TraitsT > Chris@101: struct matching_expression_kind< boost::basic_regex< CharT, TraitsT > > Chris@16: { Chris@101: typedef boost_regex_expression_tag type; Chris@16: }; Chris@16: Chris@101: //! The matching function implementation Chris@101: template< typename ExpressionT > Chris@101: struct match_traits< ExpressionT, boost_regex_expression_tag > Chris@16: { Chris@101: typedef ExpressionT compiled_type; Chris@101: static compiled_type compile(ExpressionT const& expr) { return expr; } Chris@101: Chris@16: template< typename StringT, typename CharT, typename TraitsT > Chris@101: static bool matches(StringT const& str, boost::basic_regex< CharT, TraitsT > const& expr, boost::regex_constants::match_flag_type flags = boost::regex_constants::match_default) Chris@16: { Chris@16: return boost::regex_match(str.begin(), str.end(), expr, flags); Chris@16: } Chris@101: Chris@101: template< typename CharT, typename StringTraitsT, typename AllocatorT, typename ReTraitsT > Chris@101: static bool matches( Chris@101: std::basic_string< CharT, StringTraitsT, AllocatorT > const& str, Chris@101: boost::basic_regex< CharT, ReTraitsT > const& expr, Chris@101: boost::regex_constants::match_flag_type flags = boost::regex_constants::match_default) Chris@101: { Chris@101: const CharT* p = str.c_str(); Chris@101: return boost::regex_match(p, p + str.size(), expr, flags); Chris@101: } Chris@16: }; Chris@16: Chris@16: } // namespace aux Chris@16: Chris@16: BOOST_LOG_CLOSE_NAMESPACE // namespace log Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif // BOOST_LOG_SUPPORT_REGEX_HPP_INCLUDED_