]> git.lyx.org Git - lyx.git/blob - boost/boost/regex/v4/regex_match.hpp
Boost 1.31.0
[lyx.git] / boost / boost / regex / v4 / regex_match.hpp
1 /*
2  *
3  * Copyright (c) 1998-2002
4  * Dr 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 #ifndef BOOST_REGEX_MAX_STATE_COUNT
26 #  define BOOST_REGEX_MAX_STATE_COUNT 100000000
27 #endif
28
29 #include <boost/limits.hpp>
30 #include <boost/regex/v4/perl_matcher.hpp>
31
32
33 namespace boost{
34
35 #ifdef BOOST_HAS_ABI_HEADERS
36 #  include BOOST_ABI_PREFIX
37 #endif
38
39 //
40 // proc regex_match
41 // returns true if the specified regular expression matches
42 // the whole of the input.  Fills in what matched in m.
43 //
44 template <class BidiIterator, class Allocator, class charT, class traits, class Allocator2>
45 bool regex_match(BidiIterator first, BidiIterator last, 
46                  match_results<BidiIterator, Allocator>& m, 
47                  const reg_expression<charT, traits, Allocator2>& e, 
48                  match_flag_type flags = match_default)
49 {
50    re_detail::perl_matcher<BidiIterator, Allocator, traits, Allocator2> matcher(first, last, m, e, flags);
51    return matcher.match();
52 }
53 template <class iterator, class charT, class traits, class Allocator2>
54 bool regex_match(iterator first, iterator last, 
55                  const reg_expression<charT, traits, Allocator2>& e, 
56                  match_flag_type flags = match_default)
57 {
58    match_results<iterator> m;
59    return regex_match(first, last, m, e, flags);
60 }
61 //
62 // query_match convenience interfaces:
63 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
64 //
65 // this isn't really a partial specialisation, but template function
66 // overloading - if the compiler doesn't support partial specialisation
67 // then it really won't support this either:
68 template <class charT, class Allocator, class traits, class Allocator2>
69 inline bool regex_match(const charT* str, 
70                         match_results<const charT*, Allocator>& m, 
71                         const reg_expression<charT, traits, Allocator2>& e, 
72                         match_flag_type flags = match_default)
73 {
74    return regex_match(str, str + traits::length(str), m, e, flags);
75 }
76
77 template <class ST, class SA, class Allocator, class charT, class traits, class Allocator2>
78 inline bool regex_match(const std::basic_string<charT, ST, SA>& s, 
79                  match_results<typename std::basic_string<charT, ST, SA>::const_iterator, Allocator>& m, 
80                  const reg_expression<charT, traits, Allocator2>& e, 
81                  match_flag_type flags = match_default)
82 {
83    return regex_match(s.begin(), s.end(), m, e, flags);
84 }
85 template <class charT, class traits, class Allocator2>
86 inline bool regex_match(const charT* str, 
87                         const reg_expression<charT, traits, Allocator2>& e, 
88                         match_flag_type flags = match_default)
89 {
90    match_results<const charT*> m;
91    return regex_match(str, str + traits::length(str), m, e, flags);
92 }
93
94 template <class ST, class SA, class charT, class traits, class Allocator2>
95 inline bool regex_match(const std::basic_string<charT, ST, SA>& s, 
96                  const reg_expression<charT, traits, Allocator2>& e, 
97                  match_flag_type flags = match_default)
98 {
99    typedef typename std::basic_string<charT, ST, SA>::const_iterator iterator;
100    match_results<iterator> m;
101    return regex_match(s.begin(), s.end(), m, e, flags);
102 }
103 #else  // partial ordering
104 inline bool regex_match(const char* str, 
105                         cmatch& m, 
106                         const regex& e, 
107                         match_flag_type flags = match_default)
108 {
109    return regex_match(str, str + regex::traits_type::length(str), m, e, flags);
110 }
111 inline bool regex_match(const char* str, 
112                         const regex& e, 
113                         match_flag_type flags = match_default)
114 {
115    match_results<const char*> m;
116    return regex_match(str, str + regex::traits_type::length(str), m, e, flags);
117 }
118 #ifndef BOOST_NO_WREGEX
119 inline bool regex_match(const wchar_t* str, 
120                         wcmatch& m, 
121                         const wregex& e, 
122                         match_flag_type flags = match_default)
123 {
124    return regex_match(str, str + wregex::traits_type::length(str), m, e, flags);
125 }
126 inline bool regex_match(const wchar_t* str, 
127                         const wregex& e, 
128                         match_flag_type flags = match_default)
129 {
130    match_results<const wchar_t*> m;
131    return regex_match(str, str + wregex::traits_type::length(str), m, e, flags);
132 }
133 #endif
134 inline bool regex_match(const std::string& s, 
135                         smatch& m,
136                         const regex& e, 
137                         match_flag_type flags = match_default)
138 {
139    return regex_match(s.begin(), s.end(), m, e, flags);
140 }
141 inline bool regex_match(const std::string& s, 
142                         const regex& e, 
143                         match_flag_type flags = match_default)
144 {
145    match_results<std::string::const_iterator, regex::allocator_type> m;
146    return regex_match(s.begin(), s.end(), m, e, flags);
147 }
148 #if !defined(BOOST_NO_WREGEX)
149 inline bool regex_match(const std::basic_string<wchar_t>& s, 
150                         match_results<std::basic_string<wchar_t>::const_iterator, wregex::allocator_type>& m,
151                         const wregex& e, 
152                         match_flag_type flags = match_default)
153 {
154    return regex_match(s.begin(), s.end(), m, e, flags);
155 }
156 inline bool regex_match(const std::basic_string<wchar_t>& s, 
157                         const wregex& e, 
158                         match_flag_type flags = match_default)
159 {
160    match_results<std::basic_string<wchar_t>::const_iterator, wregex::allocator_type> m;
161    return regex_match(s.begin(), s.end(), m, e, flags);
162 }
163 #endif
164
165 #endif
166
167
168 #ifdef BOOST_HAS_ABI_HEADERS
169 #  include BOOST_ABI_SUFFIX
170 #endif
171
172 } // namespace boost
173
174 #endif   // BOOST_REGEX_MATCH_HPP
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192