3 * Copyright (c) 1998-2002
6 * Use, modification and distribution are subject to the
7 * Boost Software License, Version 1.0. (See accompanying file
8 * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
13 * LOCATION: see http://www.boost.org for most recent version.
14 * FILE regex_match.hpp
15 * VERSION see <boost/version.hpp>
16 * DESCRIPTION: Regular expression matching algorithms.
17 * Note this is an internal header file included
18 * by regex.hpp, do not include on its own.
22 #ifndef BOOST_REGEX_MATCH_HPP
23 #define BOOST_REGEX_MATCH_HPP
25 #ifndef BOOST_REGEX_MAX_STATE_COUNT
26 # define BOOST_REGEX_MAX_STATE_COUNT 100000000
29 #include <boost/limits.hpp>
30 #include <boost/regex/v4/perl_matcher.hpp>
35 #ifdef BOOST_HAS_ABI_HEADERS
36 # include BOOST_ABI_PREFIX
41 // returns true if the specified regular expression matches
42 // the whole of the input. Fills in what matched in m.
44 template <class BidiIterator, class Allocator, class charT, class traits, class Allocator2>
45 bool regex_match(BidiIterator first, BidiIterator last,
46 match_results<BidiIterator, Allocator>& m,
47 const reg_expression<charT, traits, Allocator2>& e,
48 match_flag_type flags = match_default)
50 re_detail::perl_matcher<BidiIterator, Allocator, traits, Allocator2> matcher(first, last, m, e, flags);
51 return matcher.match();
53 template <class iterator, class charT, class traits, class Allocator2>
54 bool regex_match(iterator first, iterator last,
55 const reg_expression<charT, traits, Allocator2>& e,
56 match_flag_type flags = match_default)
58 match_results<iterator> m;
59 return regex_match(first, last, m, e, flags);
62 // query_match convenience interfaces:
63 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
65 // this isn't really a partial specialisation, but template function
66 // overloading - if the compiler doesn't support partial specialisation
67 // then it really won't support this either:
68 template <class charT, class Allocator, class traits, class Allocator2>
69 inline bool regex_match(const charT* str,
70 match_results<const charT*, Allocator>& m,
71 const reg_expression<charT, traits, Allocator2>& e,
72 match_flag_type flags = match_default)
74 return regex_match(str, str + traits::length(str), m, e, flags);
77 template <class ST, class SA, class Allocator, class charT, class traits, class Allocator2>
78 inline bool regex_match(const std::basic_string<charT, ST, SA>& s,
79 match_results<typename std::basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
80 const reg_expression<charT, traits, Allocator2>& e,
81 match_flag_type flags = match_default)
83 return regex_match(s.begin(), s.end(), m, e, flags);
85 template <class charT, class traits, class Allocator2>
86 inline bool regex_match(const charT* str,
87 const reg_expression<charT, traits, Allocator2>& e,
88 match_flag_type flags = match_default)
90 match_results<const charT*> m;
91 return regex_match(str, str + traits::length(str), m, e, flags);
94 template <class ST, class SA, class charT, class traits, class Allocator2>
95 inline bool regex_match(const std::basic_string<charT, ST, SA>& s,
96 const reg_expression<charT, traits, Allocator2>& e,
97 match_flag_type flags = match_default)
99 typedef typename std::basic_string<charT, ST, SA>::const_iterator iterator;
100 match_results<iterator> m;
101 return regex_match(s.begin(), s.end(), m, e, flags);
103 #else // partial ordering
104 inline bool regex_match(const char* str,
107 match_flag_type flags = match_default)
109 return regex_match(str, str + regex::traits_type::length(str), m, e, flags);
111 inline bool regex_match(const char* str,
113 match_flag_type flags = match_default)
115 match_results<const char*> m;
116 return regex_match(str, str + regex::traits_type::length(str), m, e, flags);
118 #ifndef BOOST_NO_WREGEX
119 inline bool regex_match(const wchar_t* str,
122 match_flag_type flags = match_default)
124 return regex_match(str, str + wregex::traits_type::length(str), m, e, flags);
126 inline bool regex_match(const wchar_t* str,
128 match_flag_type flags = match_default)
130 match_results<const wchar_t*> m;
131 return regex_match(str, str + wregex::traits_type::length(str), m, e, flags);
134 inline bool regex_match(const std::string& s,
137 match_flag_type flags = match_default)
139 return regex_match(s.begin(), s.end(), m, e, flags);
141 inline bool regex_match(const std::string& s,
143 match_flag_type flags = match_default)
145 match_results<std::string::const_iterator, regex::allocator_type> m;
146 return regex_match(s.begin(), s.end(), m, e, flags);
148 #if !defined(BOOST_NO_WREGEX)
149 inline bool regex_match(const std::basic_string<wchar_t>& s,
150 match_results<std::basic_string<wchar_t>::const_iterator, wregex::allocator_type>& m,
152 match_flag_type flags = match_default)
154 return regex_match(s.begin(), s.end(), m, e, flags);
156 inline bool regex_match(const std::basic_string<wchar_t>& s,
158 match_flag_type flags = match_default)
160 match_results<std::basic_string<wchar_t>::const_iterator, wregex::allocator_type> m;
161 return regex_match(s.begin(), s.end(), m, e, flags);
168 #ifdef BOOST_HAS_ABI_HEADERS
169 # include BOOST_ABI_SUFFIX
174 #endif // BOOST_REGEX_MATCH_HPP