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_search.hpp
15 * VERSION see <boost/version.hpp>
16 * DESCRIPTION: Provides regex_search implementation.
19 #ifndef BOOST_REGEX_V4_REGEX_SEARCH_HPP
20 #define BOOST_REGEX_V4_REGEX_SEARCH_HPP
25 #ifdef BOOST_HAS_ABI_HEADERS
26 # include BOOST_ABI_PREFIX
29 template <class BidiIterator, class Allocator, class charT, class traits>
30 bool regex_search(BidiIterator first, BidiIterator last,
31 match_results<BidiIterator, Allocator>& m,
32 const basic_regex<charT, traits>& e,
33 match_flag_type flags = match_default)
35 return regex_search(first, last, m, e, flags, first);
38 template <class BidiIterator, class Allocator, class charT, class traits>
39 bool regex_search(BidiIterator first, BidiIterator last,
40 match_results<BidiIterator, Allocator>& m,
41 const basic_regex<charT, traits>& e,
42 match_flag_type flags,
45 if(e.flags() & regex_constants::failbit)
48 re_detail::perl_matcher<BidiIterator, Allocator, traits> matcher(first, last, m, e, flags, base);
49 return matcher.find();
53 // regex_search convenience interfaces:
54 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
56 // this isn't really a partial specialisation, but template function
57 // overloading - if the compiler doesn't support partial specialisation
58 // then it really won't support this either:
59 template <class charT, class Allocator, class traits>
60 inline bool regex_search(const charT* str,
61 match_results<const charT*, Allocator>& m,
62 const basic_regex<charT, traits>& e,
63 match_flag_type flags = match_default)
65 return regex_search(str, str + traits::length(str), m, e, flags);
68 template <class ST, class SA, class Allocator, class charT, class traits>
69 inline bool regex_search(const std::basic_string<charT, ST, SA>& s,
70 match_results<typename std::basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
71 const basic_regex<charT, traits>& e,
72 match_flag_type flags = match_default)
74 return regex_search(s.begin(), s.end(), m, e, flags);
76 #else // partial overloads:
77 inline bool regex_search(const char* str,
80 match_flag_type flags = match_default)
82 return regex_search(str, str + regex::traits_type::length(str), m, e, flags);
84 inline bool regex_search(const char* first, const char* last,
86 match_flag_type flags = match_default)
89 return regex_search(first, last, m, e, flags | regex_constants::match_any);
92 #ifndef BOOST_NO_WREGEX
93 inline bool regex_search(const wchar_t* str,
96 match_flag_type flags = match_default)
98 return regex_search(str, str + wregex::traits_type::length(str), m, e, flags);
100 inline bool regex_search(const wchar_t* first, const wchar_t* last,
102 match_flag_type flags = match_default)
105 return regex_search(first, last, m, e, flags | regex_constants::match_any);
108 inline bool regex_search(const std::string& s,
111 match_flag_type flags = match_default)
113 return regex_search(s.begin(), s.end(), m, e, flags);
115 #if !defined(BOOST_NO_WREGEX)
116 inline bool regex_search(const std::basic_string<wchar_t>& s,
119 match_flag_type flags = match_default)
121 return regex_search(s.begin(), s.end(), m, e, flags);
127 template <class BidiIterator, class charT, class traits>
128 bool regex_search(BidiIterator first, BidiIterator last,
129 const basic_regex<charT, traits>& e,
130 match_flag_type flags = match_default)
132 if(e.flags() & regex_constants::failbit)
135 match_results<BidiIterator> m;
136 typedef typename match_results<BidiIterator>::allocator_type match_alloc_type;
137 re_detail::perl_matcher<BidiIterator, match_alloc_type, traits> matcher(first, last, m, e, flags | regex_constants::match_any, first);
138 return matcher.find();
141 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
143 template <class charT, class traits>
144 inline bool regex_search(const charT* str,
145 const basic_regex<charT, traits>& e,
146 match_flag_type flags = match_default)
148 return regex_search(str, str + traits::length(str), e, flags);
151 template <class ST, class SA, class charT, class traits>
152 inline bool regex_search(const std::basic_string<charT, ST, SA>& s,
153 const basic_regex<charT, traits>& e,
154 match_flag_type flags = match_default)
156 return regex_search(s.begin(), s.end(), e, flags);
158 #else // non-template function overloads
159 inline bool regex_search(const char* str,
161 match_flag_type flags = match_default)
164 return regex_search(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any);
166 #ifndef BOOST_NO_WREGEX
167 inline bool regex_search(const wchar_t* str,
169 match_flag_type flags = match_default)
172 return regex_search(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any);
175 inline bool regex_search(const std::string& s,
177 match_flag_type flags = match_default)
180 return regex_search(s.begin(), s.end(), m, e, flags | regex_constants::match_any);
182 #if !defined(BOOST_NO_WREGEX)
183 inline bool regex_search(const std::basic_string<wchar_t>& s,
185 match_flag_type flags = match_default)
188 return regex_search(s.begin(), s.end(), m, e, flags | regex_constants::match_any);
191 #endif // BOOST_NO_WREGEX
193 #endif // partial overload
195 #ifdef BOOST_HAS_ABI_HEADERS
196 # include BOOST_ABI_SUFFIX
201 #endif // BOOST_REGEX_V4_REGEX_SEARCH_HPP