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 //
28 // proc regex_match
29 // returns true if the specified regular expression matches
30 // the whole of the input. Fills in what matched in m.
31 //
32 template <class BidiIterator, class Allocator, class charT, class traits>
regex_match(BidiIterator first,BidiIterator last,match_results<BidiIterator,Allocator> & m,const basic_regex<charT,traits> & e,match_flag_type flags=match_default)33 bool regex_match(BidiIterator first, BidiIterator last,
34 match_results<BidiIterator, Allocator>& m,
35 const basic_regex<charT, traits>& e,
36 match_flag_type flags = match_default)
37 {
38 BOOST_REGEX_DETAIL_NS::perl_matcher<BidiIterator, Allocator, traits> matcher(first, last, m, e, flags, first);
39 return matcher.match();
40 }
41 template <class iterator, class charT, class traits>
regex_match(iterator first,iterator last,const basic_regex<charT,traits> & e,match_flag_type flags=match_default)42 bool regex_match(iterator first, iterator last,
43 const basic_regex<charT, traits>& e,
44 match_flag_type flags = match_default)
45 {
46 match_results<iterator> m;
47 return regex_match(first, last, m, e, flags | regex_constants::match_any);
48 }
49 //
50 // query_match convenience interfaces:
51 //
52 template <class charT, class Allocator, class traits>
regex_match(const charT * str,match_results<const charT *,Allocator> & m,const basic_regex<charT,traits> & e,match_flag_type flags=match_default)53 inline bool regex_match(const charT* str,
54 match_results<const charT*, Allocator>& m,
55 const basic_regex<charT, traits>& e,
56 match_flag_type flags = match_default)
57 {
58 return regex_match(str, str + traits::length(str), m, e, flags);
59 }
60
61 template <class ST, class SA, class Allocator, class charT, class traits>
regex_match(const std::basic_string<charT,ST,SA> & s,match_results<typename std::basic_string<charT,ST,SA>::const_iterator,Allocator> & m,const basic_regex<charT,traits> & e,match_flag_type flags=match_default)62 inline bool regex_match(const std::basic_string<charT, ST, SA>& s,
63 match_results<typename std::basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
64 const basic_regex<charT, traits>& e,
65 match_flag_type flags = match_default)
66 {
67 return regex_match(s.begin(), s.end(), m, e, flags);
68 }
69 template <class charT, class traits>
regex_match(const charT * str,const basic_regex<charT,traits> & e,match_flag_type flags=match_default)70 inline bool regex_match(const charT* str,
71 const basic_regex<charT, traits>& e,
72 match_flag_type flags = match_default)
73 {
74 match_results<const charT*> m;
75 return regex_match(str, str + traits::length(str), m, e, flags | regex_constants::match_any);
76 }
77
78 template <class ST, class SA, class charT, class traits>
regex_match(const std::basic_string<charT,ST,SA> & s,const basic_regex<charT,traits> & e,match_flag_type flags=match_default)79 inline bool regex_match(const std::basic_string<charT, ST, SA>& s,
80 const basic_regex<charT, traits>& e,
81 match_flag_type flags = match_default)
82 {
83 typedef typename std::basic_string<charT, ST, SA>::const_iterator iterator;
84 match_results<iterator> m;
85 return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any);
86 }
87
88
89 } // namespace boost
90
91 #endif // BOOST_REGEX_MATCH_HPP
92
93