annotate DEPENDENCIES/generic/include/boost/log/utility/functional/matches.hpp @ 49:666a1c41ce51

Package up binaries
author Chris Cannam
date Thu, 07 Aug 2014 19:17:03 +0100
parents 2665513ce2d3
children c530137014c0
rev   line source
Chris@16 1 /*
Chris@16 2 * Copyright Andrey Semashev 2007 - 2013.
Chris@16 3 * Distributed under the Boost Software License, Version 1.0.
Chris@16 4 * (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 5 * http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6 */
Chris@16 7 /*!
Chris@16 8 * \file matches.hpp
Chris@16 9 * \author Andrey Semashev
Chris@16 10 * \date 30.03.2008
Chris@16 11 *
Chris@16 12 * This header contains a predicate for checking if the provided string matches a regular expression.
Chris@16 13 */
Chris@16 14
Chris@16 15 #ifndef BOOST_LOG_UTILITY_FUNCTIONAL_MATCHES_HPP_INCLUDED_
Chris@16 16 #define BOOST_LOG_UTILITY_FUNCTIONAL_MATCHES_HPP_INCLUDED_
Chris@16 17
Chris@16 18 #include <boost/mpl/bool.hpp>
Chris@16 19 #include <boost/mpl/identity.hpp>
Chris@16 20 #include <boost/mpl/if.hpp>
Chris@16 21 #include <boost/mpl/eval_if.hpp>
Chris@16 22 #include <boost/log/detail/config.hpp>
Chris@16 23 #include <boost/log/detail/header.hpp>
Chris@16 24
Chris@16 25 #ifdef BOOST_HAS_PRAGMA_ONCE
Chris@16 26 #pragma once
Chris@16 27 #endif
Chris@16 28
Chris@16 29 namespace boost {
Chris@16 30
Chris@16 31 BOOST_LOG_OPEN_NAMESPACE
Chris@16 32
Chris@16 33 namespace aux {
Chris@16 34
Chris@16 35 //! This tag type is used if an expression is not supported for matching against strings
Chris@16 36 struct unsupported_match_expression_tag;
Chris@16 37 //! This tag type is used if an expression is recognized as a Boost.Regex expression
Chris@16 38 struct boost_regex_expression_tag;
Chris@16 39 //! This tag type is used if an expression is recognized as a Boost.Xpressive expression
Chris@16 40 struct boost_xpressive_expression_tag;
Chris@16 41 //! This tag type is used if an expression is recognized as a Boost.Spirit (classic) expression
Chris@16 42 struct boost_spirit_classic_expression_tag;
Chris@16 43 //! This tag type is used if an expression is recognized as a Boost.Spirit.Qi expression
Chris@16 44 struct boost_spirit_qi_expression_tag;
Chris@16 45
Chris@16 46 //! Preliminary declaration of a trait that detects if an expression is a Boost.Regex expression
Chris@16 47 template< typename, bool = true >
Chris@16 48 struct is_regex :
Chris@16 49 public mpl::false_
Chris@16 50 {
Chris@16 51 };
Chris@16 52 //! Preliminary declaration of a trait that detects if an expression is a Boost.Xpressive expression
Chris@16 53 template< typename, bool = true >
Chris@16 54 struct is_xpressive_regex :
Chris@16 55 public mpl::false_
Chris@16 56 {
Chris@16 57 };
Chris@16 58 //! Preliminary declaration of a trait that detects if an expression is a Boost.Spirit (classic) expression
Chris@16 59 template< typename, bool = true >
Chris@16 60 struct is_spirit_classic_parser :
Chris@16 61 public mpl::false_
Chris@16 62 {
Chris@16 63 };
Chris@16 64 //! Preliminary declaration of a trait that detects if an expression is a Boost.Spirit.Qi expression
Chris@16 65 template< typename, bool = true >
Chris@16 66 struct is_spirit_qi_parser :
Chris@16 67 public mpl::false_
Chris@16 68 {
Chris@16 69 };
Chris@16 70
Chris@16 71 //! The regex matching functor implementation
Chris@16 72 template< typename TagT >
Chris@16 73 struct matches_fun_impl;
Chris@16 74
Chris@16 75 } // namespace aux
Chris@16 76
Chris@16 77 //! The regex matching functor
Chris@16 78 struct matches_fun
Chris@16 79 {
Chris@16 80 typedef bool result_type;
Chris@16 81
Chris@16 82 private:
Chris@16 83 //! A traits to obtain the tag of the expression
Chris@16 84 template< typename ExpressionT >
Chris@16 85 struct match_traits
Chris@16 86 {
Chris@16 87 typedef typename mpl::eval_if<
Chris@16 88 aux::is_regex< ExpressionT >,
Chris@16 89 mpl::identity< aux::boost_regex_expression_tag >,
Chris@16 90 mpl::eval_if<
Chris@16 91 aux::is_xpressive_regex< ExpressionT >,
Chris@16 92 mpl::identity< aux::boost_xpressive_expression_tag >,
Chris@16 93 mpl::eval_if<
Chris@16 94 aux::is_spirit_classic_parser< ExpressionT >,
Chris@16 95 mpl::identity< aux::boost_spirit_classic_expression_tag >,
Chris@16 96 mpl::if_<
Chris@16 97 aux::is_spirit_qi_parser< ExpressionT >,
Chris@16 98 aux::boost_spirit_qi_expression_tag,
Chris@16 99 aux::unsupported_match_expression_tag
Chris@16 100 >
Chris@16 101 >
Chris@16 102 >
Chris@16 103 >::type tag_type;
Chris@16 104 };
Chris@16 105
Chris@16 106 public:
Chris@16 107 template< typename StringT, typename ExpressionT >
Chris@16 108 bool operator() (StringT const& str, ExpressionT const& expr) const
Chris@16 109 {
Chris@16 110 typedef typename match_traits< ExpressionT >::tag_type tag_type;
Chris@16 111 typedef aux::matches_fun_impl< tag_type > impl;
Chris@16 112 return impl::matches(str, expr);
Chris@16 113 }
Chris@16 114 template< typename StringT, typename ExpressionT, typename ArgT >
Chris@16 115 bool operator() (StringT const& str, ExpressionT const& expr, ArgT const& arg) const
Chris@16 116 {
Chris@16 117 typedef typename match_traits< ExpressionT >::tag_type tag_type;
Chris@16 118 typedef aux::matches_fun_impl< tag_type > impl;
Chris@16 119 return impl::matches(str, expr, arg);
Chris@16 120 }
Chris@16 121 };
Chris@16 122
Chris@16 123 BOOST_LOG_CLOSE_NAMESPACE // namespace log
Chris@16 124
Chris@16 125 } // namespace boost
Chris@16 126
Chris@16 127 #include <boost/log/detail/footer.hpp>
Chris@16 128
Chris@16 129 #endif // BOOST_LOG_UTILITY_FUNCTIONAL_MATCHES_HPP_INCLUDED_