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
29 #pragma warning(disable: 4103)
31 #ifdef BOOST_HAS_ABI_HEADERS
32 # include BOOST_ABI_PREFIX
40 // returns true if the specified regular expression matches
41 // the whole of the input. Fills in what matched in m.
43 template <class BidiIterator, class Allocator, class charT, class traits>
44 bool regex_match(BidiIterator first, BidiIterator last,
45 match_results<BidiIterator, Allocator>& m,
46 const basic_regex<charT, traits>& e,
47 match_flag_type flags = match_default)
49 BOOST_REGEX_DETAIL_NS::perl_matcher<BidiIterator, Allocator, traits> matcher(first, last, m, e, flags, first);
50 return matcher.match();
52 template <class iterator, class charT, class traits>
53 bool regex_match(iterator first, iterator last,
54 const basic_regex<charT, traits>& e,
55 match_flag_type flags = match_default)
57 match_results<iterator> m;
58 return regex_match(first, last, m, e, flags | regex_constants::match_any);
61 // query_match convenience interfaces:
62 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
64 // this isn't really a partial specialisation, but template function
65 // overloading - if the compiler doesn't support partial specialisation
66 // then it really won't support this either:
67 template <class charT, class Allocator, class traits>
68 inline bool regex_match(const charT* str,
69 match_results<const charT*, Allocator>& m,
70 const basic_regex<charT, traits>& e,
71 match_flag_type flags = match_default)
73 return regex_match(str, str + traits::length(str), m, e, flags);
76 template <class ST, class SA, class Allocator, class charT, class traits>
77 inline bool regex_match(const std::basic_string<charT, ST, SA>& s,
78 match_results<typename std::basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
79 const basic_regex<charT, traits>& e,
80 match_flag_type flags = match_default)
82 return regex_match(s.begin(), s.end(), m, e, flags);
84 template <class charT, class traits>
85 inline bool regex_match(const charT* str,
86 const basic_regex<charT, traits>& e,
87 match_flag_type flags = match_default)
89 match_results<const charT*> m;
90 return regex_match(str, str + traits::length(str), m, e, flags | regex_constants::match_any);
93 template <class ST, class SA, class charT, class traits>
94 inline bool regex_match(const std::basic_string<charT, ST, SA>& s,
95 const basic_regex<charT, traits>& e,
96 match_flag_type flags = match_default)
98 typedef typename std::basic_string<charT, ST, SA>::const_iterator iterator;
99 match_results<iterator> m;
100 return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any);
102 #else // partial ordering
103 inline bool regex_match(const char* str,
106 match_flag_type flags = match_default)
108 return regex_match(str, str + regex::traits_type::length(str), m, e, flags);
110 inline bool regex_match(const char* str,
112 match_flag_type flags = match_default)
114 match_results<const char*> m;
115 return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any);
117 #ifndef BOOST_NO_STD_LOCALE
118 inline bool regex_match(const char* str,
120 const basic_regex<char, cpp_regex_traits<char> >& e,
121 match_flag_type flags = match_default)
123 return regex_match(str, str + regex::traits_type::length(str), m, e, flags);
125 inline bool regex_match(const char* str,
126 const basic_regex<char, cpp_regex_traits<char> >& e,
127 match_flag_type flags = match_default)
129 match_results<const char*> m;
130 return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any);
133 inline bool regex_match(const char* str,
135 const basic_regex<char, c_regex_traits<char> >& e,
136 match_flag_type flags = match_default)
138 return regex_match(str, str + regex::traits_type::length(str), m, e, flags);
140 inline bool regex_match(const char* str,
141 const basic_regex<char, c_regex_traits<char> >& e,
142 match_flag_type flags = match_default)
144 match_results<const char*> m;
145 return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any);
147 #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
148 inline bool regex_match(const char* str,
150 const basic_regex<char, w32_regex_traits<char> >& e,
151 match_flag_type flags = match_default)
153 return regex_match(str, str + regex::traits_type::length(str), m, e, flags);
155 inline bool regex_match(const char* str,
156 const basic_regex<char, w32_regex_traits<char> >& e,
157 match_flag_type flags = match_default)
159 match_results<const char*> m;
160 return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any);
163 #ifndef BOOST_NO_WREGEX
164 inline bool regex_match(const wchar_t* str,
167 match_flag_type flags = match_default)
169 return regex_match(str, str + wregex::traits_type::length(str), m, e, flags);
171 inline bool regex_match(const wchar_t* str,
173 match_flag_type flags = match_default)
175 match_results<const wchar_t*> m;
176 return regex_match(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any);
178 #ifndef BOOST_NO_STD_LOCALE
179 inline bool regex_match(const wchar_t* str,
181 const basic_regex<wchar_t, cpp_regex_traits<wchar_t> >& e,
182 match_flag_type flags = match_default)
184 return regex_match(str, str + wregex::traits_type::length(str), m, e, flags);
186 inline bool regex_match(const wchar_t* str,
187 const basic_regex<wchar_t, cpp_regex_traits<wchar_t> >& e,
188 match_flag_type flags = match_default)
190 match_results<const wchar_t*> m;
191 return regex_match(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any);
194 inline bool regex_match(const wchar_t* str,
196 const basic_regex<wchar_t, c_regex_traits<wchar_t> >& e,
197 match_flag_type flags = match_default)
199 return regex_match(str, str + wregex::traits_type::length(str), m, e, flags);
201 inline bool regex_match(const wchar_t* str,
202 const basic_regex<wchar_t, c_regex_traits<wchar_t> >& e,
203 match_flag_type flags = match_default)
205 match_results<const wchar_t*> m;
206 return regex_match(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any);
208 #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
209 inline bool regex_match(const wchar_t* str,
211 const basic_regex<wchar_t, w32_regex_traits<wchar_t> >& e,
212 match_flag_type flags = match_default)
214 return regex_match(str, str + wregex::traits_type::length(str), m, e, flags);
216 inline bool regex_match(const wchar_t* str,
217 const basic_regex<wchar_t, w32_regex_traits<wchar_t> >& e,
218 match_flag_type flags = match_default)
220 match_results<const wchar_t*> m;
221 return regex_match(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any);
225 inline bool regex_match(const std::string& s,
228 match_flag_type flags = match_default)
230 return regex_match(s.begin(), s.end(), m, e, flags);
232 inline bool regex_match(const std::string& s,
234 match_flag_type flags = match_default)
236 match_results<std::string::const_iterator> m;
237 return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any);
239 #ifndef BOOST_NO_STD_LOCALE
240 inline bool regex_match(const std::string& s,
242 const basic_regex<char, cpp_regex_traits<char> >& e,
243 match_flag_type flags = match_default)
245 return regex_match(s.begin(), s.end(), m, e, flags);
247 inline bool regex_match(const std::string& s,
248 const basic_regex<char, cpp_regex_traits<char> >& e,
249 match_flag_type flags = match_default)
251 match_results<std::string::const_iterator> m;
252 return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any);
255 inline bool regex_match(const std::string& s,
257 const basic_regex<char, c_regex_traits<char> >& e,
258 match_flag_type flags = match_default)
260 return regex_match(s.begin(), s.end(), m, e, flags);
262 inline bool regex_match(const std::string& s,
263 const basic_regex<char, c_regex_traits<char> >& e,
264 match_flag_type flags = match_default)
266 match_results<std::string::const_iterator> m;
267 return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any);
269 #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
270 inline bool regex_match(const std::string& s,
272 const basic_regex<char, w32_regex_traits<char> >& e,
273 match_flag_type flags = match_default)
275 return regex_match(s.begin(), s.end(), m, e, flags);
277 inline bool regex_match(const std::string& s,
278 const basic_regex<char, w32_regex_traits<char> >& e,
279 match_flag_type flags = match_default)
281 match_results<std::string::const_iterator> m;
282 return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any);
285 #if !defined(BOOST_NO_WREGEX)
286 inline bool regex_match(const std::basic_string<wchar_t>& s,
287 match_results<std::basic_string<wchar_t>::const_iterator>& m,
289 match_flag_type flags = match_default)
291 return regex_match(s.begin(), s.end(), m, e, flags);
293 inline bool regex_match(const std::basic_string<wchar_t>& s,
295 match_flag_type flags = match_default)
297 match_results<std::basic_string<wchar_t>::const_iterator> m;
298 return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any);
300 #ifndef BOOST_NO_STD_LOCALE
301 inline bool regex_match(const std::basic_string<wchar_t>& s,
302 match_results<std::basic_string<wchar_t>::const_iterator>& m,
303 const basic_regex<wchar_t, cpp_regex_traits<wchar_t> >& e,
304 match_flag_type flags = match_default)
306 return regex_match(s.begin(), s.end(), m, e, flags);
308 inline bool regex_match(const std::basic_string<wchar_t>& s,
309 const basic_regex<wchar_t, cpp_regex_traits<wchar_t> >& e,
310 match_flag_type flags = match_default)
312 match_results<std::basic_string<wchar_t>::const_iterator> m;
313 return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any);
316 inline bool regex_match(const std::basic_string<wchar_t>& s,
317 match_results<std::basic_string<wchar_t>::const_iterator>& m,
318 const basic_regex<wchar_t, c_regex_traits<wchar_t> >& e,
319 match_flag_type flags = match_default)
321 return regex_match(s.begin(), s.end(), m, e, flags);
323 inline bool regex_match(const std::basic_string<wchar_t>& s,
324 const basic_regex<wchar_t, c_regex_traits<wchar_t> >& e,
325 match_flag_type flags = match_default)
327 match_results<std::basic_string<wchar_t>::const_iterator> m;
328 return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any);
330 #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
331 inline bool regex_match(const std::basic_string<wchar_t>& s,
332 match_results<std::basic_string<wchar_t>::const_iterator>& m,
333 const basic_regex<wchar_t, w32_regex_traits<wchar_t> >& e,
334 match_flag_type flags = match_default)
336 return regex_match(s.begin(), s.end(), m, e, flags);
338 inline bool regex_match(const std::basic_string<wchar_t>& s,
339 const basic_regex<wchar_t, w32_regex_traits<wchar_t> >& e,
340 match_flag_type flags = match_default)
342 match_results<std::basic_string<wchar_t>::const_iterator> m;
343 return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any);
352 #pragma warning(push)
353 #pragma warning(disable: 4103)
355 #ifdef BOOST_HAS_ABI_HEADERS
356 # include BOOST_ABI_SUFFIX
364 #endif // BOOST_REGEX_MATCH_HPP