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
27 #ifdef BOOST_HAS_ABI_HEADERS
28 # include BOOST_ABI_PREFIX
33 // returns true if the specified regular expression matches
34 // the whole of the input. Fills in what matched in m.
36 template <class BidiIterator, class Allocator, class charT, class traits>
37 bool regex_match(BidiIterator first, BidiIterator last,
38 match_results<BidiIterator, Allocator>& m,
39 const basic_regex<charT, traits>& e,
40 match_flag_type flags = match_default)
42 re_detail::perl_matcher<BidiIterator, Allocator, traits> matcher(first, last, m, e, flags, first);
43 return matcher.match();
45 template <class iterator, class charT, class traits>
46 bool regex_match(iterator first, iterator last,
47 const basic_regex<charT, traits>& e,
48 match_flag_type flags = match_default)
50 match_results<iterator> m;
51 return regex_match(first, last, m, e, flags | regex_constants::match_any);
54 // query_match convenience interfaces:
55 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
57 // this isn't really a partial specialisation, but template function
58 // overloading - if the compiler doesn't support partial specialisation
59 // then it really won't support this either:
60 template <class charT, class Allocator, class traits>
61 inline bool regex_match(const charT* str,
62 match_results<const charT*, Allocator>& m,
63 const basic_regex<charT, traits>& e,
64 match_flag_type flags = match_default)
66 return regex_match(str, str + traits::length(str), m, e, flags);
69 template <class ST, class SA, class Allocator, class charT, class traits>
70 inline bool regex_match(const std::basic_string<charT, ST, SA>& s,
71 match_results<typename std::basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
72 const basic_regex<charT, traits>& e,
73 match_flag_type flags = match_default)
75 return regex_match(s.begin(), s.end(), m, e, flags);
77 template <class charT, class traits>
78 inline bool regex_match(const charT* str,
79 const basic_regex<charT, traits>& e,
80 match_flag_type flags = match_default)
82 match_results<const charT*> m;
83 return regex_match(str, str + traits::length(str), m, e, flags | regex_constants::match_any);
86 template <class ST, class SA, class charT, class traits>
87 inline bool regex_match(const std::basic_string<charT, ST, SA>& s,
88 const basic_regex<charT, traits>& e,
89 match_flag_type flags = match_default)
91 typedef typename std::basic_string<charT, ST, SA>::const_iterator iterator;
92 match_results<iterator> m;
93 return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any);
95 #else // partial ordering
96 inline bool regex_match(const char* str,
99 match_flag_type flags = match_default)
101 return regex_match(str, str + regex::traits_type::length(str), m, e, flags);
103 inline bool regex_match(const char* str,
105 match_flag_type flags = match_default)
107 match_results<const char*> m;
108 return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any);
110 #ifndef BOOST_NO_STD_LOCALE
111 inline bool regex_match(const char* str,
113 const basic_regex<char, cpp_regex_traits<char> >& e,
114 match_flag_type flags = match_default)
116 return regex_match(str, str + regex::traits_type::length(str), m, e, flags);
118 inline bool regex_match(const char* str,
119 const basic_regex<char, cpp_regex_traits<char> >& e,
120 match_flag_type flags = match_default)
122 match_results<const char*> m;
123 return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any);
126 inline bool regex_match(const char* str,
128 const basic_regex<char, c_regex_traits<char> >& e,
129 match_flag_type flags = match_default)
131 return regex_match(str, str + regex::traits_type::length(str), m, e, flags);
133 inline bool regex_match(const char* str,
134 const basic_regex<char, c_regex_traits<char> >& e,
135 match_flag_type flags = match_default)
137 match_results<const char*> m;
138 return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any);
140 #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
141 inline bool regex_match(const char* str,
143 const basic_regex<char, w32_regex_traits<char> >& e,
144 match_flag_type flags = match_default)
146 return regex_match(str, str + regex::traits_type::length(str), m, e, flags);
148 inline bool regex_match(const char* str,
149 const basic_regex<char, w32_regex_traits<char> >& e,
150 match_flag_type flags = match_default)
152 match_results<const char*> m;
153 return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any);
156 #ifndef BOOST_NO_WREGEX
157 inline bool regex_match(const wchar_t* str,
160 match_flag_type flags = match_default)
162 return regex_match(str, str + wregex::traits_type::length(str), m, e, flags);
164 inline bool regex_match(const wchar_t* str,
166 match_flag_type flags = match_default)
168 match_results<const wchar_t*> m;
169 return regex_match(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any);
171 #ifndef BOOST_NO_STD_LOCALE
172 inline bool regex_match(const wchar_t* str,
174 const basic_regex<wchar_t, cpp_regex_traits<wchar_t> >& e,
175 match_flag_type flags = match_default)
177 return regex_match(str, str + wregex::traits_type::length(str), m, e, flags);
179 inline bool regex_match(const wchar_t* str,
180 const basic_regex<wchar_t, cpp_regex_traits<wchar_t> >& e,
181 match_flag_type flags = match_default)
183 match_results<const wchar_t*> m;
184 return regex_match(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any);
187 inline bool regex_match(const wchar_t* str,
189 const basic_regex<wchar_t, c_regex_traits<wchar_t> >& e,
190 match_flag_type flags = match_default)
192 return regex_match(str, str + wregex::traits_type::length(str), m, e, flags);
194 inline bool regex_match(const wchar_t* str,
195 const basic_regex<wchar_t, c_regex_traits<wchar_t> >& e,
196 match_flag_type flags = match_default)
198 match_results<const wchar_t*> m;
199 return regex_match(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any);
201 #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
202 inline bool regex_match(const wchar_t* str,
204 const basic_regex<wchar_t, w32_regex_traits<wchar_t> >& e,
205 match_flag_type flags = match_default)
207 return regex_match(str, str + wregex::traits_type::length(str), m, e, flags);
209 inline bool regex_match(const wchar_t* str,
210 const basic_regex<wchar_t, w32_regex_traits<wchar_t> >& e,
211 match_flag_type flags = match_default)
213 match_results<const wchar_t*> m;
214 return regex_match(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any);
218 inline bool regex_match(const std::string& s,
221 match_flag_type flags = match_default)
223 return regex_match(s.begin(), s.end(), m, e, flags);
225 inline bool regex_match(const std::string& s,
227 match_flag_type flags = match_default)
229 match_results<std::string::const_iterator> m;
230 return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any);
232 #ifndef BOOST_NO_STD_LOCALE
233 inline bool regex_match(const std::string& s,
235 const basic_regex<char, cpp_regex_traits<char> >& e,
236 match_flag_type flags = match_default)
238 return regex_match(s.begin(), s.end(), m, e, flags);
240 inline bool regex_match(const std::string& s,
241 const basic_regex<char, cpp_regex_traits<char> >& e,
242 match_flag_type flags = match_default)
244 match_results<std::string::const_iterator> m;
245 return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any);
248 inline bool regex_match(const std::string& s,
250 const basic_regex<char, c_regex_traits<char> >& e,
251 match_flag_type flags = match_default)
253 return regex_match(s.begin(), s.end(), m, e, flags);
255 inline bool regex_match(const std::string& s,
256 const basic_regex<char, c_regex_traits<char> >& e,
257 match_flag_type flags = match_default)
259 match_results<std::string::const_iterator> m;
260 return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any);
262 #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
263 inline bool regex_match(const std::string& s,
265 const basic_regex<char, w32_regex_traits<char> >& e,
266 match_flag_type flags = match_default)
268 return regex_match(s.begin(), s.end(), m, e, flags);
270 inline bool regex_match(const std::string& s,
271 const basic_regex<char, w32_regex_traits<char> >& e,
272 match_flag_type flags = match_default)
274 match_results<std::string::const_iterator> m;
275 return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any);
278 #if !defined(BOOST_NO_WREGEX)
279 inline bool regex_match(const std::basic_string<wchar_t>& s,
280 match_results<std::basic_string<wchar_t>::const_iterator>& m,
282 match_flag_type flags = match_default)
284 return regex_match(s.begin(), s.end(), m, e, flags);
286 inline bool regex_match(const std::basic_string<wchar_t>& s,
288 match_flag_type flags = match_default)
290 match_results<std::basic_string<wchar_t>::const_iterator> m;
291 return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any);
293 #ifndef BOOST_NO_STD_LOCALE
294 inline bool regex_match(const std::basic_string<wchar_t>& s,
295 match_results<std::basic_string<wchar_t>::const_iterator>& m,
296 const basic_regex<wchar_t, cpp_regex_traits<wchar_t> >& e,
297 match_flag_type flags = match_default)
299 return regex_match(s.begin(), s.end(), m, e, flags);
301 inline bool regex_match(const std::basic_string<wchar_t>& s,
302 const basic_regex<wchar_t, cpp_regex_traits<wchar_t> >& e,
303 match_flag_type flags = match_default)
305 match_results<std::basic_string<wchar_t>::const_iterator> m;
306 return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any);
309 inline bool regex_match(const std::basic_string<wchar_t>& s,
310 match_results<std::basic_string<wchar_t>::const_iterator>& m,
311 const basic_regex<wchar_t, c_regex_traits<wchar_t> >& e,
312 match_flag_type flags = match_default)
314 return regex_match(s.begin(), s.end(), m, e, flags);
316 inline bool regex_match(const std::basic_string<wchar_t>& s,
317 const basic_regex<wchar_t, c_regex_traits<wchar_t> >& e,
318 match_flag_type flags = match_default)
320 match_results<std::basic_string<wchar_t>::const_iterator> m;
321 return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any);
323 #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
324 inline bool regex_match(const std::basic_string<wchar_t>& s,
325 match_results<std::basic_string<wchar_t>::const_iterator>& m,
326 const basic_regex<wchar_t, w32_regex_traits<wchar_t> >& e,
327 match_flag_type flags = match_default)
329 return regex_match(s.begin(), s.end(), m, e, flags);
331 inline bool regex_match(const std::basic_string<wchar_t>& s,
332 const basic_regex<wchar_t, w32_regex_traits<wchar_t> >& e,
333 match_flag_type flags = match_default)
335 match_results<std::basic_string<wchar_t>::const_iterator> m;
336 return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any);
344 #ifdef BOOST_HAS_ABI_HEADERS
345 # include BOOST_ABI_SUFFIX
350 #endif // BOOST_REGEX_MATCH_HPP