| 1 | /* |
|---|
| 2 | * |
|---|
| 3 | * Copyright (c) 1998-2002 |
|---|
| 4 | * John Maddock |
|---|
| 5 | * |
|---|
| 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) |
|---|
| 9 | * |
|---|
| 10 | */ |
|---|
| 11 | |
|---|
| 12 | /* |
|---|
| 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. |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | #ifndef BOOST_REGEX_MATCH_HPP |
|---|
| 23 | #define BOOST_REGEX_MATCH_HPP |
|---|
| 24 | |
|---|
| 25 | namespace boost{ |
|---|
| 26 | |
|---|
| 27 | #ifdef BOOST_HAS_ABI_HEADERS |
|---|
| 28 | # include BOOST_ABI_PREFIX |
|---|
| 29 | #endif |
|---|
| 30 | |
|---|
| 31 | // |
|---|
| 32 | // proc regex_match |
|---|
| 33 | // returns true if the specified regular expression matches |
|---|
| 34 | // the whole of the input. Fills in what matched in m. |
|---|
| 35 | // |
|---|
| 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) |
|---|
| 41 | { |
|---|
| 42 | re_detail::perl_matcher<BidiIterator, Allocator, traits> matcher(first, last, m, e, flags, first); |
|---|
| 43 | return matcher.match(); |
|---|
| 44 | } |
|---|
| 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) |
|---|
| 49 | { |
|---|
| 50 | match_results<iterator> m; |
|---|
| 51 | return regex_match(first, last, m, e, flags | regex_constants::match_any); |
|---|
| 52 | } |
|---|
| 53 | // |
|---|
| 54 | // query_match convenience interfaces: |
|---|
| 55 | #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING |
|---|
| 56 | // |
|---|
| 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) |
|---|
| 65 | { |
|---|
| 66 | return regex_match(str, str + traits::length(str), m, e, flags); |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 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) |
|---|
| 74 | { |
|---|
| 75 | return regex_match(s.begin(), s.end(), m, e, flags); |
|---|
| 76 | } |
|---|
| 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) |
|---|
| 81 | { |
|---|
| 82 | match_results<const charT*> m; |
|---|
| 83 | return regex_match(str, str + traits::length(str), m, e, flags | regex_constants::match_any); |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 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) |
|---|
| 90 | { |
|---|
| 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); |
|---|
| 94 | } |
|---|
| 95 | #else // partial ordering |
|---|
| 96 | inline bool regex_match(const char* str, |
|---|
| 97 | cmatch& m, |
|---|
| 98 | const regex& e, |
|---|
| 99 | match_flag_type flags = match_default) |
|---|
| 100 | { |
|---|
| 101 | return regex_match(str, str + regex::traits_type::length(str), m, e, flags); |
|---|
| 102 | } |
|---|
| 103 | inline bool regex_match(const char* str, |
|---|
| 104 | const regex& e, |
|---|
| 105 | match_flag_type flags = match_default) |
|---|
| 106 | { |
|---|
| 107 | match_results<const char*> m; |
|---|
| 108 | return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any); |
|---|
| 109 | } |
|---|
| 110 | #ifndef BOOST_NO_STD_LOCALE |
|---|
| 111 | inline bool regex_match(const char* str, |
|---|
| 112 | cmatch& m, |
|---|
| 113 | const basic_regex<char, cpp_regex_traits<char> >& e, |
|---|
| 114 | match_flag_type flags = match_default) |
|---|
| 115 | { |
|---|
| 116 | return regex_match(str, str + regex::traits_type::length(str), m, e, flags); |
|---|
| 117 | } |
|---|
| 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) |
|---|
| 121 | { |
|---|
| 122 | match_results<const char*> m; |
|---|
| 123 | return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any); |
|---|
| 124 | } |
|---|
| 125 | #endif |
|---|
| 126 | inline bool regex_match(const char* str, |
|---|
| 127 | cmatch& m, |
|---|
| 128 | const basic_regex<char, c_regex_traits<char> >& e, |
|---|
| 129 | match_flag_type flags = match_default) |
|---|
| 130 | { |
|---|
| 131 | return regex_match(str, str + regex::traits_type::length(str), m, e, flags); |
|---|
| 132 | } |
|---|
| 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) |
|---|
| 136 | { |
|---|
| 137 | match_results<const char*> m; |
|---|
| 138 | return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any); |
|---|
| 139 | } |
|---|
| 140 | #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) |
|---|
| 141 | inline bool regex_match(const char* str, |
|---|
| 142 | cmatch& m, |
|---|
| 143 | const basic_regex<char, w32_regex_traits<char> >& e, |
|---|
| 144 | match_flag_type flags = match_default) |
|---|
| 145 | { |
|---|
| 146 | return regex_match(str, str + regex::traits_type::length(str), m, e, flags); |
|---|
| 147 | } |
|---|
| 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) |
|---|
| 151 | { |
|---|
| 152 | match_results<const char*> m; |
|---|
| 153 | return regex_match(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any); |
|---|
| 154 | } |
|---|
| 155 | #endif |
|---|
| 156 | #ifndef BOOST_NO_WREGEX |
|---|
| 157 | inline bool regex_match(const wchar_t* str, |
|---|
| 158 | wcmatch& m, |
|---|
| 159 | const wregex& e, |
|---|
| 160 | match_flag_type flags = match_default) |
|---|
| 161 | { |
|---|
| 162 | return regex_match(str, str + wregex::traits_type::length(str), m, e, flags); |
|---|
| 163 | } |
|---|
| 164 | inline bool regex_match(const wchar_t* str, |
|---|
| 165 | const wregex& e, |
|---|
| 166 | match_flag_type flags = match_default) |
|---|
| 167 | { |
|---|
| 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); |
|---|
| 170 | } |
|---|
| 171 | #ifndef BOOST_NO_STD_LOCALE |
|---|
| 172 | inline bool regex_match(const wchar_t* str, |
|---|
| 173 | wcmatch& m, |
|---|
| 174 | const basic_regex<wchar_t, cpp_regex_traits<wchar_t> >& e, |
|---|
| 175 | match_flag_type flags = match_default) |
|---|
| 176 | { |
|---|
| 177 | return regex_match(str, str + wregex::traits_type::length(str), m, e, flags); |
|---|
| 178 | } |
|---|
| 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) |
|---|
| 182 | { |
|---|
| 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); |
|---|
| 185 | } |
|---|
| 186 | #endif |
|---|
| 187 | inline bool regex_match(const wchar_t* str, |
|---|
| 188 | wcmatch& m, |
|---|
| 189 | const basic_regex<wchar_t, c_regex_traits<wchar_t> >& e, |
|---|
| 190 | match_flag_type flags = match_default) |
|---|
| 191 | { |
|---|
| 192 | return regex_match(str, str + wregex::traits_type::length(str), m, e, flags); |
|---|
| 193 | } |
|---|
| 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) |
|---|
| 197 | { |
|---|
| 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); |
|---|
| 200 | } |
|---|
| 201 | #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) |
|---|
| 202 | inline bool regex_match(const wchar_t* str, |
|---|
| 203 | wcmatch& m, |
|---|
| 204 | const basic_regex<wchar_t, w32_regex_traits<wchar_t> >& e, |
|---|
| 205 | match_flag_type flags = match_default) |
|---|
| 206 | { |
|---|
| 207 | return regex_match(str, str + wregex::traits_type::length(str), m, e, flags); |
|---|
| 208 | } |
|---|
| 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) |
|---|
| 212 | { |
|---|
| 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); |
|---|
| 215 | } |
|---|
| 216 | #endif |
|---|
| 217 | #endif |
|---|
| 218 | inline bool regex_match(const std::string& s, |
|---|
| 219 | smatch& m, |
|---|
| 220 | const regex& e, |
|---|
| 221 | match_flag_type flags = match_default) |
|---|
| 222 | { |
|---|
| 223 | return regex_match(s.begin(), s.end(), m, e, flags); |
|---|
| 224 | } |
|---|
| 225 | inline bool regex_match(const std::string& s, |
|---|
| 226 | const regex& e, |
|---|
| 227 | match_flag_type flags = match_default) |
|---|
| 228 | { |
|---|
| 229 | match_results<std::string::const_iterator> m; |
|---|
| 230 | return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); |
|---|
| 231 | } |
|---|
| 232 | #ifndef BOOST_NO_STD_LOCALE |
|---|
| 233 | inline bool regex_match(const std::string& s, |
|---|
| 234 | smatch& m, |
|---|
| 235 | const basic_regex<char, cpp_regex_traits<char> >& e, |
|---|
| 236 | match_flag_type flags = match_default) |
|---|
| 237 | { |
|---|
| 238 | return regex_match(s.begin(), s.end(), m, e, flags); |
|---|
| 239 | } |
|---|
| 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) |
|---|
| 243 | { |
|---|
| 244 | match_results<std::string::const_iterator> m; |
|---|
| 245 | return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); |
|---|
| 246 | } |
|---|
| 247 | #endif |
|---|
| 248 | inline bool regex_match(const std::string& s, |
|---|
| 249 | smatch& m, |
|---|
| 250 | const basic_regex<char, c_regex_traits<char> >& e, |
|---|
| 251 | match_flag_type flags = match_default) |
|---|
| 252 | { |
|---|
| 253 | return regex_match(s.begin(), s.end(), m, e, flags); |
|---|
| 254 | } |
|---|
| 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) |
|---|
| 258 | { |
|---|
| 259 | match_results<std::string::const_iterator> m; |
|---|
| 260 | return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); |
|---|
| 261 | } |
|---|
| 262 | #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) |
|---|
| 263 | inline bool regex_match(const std::string& s, |
|---|
| 264 | smatch& m, |
|---|
| 265 | const basic_regex<char, w32_regex_traits<char> >& e, |
|---|
| 266 | match_flag_type flags = match_default) |
|---|
| 267 | { |
|---|
| 268 | return regex_match(s.begin(), s.end(), m, e, flags); |
|---|
| 269 | } |
|---|
| 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) |
|---|
| 273 | { |
|---|
| 274 | match_results<std::string::const_iterator> m; |
|---|
| 275 | return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); |
|---|
| 276 | } |
|---|
| 277 | #endif |
|---|
| 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, |
|---|
| 281 | const wregex& e, |
|---|
| 282 | match_flag_type flags = match_default) |
|---|
| 283 | { |
|---|
| 284 | return regex_match(s.begin(), s.end(), m, e, flags); |
|---|
| 285 | } |
|---|
| 286 | inline bool regex_match(const std::basic_string<wchar_t>& s, |
|---|
| 287 | const wregex& e, |
|---|
| 288 | match_flag_type flags = match_default) |
|---|
| 289 | { |
|---|
| 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); |
|---|
| 292 | } |
|---|
| 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) |
|---|
| 298 | { |
|---|
| 299 | return regex_match(s.begin(), s.end(), m, e, flags); |
|---|
| 300 | } |
|---|
| 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) |
|---|
| 304 | { |
|---|
| 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); |
|---|
| 307 | } |
|---|
| 308 | #endif |
|---|
| 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) |
|---|
| 313 | { |
|---|
| 314 | return regex_match(s.begin(), s.end(), m, e, flags); |
|---|
| 315 | } |
|---|
| 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) |
|---|
| 319 | { |
|---|
| 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); |
|---|
| 322 | } |
|---|
| 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) |
|---|
| 328 | { |
|---|
| 329 | return regex_match(s.begin(), s.end(), m, e, flags); |
|---|
| 330 | } |
|---|
| 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) |
|---|
| 334 | { |
|---|
| 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); |
|---|
| 337 | } |
|---|
| 338 | #endif |
|---|
| 339 | #endif |
|---|
| 340 | |
|---|
| 341 | #endif |
|---|
| 342 | |
|---|
| 343 | |
|---|
| 344 | #ifdef BOOST_HAS_ABI_HEADERS |
|---|
| 345 | # include BOOST_ABI_SUFFIX |
|---|
| 346 | #endif |
|---|
| 347 | |
|---|
| 348 | } // namespace boost |
|---|
| 349 | |
|---|
| 350 | #endif // BOOST_REGEX_MATCH_HPP |
|---|
| 351 | |
|---|
| 352 | |
|---|
| 353 | |
|---|
| 354 | |
|---|
| 355 | |
|---|
| 356 | |
|---|
| 357 | |
|---|
| 358 | |
|---|
| 359 | |
|---|
| 360 | |
|---|
| 361 | |
|---|
| 362 | |
|---|
| 363 | |
|---|
| 364 | |
|---|
| 365 | |
|---|
| 366 | |
|---|
| 367 | |
|---|
| 368 | |
|---|