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
27 #pragma warning(disable: 4103)
29 #ifdef BOOST_HAS_ABI_HEADERS
30 # include BOOST_ABI_PREFIX
36 template <class BidiIterator
, class Allocator
, class charT
, class traits
>
37 bool regex_search(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 return regex_search(first
, last
, m
, e
, flags
, first
);
45 template <class BidiIterator
, class Allocator
, class charT
, class traits
>
46 bool regex_search(BidiIterator first
, BidiIterator last
,
47 match_results
<BidiIterator
, Allocator
>& m
,
48 const basic_regex
<charT
, traits
>& e
,
49 match_flag_type flags
,
52 if(e
.flags() & regex_constants::failbit
)
55 re_detail::perl_matcher
<BidiIterator
, Allocator
, traits
> matcher(first
, last
, m
, e
, flags
, base
);
56 return matcher
.find();
60 // regex_search convenience interfaces:
61 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
63 // this isn't really a partial specialisation, but template function
64 // overloading - if the compiler doesn't support partial specialisation
65 // then it really won't support this either:
66 template <class charT
, class Allocator
, class traits
>
67 inline bool regex_search(const charT
* str
,
68 match_results
<const charT
*, Allocator
>& m
,
69 const basic_regex
<charT
, traits
>& e
,
70 match_flag_type flags
= match_default
)
72 return regex_search(str
, str
+ traits::length(str
), m
, e
, flags
);
75 template <class ST
, class SA
, class Allocator
, class charT
, class traits
>
76 inline bool regex_search(const std::basic_string
<charT
, ST
, SA
>& s
,
77 match_results
<typename
std::basic_string
<charT
, ST
, SA
>::const_iterator
, Allocator
>& m
,
78 const basic_regex
<charT
, traits
>& e
,
79 match_flag_type flags
= match_default
)
81 return regex_search(s
.begin(), s
.end(), m
, e
, flags
);
83 #else // partial overloads:
84 inline bool regex_search(const char* str
,
87 match_flag_type flags
= match_default
)
89 return regex_search(str
, str
+ regex::traits_type::length(str
), m
, e
, flags
);
91 inline bool regex_search(const char* first
, const char* last
,
93 match_flag_type flags
= match_default
)
96 return regex_search(first
, last
, m
, e
, flags
| regex_constants::match_any
);
99 #ifndef BOOST_NO_WREGEX
100 inline bool regex_search(const wchar_t* str
,
103 match_flag_type flags
= match_default
)
105 return regex_search(str
, str
+ wregex::traits_type::length(str
), m
, e
, flags
);
107 inline bool regex_search(const wchar_t* first
, const wchar_t* last
,
109 match_flag_type flags
= match_default
)
112 return regex_search(first
, last
, m
, e
, flags
| regex_constants::match_any
);
115 inline bool regex_search(const std::string
& s
,
118 match_flag_type flags
= match_default
)
120 return regex_search(s
.begin(), s
.end(), m
, e
, flags
);
122 #if !defined(BOOST_NO_WREGEX)
123 inline bool regex_search(const std::basic_string
<wchar_t>& s
,
126 match_flag_type flags
= match_default
)
128 return regex_search(s
.begin(), s
.end(), m
, e
, flags
);
134 template <class BidiIterator
, class charT
, class traits
>
135 bool regex_search(BidiIterator first
, BidiIterator last
,
136 const basic_regex
<charT
, traits
>& e
,
137 match_flag_type flags
= match_default
)
139 if(e
.flags() & regex_constants::failbit
)
142 match_results
<BidiIterator
> m
;
143 typedef typename match_results
<BidiIterator
>::allocator_type match_alloc_type
;
144 re_detail::perl_matcher
<BidiIterator
, match_alloc_type
, traits
> matcher(first
, last
, m
, e
, flags
| regex_constants::match_any
, first
);
145 return matcher
.find();
148 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
150 template <class charT
, class traits
>
151 inline bool regex_search(const charT
* str
,
152 const basic_regex
<charT
, traits
>& e
,
153 match_flag_type flags
= match_default
)
155 return regex_search(str
, str
+ traits::length(str
), e
, flags
);
158 template <class ST
, class SA
, class charT
, class traits
>
159 inline bool regex_search(const std::basic_string
<charT
, ST
, SA
>& s
,
160 const basic_regex
<charT
, traits
>& e
,
161 match_flag_type flags
= match_default
)
163 return regex_search(s
.begin(), s
.end(), e
, flags
);
165 #else // non-template function overloads
166 inline bool regex_search(const char* str
,
168 match_flag_type flags
= match_default
)
171 return regex_search(str
, str
+ regex::traits_type::length(str
), m
, e
, flags
| regex_constants::match_any
);
173 #ifndef BOOST_NO_WREGEX
174 inline bool regex_search(const wchar_t* str
,
176 match_flag_type flags
= match_default
)
179 return regex_search(str
, str
+ wregex::traits_type::length(str
), m
, e
, flags
| regex_constants::match_any
);
182 inline bool regex_search(const std::string
& s
,
184 match_flag_type flags
= match_default
)
187 return regex_search(s
.begin(), s
.end(), m
, e
, flags
| regex_constants::match_any
);
189 #if !defined(BOOST_NO_WREGEX)
190 inline bool regex_search(const std::basic_string
<wchar_t>& s
,
192 match_flag_type flags
= match_default
)
195 return regex_search(s
.begin(), s
.end(), m
, e
, flags
| regex_constants::match_any
);
198 #endif // BOOST_NO_WREGEX
200 #endif // partial overload
203 #pragma warning(push)
204 #pragma warning(disable: 4103)
206 #ifdef BOOST_HAS_ABI_HEADERS
207 # include BOOST_ABI_SUFFIX
215 #endif // BOOST_REGEX_V4_REGEX_SEARCH_HPP