]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/log/include/boost/log/support/std_regex.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / log / include / boost / log / support / std_regex.hpp
CommitLineData
7c673cae
FG
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/std_regex.hpp
9 * \author Andrey Semashev
10 * \date 19.03.2014
11 *
12 * This header enables \c std::regex support for Boost.Log.
13 */
14
15#ifndef BOOST_LOG_SUPPORT_STD_REGEX_HPP_INCLUDED_
16#define BOOST_LOG_SUPPORT_STD_REGEX_HPP_INCLUDED_
17
18#include <boost/log/detail/config.hpp>
19
20#ifdef BOOST_HAS_PRAGMA_ONCE
21#pragma once
22#endif
23
24#if defined(BOOST_NO_CXX11_HDR_REGEX)
25
26#if defined(__GNUC__)
27#pragma message "Boost.Log: This header requires support for std::regex in the standard library."
28#elif defined(_MSC_VER)
29#pragma message("Boost.Log: This header requires support for std::regex in the standard library.")
30#endif
31
32#else // defined(BOOST_NO_CXX11_HDR_REGEX)
33
34#include <regex>
35#include <string>
36#include <boost/log/utility/functional/matches.hpp>
37#include <boost/log/detail/header.hpp>
38
39namespace boost {
40
41BOOST_LOG_OPEN_NAMESPACE
42
43namespace aux {
44
45//! This tag type is used if an expression is recognized as \c std::regex
46struct std_regex_expression_tag;
47
48//! The metafunction detects the matching expression kind and returns a tag that is used to specialize \c match_traits
49template< typename CharT, typename ReTraitsT >
50struct matching_expression_kind< std::basic_regex< CharT, ReTraitsT > >
51{
52 typedef std_regex_expression_tag type;
53};
54
55//! The matching function implementation
56template< typename ExpressionT >
57struct match_traits< ExpressionT, std_regex_expression_tag >
58{
59 typedef ExpressionT compiled_type;
60 static compiled_type compile(ExpressionT const& expr) { return expr; }
61
62 template< typename StringT, typename CharT, typename ReTraitsT >
63 static bool matches(StringT const& str, std::basic_regex< CharT, ReTraitsT > const& expr, std::regex_constants::match_flag_type flags = std::regex_constants::match_default)
64 {
65 return std::regex_match(str.begin(), str.end(), expr, flags);
66 }
67
68 template< typename CharT, typename StringTraitsT, typename AllocatorT, typename ReTraitsT >
69 static bool matches(std::basic_string< CharT, StringTraitsT, AllocatorT > const& str, std::basic_regex< CharT, ReTraitsT > const& expr, std::regex_constants::match_flag_type flags = std::regex_constants::match_default)
70 {
71 const CharT* p = str.c_str();
72 return std::regex_match(p, p + str.size(), expr, flags);
73 }
74};
75
76} // namespace aux
77
78BOOST_LOG_CLOSE_NAMESPACE // namespace log
79
80} // namespace boost
81
82#include <boost/log/detail/footer.hpp>
83
84#endif // defined(BOOST_NO_CXX11_HDR_REGEX)
85
86#endif // BOOST_LOG_SUPPORT_STD_REGEX_HPP_INCLUDED_