1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
---|
2 | <html> |
---|
3 | <head> |
---|
4 | <title>Boost.Regex: basic_regex</title> |
---|
5 | <meta name="generator" content="HTML Tidy, see www.w3.org"> |
---|
6 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
7 | <link rel="stylesheet" type="text/css" href="../../../boost.css"> |
---|
8 | </head> |
---|
9 | <body> |
---|
10 | <table id="Table1" cellspacing="1" cellpadding="1" width="100%" border="0"> |
---|
11 | <tr> |
---|
12 | <td valign="top" width="300"> |
---|
13 | <h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../boost.png" border="0"></a></h3> |
---|
14 | </td> |
---|
15 | <td width="353"> |
---|
16 | <h1 align="center">Boost.Regex</h1> |
---|
17 | <h2 align="center">basic_regex</h2> |
---|
18 | </td> |
---|
19 | <td width="50"> |
---|
20 | <h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3> |
---|
21 | </td> |
---|
22 | </tr> |
---|
23 | </table> |
---|
24 | <br> |
---|
25 | <br> |
---|
26 | <hr> |
---|
27 | <h3>Synopsis</h3> |
---|
28 | <pre> |
---|
29 | #include <<a href="../../../boost/regex.hpp">boost/regex.hpp</a>> |
---|
30 | </pre> |
---|
31 | <p>The template class <em>basic_regex</em> encapsulates regular expression parsing |
---|
32 | and compilation. The class takes two template parameters:</p> |
---|
33 | <p><b><i>charT</i></b>: determines the character type, i.e. either char or |
---|
34 | wchar_t; see <EM><A href="concepts.html#charT">charT concept</A></EM>.</p> |
---|
35 | <p><b><i>traits</i></b>: determines the behavior of the character type, for |
---|
36 | example which character class names are recognized. A default traits class is |
---|
37 | provided: <a href="regex_traits.html">regex_traits<charT></a>. See |
---|
38 | also <EM><A href="concepts.html#traits">traits concept</A></EM>.</p> |
---|
39 | <p>For ease of use there are two typedefs that define the two standard <i>basic_regex</i> |
---|
40 | instances, unless you want to use custom traits classes or non-standard |
---|
41 | character types, you won't need to use anything other than these:</p> |
---|
42 | <pre> |
---|
43 | <b>namespace</b> boost{ |
---|
44 | <b>template</b> <<b>class</b> charT, <b>class</b> traits = regex_traits<charT> > |
---|
45 | <b>class</b> basic_regex; |
---|
46 | <b>typedef</b> basic_regex<<b>char</b>> regex; |
---|
47 | <b>typedef</b> basic_regex<<b>wchar_t></b> wregex; |
---|
48 | } |
---|
49 | </pre> |
---|
50 | <p>The definition of <i>basic_regex</i> follows: it is based very closely on class |
---|
51 | basic_string, and fulfils the requirements for a constant-container of <i>charT</i>.</p> |
---|
52 | <pre> |
---|
53 | namespace boost{ |
---|
54 | |
---|
55 | template <class charT, class traits = regex_traits<charT> > |
---|
56 | class basic_regex { |
---|
57 | public: |
---|
58 | // types: |
---|
59 | typedef charT value_type; |
---|
60 | typedef implementation-specific const_iterator; |
---|
61 | typedef const_iterator iterator; |
---|
62 | typedef charT& reference; |
---|
63 | typedef const charT& const_reference; |
---|
64 | typedef std::ptrdiff_t difference_type; |
---|
65 | typedef std::size_t size_type; |
---|
66 | typedef regex_constants::syntax_option_type flag_type; |
---|
67 | typedef typename traits::locale_type locale_type; |
---|
68 | |
---|
69 | // constants: |
---|
70 | // main option selection: |
---|
71 | static const regex_constants::syntax_option_type normal = regex_constants::normal; |
---|
72 | static const regex_constants::syntax_option_type ECMAScript = normal; |
---|
73 | static const regex_constants::syntax_option_type JavaScript = normal; |
---|
74 | static const regex_constants::syntax_option_type JScript = normal; |
---|
75 | static const regex_constants::syntax_option_type basic = regex_constants::basic; |
---|
76 | static const regex_constants::syntax_option_type extended = regex_constants::extended; |
---|
77 | static const regex_constants::syntax_option_type awk = regex_constants::awk; |
---|
78 | static const regex_constants::syntax_option_type grep = regex_constants::grep; |
---|
79 | static const regex_constants::syntax_option_type egrep = regex_constants::egrep; |
---|
80 | static const regex_constants::syntax_option_type sed = basic = regex_constants::sed; |
---|
81 | static const regex_constants::syntax_option_type perl = regex_constants::perl; |
---|
82 | static const regex_constants::syntax_option_type literal = regex_constants::literal; |
---|
83 | // modifiers specific to perl expressions: |
---|
84 | static const regex_constants::syntax_option_type no_mod_m = regex_constants::no_mod_m; |
---|
85 | static const regex_constants::syntax_option_type no_mod_s = regex_constants::no_mod_s; |
---|
86 | static const regex_constants::syntax_option_type mod_s = regex_constants::mod_s; |
---|
87 | static const regex_constants::syntax_option_type mod_x = regex_constants::mod_x; |
---|
88 | // modifiers specific to POSIX basic expressions: |
---|
89 | static const regex_constants::syntax_option_type bk_plus_qm = regex_constants::bk_plus_qm; |
---|
90 | static const regex_constants::syntax_option_type bk_vbar = regex_constants::bk_vbar |
---|
91 | static const regex_constants::syntax_option_type no_char_classes = regex_constants::no_char_classes |
---|
92 | static const regex_constants::syntax_option_type no_intervals = regex_constants::no_intervals |
---|
93 | // common modifiers: |
---|
94 | static const regex_constants::syntax_option_type nosubs = regex_constants::nosubs; |
---|
95 | static const regex_constants::syntax_option_type optimize = regex_constants::optimize; |
---|
96 | static const regex_constants::syntax_option_type collate = regex_constants::collate; |
---|
97 | static const regex_constants::syntax_option_type newline_alt = regex_constants::newline_alt; |
---|
98 | |
---|
99 | // construct/copy/destroy: |
---|
100 | explicit <A href="#c1">basic_regex</A> (); |
---|
101 | explicit <A href="#c2">basic_regex</A>(const charT* p, flag_type f = regex_constants::normal); |
---|
102 | <A href="#c3">basic_regex</A>(const charT* p1, const charT* p2, flag_type f = regex_constants::normal); |
---|
103 | <A href="#c4">basic_regex</A>(const charT* p, size_type len, flag_type f); |
---|
104 | <A href="#c5">basic_regex</A>(const basic_regex&); |
---|
105 | template <class ST, class SA> |
---|
106 | explicit <A href="#c6">basic_regex</A>(const basic_string<charT, ST, SA>& p, flag_type f = regex_constants::normal); |
---|
107 | template <class InputIterator> |
---|
108 | <A href="#c7">basic_regex</A>(InputIterator first, InputIterator last, flag_type f = regex_constants::normal); |
---|
109 | |
---|
110 | ~basic_regex(); |
---|
111 | basic_regex& <A href="#o1">operator</A>=(const basic_regex&); |
---|
112 | basic_regex& <A href="#o2">operator</A>= (const charT* ptr); |
---|
113 | template <class ST, class SA> |
---|
114 | basic_regex& <A href="#o3">operator</A>= (const basic_string<charT, ST, SA>& p); |
---|
115 | // iterators: |
---|
116 | const_iterator <A href="#m1">begin</A>() const; |
---|
117 | const_iterator <A href="#m2">end</A>() const; |
---|
118 | // capacity: |
---|
119 | size_type <A href="#m3">size</A>() const; |
---|
120 | size_type <A href="#m4">max_size</A>() const; |
---|
121 | bool <A href="#m5">empty</A>() const; |
---|
122 | unsigned <A href="#m6">mark_count</A>()const; |
---|
123 | // |
---|
124 | // modifiers: |
---|
125 | basic_regex& <A href="#a1">assign</A>(const basic_regex& that); |
---|
126 | basic_regex& <A href="#a2">assign</A>(const charT* ptr, flag_type f = regex_constants::normal); |
---|
127 | basic_regex& <A href="#a3">assign</A>(const charT* ptr, unsigned int len, flag_type f); |
---|
128 | template <class string_traits, class A> |
---|
129 | basic_regex& <A href="#a4">assign</A>(const basic_string<charT, string_traits, A>& s, |
---|
130 | flag_type f = regex_constants::normal); |
---|
131 | template <class InputIterator> |
---|
132 | basic_regex& <A href="#a5">assign</A>(InputIterator first, InputIterator last, |
---|
133 | flag_type f = regex_constants::normal); |
---|
134 | |
---|
135 | // const operations: |
---|
136 | flag_type <A href="#m8">flags</A>() const; |
---|
137 | basic_string<charT> <A href="#m9">str</A>() const; |
---|
138 | int <A href="#m10">compare</A>(basic_regex&) const; |
---|
139 | // locale: |
---|
140 | locale_type <A href="#m11">imbue</A>(locale_type loc); |
---|
141 | locale_type <A href="#m12">getloc</A>() const; |
---|
142 | // swap |
---|
143 | void <A href="#m13">swap</A>(basic_regex&) throw(); |
---|
144 | }; |
---|
145 | |
---|
146 | template <class charT, class traits> |
---|
147 | bool <A href="#o4">operator</A> == (const basic_regex<charT, traits>& lhs, |
---|
148 | const basic_regex<charT, traits>& rhs); |
---|
149 | template <class charT, class traits> |
---|
150 | bool <A href="#o5">operator</A> != (const basic_regex<charT, traits>& lhs, |
---|
151 | const basic_regex<charT, traits>& rhs); |
---|
152 | template <class charT, class traits> |
---|
153 | bool <A href="#o7">operator</A> < (const basic_regex<charT, traits>& lhs, |
---|
154 | const basic_regex<charT, traits>& rhs); |
---|
155 | template <class charT, class traits> |
---|
156 | bool <A href="#o8">operator</A> <= (const basic_regex<charT, traits>& lhs, |
---|
157 | const basic_regex<charT, traits>& rhs); |
---|
158 | template <class charT, class traits> |
---|
159 | bool <A href="#o9">operator</A> >= (const basic_regex<charT, traits>& lhs, |
---|
160 | const basic_regex<charT, traits>& rhs); |
---|
161 | template <class charT, class traits> |
---|
162 | bool <A href="#o10">operator</A> > (const basic_regex<charT, traits>& lhs, |
---|
163 | const basic_regex<charT, traits>& rhs); |
---|
164 | |
---|
165 | template <class charT, class io_traits, class re_traits> |
---|
166 | basic_ostream<charT, io_traits>& |
---|
167 | <A href="#o11">operator</A> << (basic_ostream<charT, io_traits>& os, |
---|
168 | const basic_regex<charT, re_traits>& e); |
---|
169 | |
---|
170 | template <class charT, class traits> |
---|
171 | void <A href="#o12">swap</A>(basic_regex<charT, traits>& e1, |
---|
172 | basic_regex<charT, traits>& e2); |
---|
173 | |
---|
174 | typedef basic_regex<char> regex; |
---|
175 | typedef basic_regex<wchar_t> wregex; |
---|
176 | |
---|
177 | } // namespace boost |
---|
178 | </pre> |
---|
179 | <h3>Description</h3> |
---|
180 | <p>Class <em>basic_regex</em> has the following public member functions:</p> |
---|
181 | <h4>basic_regex constants</h4> |
---|
182 | <pre> |
---|
183 | // main option selection: |
---|
184 | static const regex_constants::syntax_option_type normal = regex_constants::normal; |
---|
185 | static const regex_constants::syntax_option_type ECMAScript = normal; |
---|
186 | static const regex_constants::syntax_option_type JavaScript = normal; |
---|
187 | static const regex_constants::syntax_option_type JScript = normal; |
---|
188 | static const regex_constants::syntax_option_type basic = regex_constants::basic; |
---|
189 | static const regex_constants::syntax_option_type extended = regex_constants::extended; |
---|
190 | static const regex_constants::syntax_option_type awk = regex_constants::awk; |
---|
191 | static const regex_constants::syntax_option_type grep = regex_constants::grep; |
---|
192 | static const regex_constants::syntax_option_type egrep = regex_constants::egrep; |
---|
193 | static const regex_constants::syntax_option_type sed = regex_constants::sed; |
---|
194 | static const regex_constants::syntax_option_type perl = regex_constants::perl; |
---|
195 | static const regex_constants::syntax_option_type literal = regex_constants::literal; |
---|
196 | // modifiers specific to perl expressions: |
---|
197 | static const regex_constants::syntax_option_type no_mod_m = regex_constants::no_mod_m; |
---|
198 | static const regex_constants::syntax_option_type no_mod_s = regex_constants::no_mod_s; |
---|
199 | static const regex_constants::syntax_option_type mod_s = regex_constants::mod_s; |
---|
200 | static const regex_constants::syntax_option_type mod_x = regex_constants::mod_x; |
---|
201 | // modifiers specific to POSIX basic expressions: |
---|
202 | static const regex_constants::syntax_option_type bk_plus_qm = regex_constants::bk_plus_qm; |
---|
203 | static const regex_constants::syntax_option_type bk_vbar = regex_constants::bk_vbar |
---|
204 | static const regex_constants::syntax_option_type no_char_classes = regex_constants::no_char_classes |
---|
205 | static const regex_constants::syntax_option_type no_intervals = regex_constants::no_intervals |
---|
206 | // common modifiers: |
---|
207 | static const regex_constants::syntax_option_type nosubs = regex_constants::nosubs; |
---|
208 | static const regex_constants::syntax_option_type optimize = regex_constants::optimize; |
---|
209 | static const regex_constants::syntax_option_type collate = regex_constants::collate; |
---|
210 | static const regex_constants::syntax_option_type newline_alt = regex_constants::newline_alt; |
---|
211 | </pre> |
---|
212 | <p>The static constant members are provided as synonyms for the constants declared |
---|
213 | in namespace <code>boost::regex_constants</code>; for each constant of type <code><A href="syntax_option_type.html"> |
---|
214 | syntax_option_type</A></code> declared in namespace <code>boost::regex_constants</code> |
---|
215 | then a constant with the same name, type and value is declared within the scope |
---|
216 | of <code>basic_regex</code>.</p> |
---|
217 | <h4>basic_regex constructors</h4> |
---|
218 | <pre><A name=c1> basic_regex(); |
---|
219 | </pre> |
---|
220 | <P><b>Effects:</b> Constructs an object of class <code>basic_regex</code>. The |
---|
221 | postconditions of this function are indicated in the table:</P> |
---|
222 | <div align="center"> |
---|
223 | <center> |
---|
224 | <table id="Table2" cellspacing="1" cellpadding="7" width="624" border="1"> |
---|
225 | <tbody> |
---|
226 | <tr> |
---|
227 | <td valign="top" width="50%"> |
---|
228 | <p><b>Element</b></p> |
---|
229 | </td> |
---|
230 | <td valign="top" width="50%"> |
---|
231 | <p><b>Value</b></p> |
---|
232 | </td> |
---|
233 | </tr> |
---|
234 | <tr> |
---|
235 | <td valign="top" width="50%"> |
---|
236 | <p>empty()</p> |
---|
237 | </td> |
---|
238 | <td valign="top" width="50%"> |
---|
239 | <p>true</p> |
---|
240 | </td> |
---|
241 | </tr> |
---|
242 | <tr> |
---|
243 | <td valign="top" width="50%"> |
---|
244 | <p>size()</p> |
---|
245 | </td> |
---|
246 | <td valign="top" width="50%"> |
---|
247 | <p>0</p> |
---|
248 | </td> |
---|
249 | </tr> |
---|
250 | <tr> |
---|
251 | <td valign="top" width="50%"> |
---|
252 | <p>str()</p> |
---|
253 | </td> |
---|
254 | <td valign="top" width="50%"> |
---|
255 | <p>basic_string<charT>()</p> |
---|
256 | </td> |
---|
257 | </tr> |
---|
258 | </tbody> |
---|
259 | </table> |
---|
260 | </center> |
---|
261 | </div> |
---|
262 | <pre><A name=c2><BR> basic_regex(const charT* p, flag_type f = regex_constants::normal); |
---|
263 | |
---|
264 | </pre> |
---|
265 | <P><b>Requires:</b> <i>p</i> shall not be a null pointer.</P> |
---|
266 | <p><b>Throws:</b> <code>bad_expression</code> if <i>p</i> is not a valid regular |
---|
267 | expression.</p> |
---|
268 | <p><b>Effects:</b> Constructs an object of class <code>basic_regex</code>; the |
---|
269 | object's internal finite state machine is constructed from the regular |
---|
270 | expression contained in the null-terminated string <i>p</i>, and interpreted |
---|
271 | according to the <a href="syntax_option_type.html">option flags</a> specified |
---|
272 | in <i>f</i>. The postconditions of this function are indicated in the table:</p> |
---|
273 | <div align="center"> |
---|
274 | <center> |
---|
275 | <table id="Table3" cellspacing="1" cellpadding="7" width="624" border="1"> |
---|
276 | <tbody> |
---|
277 | <tr> |
---|
278 | <td valign="top" width="50%"> |
---|
279 | <p><b>Element</b></p> |
---|
280 | </td> |
---|
281 | <td valign="top" width="50%"> |
---|
282 | <p><b>Value</b></p> |
---|
283 | </td> |
---|
284 | </tr> |
---|
285 | <tr> |
---|
286 | <td valign="top" width="50%"> |
---|
287 | <p>empty()</p> |
---|
288 | </td> |
---|
289 | <td valign="top" width="50%"> |
---|
290 | <p>false</p> |
---|
291 | </td> |
---|
292 | </tr> |
---|
293 | <tr> |
---|
294 | <td valign="top" width="50%"> |
---|
295 | <p>size()</p> |
---|
296 | </td> |
---|
297 | <td valign="top" width="50%"> |
---|
298 | <p>char_traits<charT>::length(p)</p> |
---|
299 | </td> |
---|
300 | </tr> |
---|
301 | <tr> |
---|
302 | <td valign="top" width="50%"> |
---|
303 | <p>str()</p> |
---|
304 | </td> |
---|
305 | <td valign="top" width="50%"> |
---|
306 | <p>basic_string<charT>(p)</p> |
---|
307 | </td> |
---|
308 | </tr> |
---|
309 | <tr> |
---|
310 | <td valign="top" width="50%"> |
---|
311 | <p>flags()</p> |
---|
312 | </td> |
---|
313 | <td valign="top" width="50%"> |
---|
314 | <p>f</p> |
---|
315 | </td> |
---|
316 | </tr> |
---|
317 | <tr> |
---|
318 | <td valign="top" width="50%"> |
---|
319 | <p>mark_count()</p> |
---|
320 | </td> |
---|
321 | <td valign="top" width="50%"> |
---|
322 | <p>The number of marked sub-expressions within the expression.</p> |
---|
323 | </td> |
---|
324 | </tr> |
---|
325 | </tbody> |
---|
326 | </table> |
---|
327 | </center> |
---|
328 | </div> |
---|
329 | <pre> |
---|
330 | |
---|
331 | </pre> |
---|
332 | <PRE><A name=c3></A>basic_regex(const charT* p1, const charT* p2, flag_type f = regex_constants::normal);</PRE> |
---|
333 | <p><b>Requires:</b> <i>p1</i> and <i>p2</i> are not null pointers, <code>p1 < p2</code>.</p> |
---|
334 | <p><b>Throws:</b> <code>bad_expression</code> if [p1,p2) is not a valid regular |
---|
335 | expression.</p> |
---|
336 | <p><b>Effects:</b> Constructs an object of class <code>basic_regex</code>; the |
---|
337 | object's internal finite state machine is constructed from the regular |
---|
338 | expression contained in the sequence of characters [p1,p2), and interpreted |
---|
339 | according the <a href="syntax_option_type.html">option flags</a> specified in <i>f</i>. |
---|
340 | The postconditions of this function are indicated in the table:</p> |
---|
341 | <div align="center"> |
---|
342 | <center> |
---|
343 | <table id="Table4" cellspacing="1" cellpadding="7" width="624" border="1"> |
---|
344 | <tbody> |
---|
345 | <tr> |
---|
346 | <td valign="top" width="50%"> |
---|
347 | <p><b>Element</b></p> |
---|
348 | </td> |
---|
349 | <td valign="top" width="50%"> |
---|
350 | <p><b>Value</b></p> |
---|
351 | </td> |
---|
352 | </tr> |
---|
353 | <tr> |
---|
354 | <td valign="top" width="50%"> |
---|
355 | <p>empty()</p> |
---|
356 | </td> |
---|
357 | <td valign="top" width="50%"> |
---|
358 | <p>false</p> |
---|
359 | </td> |
---|
360 | </tr> |
---|
361 | <tr> |
---|
362 | <td valign="top" width="50%"> |
---|
363 | <p>size()</p> |
---|
364 | </td> |
---|
365 | <td valign="top" width="50%"> |
---|
366 | <p>std::distance(p1,p2)</p> |
---|
367 | </td> |
---|
368 | </tr> |
---|
369 | <tr> |
---|
370 | <td valign="top" width="50%"> |
---|
371 | <p>str()</p> |
---|
372 | </td> |
---|
373 | <td valign="top" width="50%"> |
---|
374 | <p>basic_string<charT>(p1,p2)</p> |
---|
375 | </td> |
---|
376 | </tr> |
---|
377 | <tr> |
---|
378 | <td valign="top" width="50%"> |
---|
379 | <p>flags()</p> |
---|
380 | </td> |
---|
381 | <td valign="top" width="50%"> |
---|
382 | <p>f</p> |
---|
383 | </td> |
---|
384 | </tr> |
---|
385 | <tr> |
---|
386 | <td valign="top" width="50%"> |
---|
387 | <p>mark_count()</p> |
---|
388 | </td> |
---|
389 | <td valign="top" width="50%"> |
---|
390 | <p>The number of marked sub-expressions within the expression.</p> |
---|
391 | </td> |
---|
392 | </tr> |
---|
393 | </tbody> |
---|
394 | </table> |
---|
395 | </center> |
---|
396 | </div> |
---|
397 | <pre> |
---|
398 | |
---|
399 | </pre> |
---|
400 | <pre><A name=c4></A>basic_regex(const charT* p, size_type len, flag_type f); |
---|
401 | </pre> |
---|
402 | <p><b>Requires:</b> <i>p</i> shall not be a null pointer, <code>len < max_size()</code>.</p> |
---|
403 | <p><b>Throws:</b> <code>bad_expression</code> if <i>p</i> is not a valid regular |
---|
404 | expression.</p> |
---|
405 | <p><b>Effects:</b> Constructs an object of class <code>basic_regex</code>; the |
---|
406 | object's internal finite state machine is constructed from the regular |
---|
407 | expression contained in the sequence of characters [p, p+len), and interpreted |
---|
408 | according the <a href="syntax_option_type.html">option flags</a> specified in <i>f</i>. |
---|
409 | The postconditions of this function are indicated in the table:</p> |
---|
410 | <div align="center"> |
---|
411 | <center> |
---|
412 | <table id="Table5" cellspacing="1" cellpadding="7" width="624" border="1"> |
---|
413 | <tbody> |
---|
414 | <tr> |
---|
415 | <td valign="top" width="50%"> |
---|
416 | <p><b>Element</b></p> |
---|
417 | </td> |
---|
418 | <td valign="top" width="50%"> |
---|
419 | <p><b>Value</b></p> |
---|
420 | </td> |
---|
421 | </tr> |
---|
422 | <tr> |
---|
423 | <td valign="top" width="50%"> |
---|
424 | <p>empty()</p> |
---|
425 | </td> |
---|
426 | <td valign="top" width="50%"> |
---|
427 | <p>false</p> |
---|
428 | </td> |
---|
429 | </tr> |
---|
430 | <tr> |
---|
431 | <td valign="top" width="50%"> |
---|
432 | <p>size()</p> |
---|
433 | </td> |
---|
434 | <td valign="top" width="50%"> |
---|
435 | <p>len</p> |
---|
436 | </td> |
---|
437 | </tr> |
---|
438 | <tr> |
---|
439 | <td valign="top" width="50%"> |
---|
440 | <p>str()</p> |
---|
441 | </td> |
---|
442 | <td valign="top" width="50%"> |
---|
443 | <p>basic_string<charT>(p, len)</p> |
---|
444 | </td> |
---|
445 | </tr> |
---|
446 | <tr> |
---|
447 | <td valign="top" width="50%"> |
---|
448 | <p>flags()</p> |
---|
449 | </td> |
---|
450 | <td valign="top" width="50%"> |
---|
451 | <p>f</p> |
---|
452 | </td> |
---|
453 | </tr> |
---|
454 | <tr> |
---|
455 | <td valign="top" width="50%"> |
---|
456 | <p>mark_count()</p> |
---|
457 | </td> |
---|
458 | <td valign="top" width="50%"> |
---|
459 | <p>The number of marked sub-expressions within the expression.</p> |
---|
460 | </td> |
---|
461 | </tr> |
---|
462 | </tbody> |
---|
463 | </table> |
---|
464 | </center> |
---|
465 | </div> |
---|
466 | <pre><A name=c5></A><BR>basic_regex(const basic_regex& e); |
---|
467 | </pre> |
---|
468 | <p><b>Effects:</b> Constructs an object of class <code>basic_regex</code> as a |
---|
469 | copy of the object <i>e</i>. The postconditions of this function are indicated |
---|
470 | in the table:</p> |
---|
471 | <div align="center"> |
---|
472 | <center> |
---|
473 | <table id="Table6" cellspacing="1" cellpadding="7" width="624" border="1"> |
---|
474 | <tbody> |
---|
475 | <tr> |
---|
476 | <td valign="top" width="50%"> |
---|
477 | <p><b>Element</b></p> |
---|
478 | </td> |
---|
479 | <td valign="top" width="50%"> |
---|
480 | <p><b>Value</b></p> |
---|
481 | </td> |
---|
482 | </tr> |
---|
483 | <tr> |
---|
484 | <td valign="top" width="50%"> |
---|
485 | <p>empty()</p> |
---|
486 | </td> |
---|
487 | <td valign="top" width="50%"> |
---|
488 | <p>e.empty()</p> |
---|
489 | </td> |
---|
490 | </tr> |
---|
491 | <tr> |
---|
492 | <td valign="top" width="50%"> |
---|
493 | <p>size()</p> |
---|
494 | </td> |
---|
495 | <td valign="top" width="50%"> |
---|
496 | <p>e.size()</p> |
---|
497 | </td> |
---|
498 | </tr> |
---|
499 | <tr> |
---|
500 | <td valign="top" width="50%"> |
---|
501 | <p>str()</p> |
---|
502 | </td> |
---|
503 | <td valign="top" width="50%"> |
---|
504 | <p>e.str()</p> |
---|
505 | </td> |
---|
506 | </tr> |
---|
507 | <tr> |
---|
508 | <td valign="top" width="50%"> |
---|
509 | <p>flags()</p> |
---|
510 | </td> |
---|
511 | <td valign="top" width="50%"> |
---|
512 | <p>e.flags()</p> |
---|
513 | </td> |
---|
514 | </tr> |
---|
515 | <tr> |
---|
516 | <td valign="top" width="50%"> |
---|
517 | <p>mark_count()</p> |
---|
518 | </td> |
---|
519 | <td valign="top" width="50%"> |
---|
520 | <p>e.mark_count()</p> |
---|
521 | </td> |
---|
522 | </tr> |
---|
523 | </tbody> |
---|
524 | </table> |
---|
525 | </center> |
---|
526 | </div> |
---|
527 | <pre><BR> |
---|
528 | template <class ST, class SA> |
---|
529 | <A name=c6></A>basic_regex(const basic_string<charT, ST, SA>& s, flag_type f = regex_constants::normal); |
---|
530 | </pre> |
---|
531 | <p><b>Throws:</b> <code>bad_expression</code> if <i>s</i> is not a valid regular |
---|
532 | expression.</p> |
---|
533 | <p><b>Effects:</b> Constructs an object of class <code>basic_regex</code>; the |
---|
534 | object's internal finite state machine is constructed from the regular |
---|
535 | expression contained in the string <i>s</i>, and interpreted according to the <a href="syntax_option_type.html"> |
---|
536 | option flags</a> specified in <i>f</i>. The postconditions of this function |
---|
537 | are indicated in the table:</p> |
---|
538 | <div align="center"> |
---|
539 | <center> |
---|
540 | <table id="Table7" cellspacing="1" cellpadding="7" width="624" border="1"> |
---|
541 | <tbody> |
---|
542 | <tr> |
---|
543 | <td valign="top" width="50%"> |
---|
544 | <p><b>Element</b></p> |
---|
545 | </td> |
---|
546 | <td valign="top" width="50%"> |
---|
547 | <p><b>Value</b></p> |
---|
548 | </td> |
---|
549 | </tr> |
---|
550 | <tr> |
---|
551 | <td valign="top" width="50%"> |
---|
552 | <p>empty()</p> |
---|
553 | </td> |
---|
554 | <td valign="top" width="50%"> |
---|
555 | <p>false</p> |
---|
556 | </td> |
---|
557 | </tr> |
---|
558 | <tr> |
---|
559 | <td valign="top" width="50%"> |
---|
560 | <p>size()</p> |
---|
561 | </td> |
---|
562 | <td valign="top" width="50%"> |
---|
563 | <p>s.size()</p> |
---|
564 | </td> |
---|
565 | </tr> |
---|
566 | <tr> |
---|
567 | <td valign="top" width="50%"> |
---|
568 | <p>str()</p> |
---|
569 | </td> |
---|
570 | <td valign="top" width="50%"> |
---|
571 | <p>s</p> |
---|
572 | </td> |
---|
573 | </tr> |
---|
574 | <tr> |
---|
575 | <td valign="top" width="50%"> |
---|
576 | <p>flags()</p> |
---|
577 | </td> |
---|
578 | <td valign="top" width="50%"> |
---|
579 | <p>f</p> |
---|
580 | </td> |
---|
581 | </tr> |
---|
582 | <tr> |
---|
583 | <td valign="top" width="50%"> |
---|
584 | <p>mark_count()</p> |
---|
585 | </td> |
---|
586 | <td valign="top" width="50%"> |
---|
587 | <p>The number of marked sub-expressions within the expression.</p> |
---|
588 | </td> |
---|
589 | </tr> |
---|
590 | </tbody> |
---|
591 | </table> |
---|
592 | </center> |
---|
593 | </div> |
---|
594 | <pre><BR> |
---|
595 | template <class ForwardIterator> |
---|
596 | <A name=c7></A>basic_regex(ForwardIterator first, ForwardIterator last, flag_type f = regex_constants::normal); |
---|
597 | </pre> |
---|
598 | <p><b>Throws:</b> <code>bad_expression</code> if the sequence <i>[first, last)</i> |
---|
599 | is not a valid regular expression.</p> |
---|
600 | <p><b>Effects:</b> Constructs an object of class <code>basic_regex</code>; the |
---|
601 | object's internal finite state machine is constructed from the regular |
---|
602 | expression contained in the sequence of characters [first, last), and |
---|
603 | interpreted according to the <a href="syntax_option_type.html">option flags</a> |
---|
604 | specified in <i>f</i>. The postconditions of this function are indicated in the |
---|
605 | table:</p> |
---|
606 | <div align="center"> |
---|
607 | <center> |
---|
608 | <table id="Table8" cellspacing="1" cellpadding="7" width="624" border="1"> |
---|
609 | <tbody> |
---|
610 | <tr> |
---|
611 | <td valign="top" width="50%"> |
---|
612 | <p><b>Element</b></p> |
---|
613 | </td> |
---|
614 | <td valign="top" width="50%"> |
---|
615 | <p><b>Value</b></p> |
---|
616 | </td> |
---|
617 | </tr> |
---|
618 | <tr> |
---|
619 | <td valign="top" width="50%"> |
---|
620 | <p>empty()</p> |
---|
621 | </td> |
---|
622 | <td valign="top" width="50%"> |
---|
623 | <p>false</p> |
---|
624 | </td> |
---|
625 | </tr> |
---|
626 | <tr> |
---|
627 | <td valign="top" width="50%"> |
---|
628 | <p>size()</p> |
---|
629 | </td> |
---|
630 | <td valign="top" width="50%"> |
---|
631 | <p>distance(first,last)</p> |
---|
632 | </td> |
---|
633 | </tr> |
---|
634 | <tr> |
---|
635 | <td valign="top" width="50%"> |
---|
636 | <p>str()</p> |
---|
637 | </td> |
---|
638 | <td valign="top" width="50%"> |
---|
639 | <p>basic_string<charT>(first,last)</p> |
---|
640 | </td> |
---|
641 | </tr> |
---|
642 | <tr> |
---|
643 | <td valign="top" width="50%"> |
---|
644 | <p>flags()</p> |
---|
645 | </td> |
---|
646 | <td valign="top" width="50%"> |
---|
647 | <p>f</p> |
---|
648 | </td> |
---|
649 | </tr> |
---|
650 | <tr> |
---|
651 | <td valign="top" width="50%"> |
---|
652 | <p>mark_count()</p> |
---|
653 | </td> |
---|
654 | <td valign="top" width="50%"> |
---|
655 | <p>The number of marked sub-expressions within the expression.</p> |
---|
656 | </td> |
---|
657 | </tr> |
---|
658 | </tbody> |
---|
659 | </table> |
---|
660 | </center> |
---|
661 | </div> |
---|
662 | <pre><A name=o1></A> |
---|
663 | basic_regex& operator=(const basic_regex& e); |
---|
664 | </pre> |
---|
665 | <p><b>Effects:</b> Returns the result of <code>assign(e.str(), e.flags())</code>.</p> |
---|
666 | <pre><A name=o2></A>basic_regex& operator=(const charT* ptr); |
---|
667 | </pre> |
---|
668 | <p><b>Requires:</b> <i>p</i> shall not be a null pointer.</p> |
---|
669 | <p><b>Effects:</b> Returns the result of <code>assign(ptr)</code>.</p> |
---|
670 | <pre><A name=o3></A> |
---|
671 | template <class ST, class SA> |
---|
672 | basic_regex& operator=(const basic_string<charT, ST, SA>& p); |
---|
673 | </pre> |
---|
674 | <p><b>Effects:</b> Returns the result of <code>assign(p)</code>.</p> |
---|
675 | |
---|
676 | <h4>basic_regex iterators</h4> |
---|
677 | <pre><A name=m1> |
---|
678 | const_iterator begin() const; |
---|
679 | </pre> |
---|
680 | <p><b>Effects:</b> Returns a starting iterator to a sequence of characters |
---|
681 | representing the regular expression.</p> |
---|
682 | <pre><A name=m2> |
---|
683 | const_iterator end() const; |
---|
684 | </pre> |
---|
685 | <p><b>Effects:</b> Returns termination iterator to a sequence of characters |
---|
686 | representing the regular expression.</p> |
---|
687 | <h4>basic_regex capacity</h4> |
---|
688 | <pre><A name=m3> |
---|
689 | size_type size() const; |
---|
690 | </pre> |
---|
691 | <p><b>Effects:</b> Returns the length of the sequence of characters representing |
---|
692 | the regular expression.</p> |
---|
693 | <pre><A name=m4> |
---|
694 | size_type max_size() const; |
---|
695 | </pre> |
---|
696 | <p><b>Effects:</b> Returns the maximum length of the sequence of characters |
---|
697 | representing the regular expression.</p> |
---|
698 | <pre><A name=m5></A> |
---|
699 | bool empty() const; |
---|
700 | </pre> |
---|
701 | <p><b>Effects:</b> Returns <b>true</b> if the object does not contain a valid |
---|
702 | regular expression, otherwise <b>false</b>.</p> |
---|
703 | <pre><A name=m6></A>unsigned mark_count() const; |
---|
704 | </pre> |
---|
705 | <p><b>Effects:</b> Returns the number of marked sub-expressions within the regular |
---|
706 | expresion.</p> |
---|
707 | <h4>basic_regex assign</h4> |
---|
708 | <pre><A name=a1> |
---|
709 | basic_regex& assign(const basic_regex& that); |
---|
710 | </pre> |
---|
711 | <p><b>Effects:</b> Returns <code>assign(that.str(), that.flags())</code>.</p> |
---|
712 | <pre><A name=a2></A> |
---|
713 | basic_regex& assign(const charT* ptr, flag_type f = regex_constants::normal); |
---|
714 | </pre> |
---|
715 | <p><b>Effects:</b> Returns <code>assign(string_type(ptr), f)</code>.</p> |
---|
716 | <PRE><A name=a3></A><A name=a3></A>basic_regex& assign(const charT* ptr, unsigned int len, flag_type f);</PRE> |
---|
717 | <P><B>Effects:</B> Returns <CODE>assign(string_type(ptr, len), f)</CODE>.</P> |
---|
718 | <PRE><A name=a4></A>template <class string_traits, class A> |
---|
719 | <A name=a6></A>basic_regex& assign(const basic_string<charT, string_traits, A>& s, |
---|
720 | flag_type f = regex_constants::normal); |
---|
721 | </PRE> |
---|
722 | <p><b>Throws:</b> <code>bad_expression</code> if <i>s</i> is not a valid regular |
---|
723 | expression.</p> |
---|
724 | <p><b>Returns:</b> <code>*this</code>.</p> |
---|
725 | <p><b>Effects:</b> Assigns the regular expression contained in the string <i>s</i>, |
---|
726 | interpreted according the <a href="syntax_option_type.html">option flags</a> specified |
---|
727 | in <i>f</i>. The postconditions of this function are indicated in the table:</p> |
---|
728 | <div align="center"> |
---|
729 | <center> |
---|
730 | <table id="Table9" cellspacing="1" cellpadding="7" width="624" border="1"> |
---|
731 | <tbody> |
---|
732 | <tr> |
---|
733 | <td valign="top" width="50%"> |
---|
734 | <p><b>Element</b></p> |
---|
735 | </td> |
---|
736 | <td valign="top" width="50%"> |
---|
737 | <p><b>Value</b></p> |
---|
738 | </td> |
---|
739 | </tr> |
---|
740 | <tr> |
---|
741 | <td valign="top" width="50%"> |
---|
742 | <p>empty()</p> |
---|
743 | </td> |
---|
744 | <td valign="top" width="50%"> |
---|
745 | <p>false</p> |
---|
746 | </td> |
---|
747 | </tr> |
---|
748 | <tr> |
---|
749 | <td valign="top" width="50%"> |
---|
750 | <p>size()</p> |
---|
751 | </td> |
---|
752 | <td valign="top" width="50%"> |
---|
753 | <p>s.size()</p> |
---|
754 | </td> |
---|
755 | </tr> |
---|
756 | <tr> |
---|
757 | <td valign="top" width="50%"> |
---|
758 | <p>str()</p> |
---|
759 | </td> |
---|
760 | <td valign="top" width="50%"> |
---|
761 | <p>s</p> |
---|
762 | </td> |
---|
763 | </tr> |
---|
764 | <tr> |
---|
765 | <td valign="top" width="50%"> |
---|
766 | <p>flags()</p> |
---|
767 | </td> |
---|
768 | <td valign="top" width="50%"> |
---|
769 | <p>f</p> |
---|
770 | </td> |
---|
771 | </tr> |
---|
772 | <tr> |
---|
773 | <td valign="top" width="50%"> |
---|
774 | <p>mark_count()</p> |
---|
775 | </td> |
---|
776 | <td valign="top" width="50%"> |
---|
777 | <p>The number of marked sub-expressions within the expression.</p> |
---|
778 | </td> |
---|
779 | </tr> |
---|
780 | </tbody> |
---|
781 | </table> |
---|
782 | </center> |
---|
783 | </div> |
---|
784 | <pre> |
---|
785 | |
---|
786 | </pre> |
---|
787 | <pre><A name=a5></A>template <class InputIterator> |
---|
788 | basic_regex& assign(InputIterator first, InputIterator last, |
---|
789 | flag_type f = regex_constants::normal); |
---|
790 | </pre> |
---|
791 | <p><b>Requires:</b> The type InputIterator corresponds to the Input Iterator |
---|
792 | requirements (24.1.1).</p> |
---|
793 | <p><b>Effects:</b> Returns <code>assign(string_type(first, last), f)</code>.</p> |
---|
794 | <h4>basic_regex constant operations</h4> |
---|
795 | <pre><A name=m7></A><A name=m8></A>flag_type flags() const; |
---|
796 | </pre> |
---|
797 | <p><b>Effects:</b> Returns a copy of the regular expression syntax flags that were |
---|
798 | passed to the object's constructor, or the last call to <code>assign.</code></p> |
---|
799 | <pre><A name=m9></A>basic_string<charT> str() const; |
---|
800 | </pre> |
---|
801 | <p><b>Effects:</b> Returns a copy of the character sequence passed to the object's |
---|
802 | constructor, or the last call to <code>assign.</code></p> |
---|
803 | <pre><A name=m10></A>int compare(basic_regex& e)const; |
---|
804 | </pre> |
---|
805 | <p><b>Effects:</b> If <code>flags() == e.flags()</code> then returns <code>str().compare(e.str())</code>, |
---|
806 | otherwise returns <code>flags() - e.flags()</code>.</p> |
---|
807 | <h4>basic_regex locale</h4> |
---|
808 | <pre><A name=m11></A>locale_type imbue(locale_type l); |
---|
809 | </pre> |
---|
810 | <p><b>Effects:</b> Returns the result of <code>traits_inst.imbue(l)</code> where <code> |
---|
811 | traits_inst</code> is a (default initialized) instance of the template |
---|
812 | parameter <code>traits</code> stored within the object. Calls to imbue |
---|
813 | invalidate any currently contained regular expression.</p> |
---|
814 | <p><b>Postcondition:</b> <code>empty() == true</code>.</p> |
---|
815 | <pre><A name=m12></A> |
---|
816 | locale_type getloc() const; |
---|
817 | </pre> |
---|
818 | <p><b>Effects:</b> Returns the result of <code>traits_inst.getloc()</code> where <code> |
---|
819 | traits_inst</code> is a (default initialized) instance of the template |
---|
820 | parameter <code>traits</code> stored within the object.</p> |
---|
821 | <h4>basic_regex swap</h4> |
---|
822 | <pre><A name=m13> |
---|
823 | void swap(basic_regex& e) throw(); |
---|
824 | </pre> |
---|
825 | <p><b>Effects:</b> Swaps the contents of the two regular expressions.</p> |
---|
826 | <p><b>Postcondition:</b> <code>*this</code> contains the characters that were in <i>e</i>, |
---|
827 | <i>e</i> contains the regular expression that was in <code>*this</code>.</p> |
---|
828 | <p><b>Complexity:</b> constant time.</p> |
---|
829 | <h4>basic_regex non-member functions</h4> |
---|
830 | <h5>basic_regex non-member comparison operators </h5> |
---|
831 | <P>Comparisons between basic_regex objects are provided on an experimental basis: |
---|
832 | please note that these are likely to be removed from the standard library |
---|
833 | proposal, so use with care if you are writing portable code.</P> |
---|
834 | <pre><A name=o4></A> |
---|
835 | template <class charT, class traits> |
---|
836 | bool operator == (const basic_regex<charT, traits>& lhs, |
---|
837 | const basic_regex<charT, traits>& rhs); |
---|
838 | </pre> |
---|
839 | <p><b>Effects:</b> Returns <code>lhs.compare(rhs) == 0</code>.</p> |
---|
840 | <pre><A name=o5></A> |
---|
841 | template <class charT, class traits> |
---|
842 | bool operator != (const basic_regex<charT, traits>& lhs, |
---|
843 | const basic_regex<charT, traits>& rhs); |
---|
844 | </pre> |
---|
845 | <p><b>Effects:</b> Returns <code>lhs.compare(rhs) != 0</code>.</p> |
---|
846 | <pre><A name=o7></A> |
---|
847 | template <class charT, class traits> |
---|
848 | bool operator < (const basic_regex<charT, traits>& lhs, |
---|
849 | const basic_regex<charT, traits>& rhs); |
---|
850 | </pre> |
---|
851 | <p><b>Effects:</b> Returns <code>lhs.compare(rhs) < 0</code>.</p> |
---|
852 | <pre><A name=o8></A> |
---|
853 | template <class charT, class traits> |
---|
854 | bool operator <= (const basic_regex<charT, traits>& lhs, |
---|
855 | const basic_regex<charT, traits>& rhs); |
---|
856 | </pre> |
---|
857 | <p><b>Effects:</b> Returns <code>lhs.compare(rhs) <= 0</code>.</p> |
---|
858 | <pre><A name=o9></A> |
---|
859 | template <class charT, class traits> |
---|
860 | bool operator >= (const basic_regex<charT, traits>& lhs, |
---|
861 | const basic_regex<charT, traits>& rhs); |
---|
862 | </pre> |
---|
863 | <p><b>Effects:</b> Returns <code>lhs.compare(rhs) >= 0</code>.</p> |
---|
864 | <pre><A name=o10></A> |
---|
865 | template <class charT, class traits> |
---|
866 | bool operator > (const basic_regex<charT, traits>& lhs, |
---|
867 | const basic_regex<charT, traits>& rhs); |
---|
868 | </pre> |
---|
869 | <p><b>Effects:</b> Returns <code>lhs.compare(rhs) > 0</code>.</p> |
---|
870 | <h5>basic_regex inserter.</h5> |
---|
871 | <P>The basic_regex stream inserter is provided on an experimental basis, and |
---|
872 | outputs the textual representation of the expression to the stream:</P> |
---|
873 | <pre><A name=o11></A> |
---|
874 | template <class charT, class io_traits, class re_traits> |
---|
875 | basic_ostream<charT, io_traits>& |
---|
876 | operator << (basic_ostream<charT, io_traits>& os |
---|
877 | const basic_regex<charT, re_traits>& e); |
---|
878 | </pre> |
---|
879 | <p><b>Effects:</b> Returns (os << e.str()).</p> |
---|
880 | <h5>basic_regex non-member swap</h5> |
---|
881 | <pre><A name=o12></A> |
---|
882 | template <class charT, class traits> |
---|
883 | void swap(basic_regex<charT, traits>& lhs, |
---|
884 | basic_regex<charT, traits>& rhs); |
---|
885 | </pre> |
---|
886 | <p><b>Effects:</b> calls <code>lhs.swap(rhs)</code>.</p> |
---|
887 | <hr> |
---|
888 | <p>Revised 7 Aug |
---|
889 | <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan --> |
---|
890 | 2004 |
---|
891 | <!--webbot bot="Timestamp" endspan i-checksum="39359" --></p> |
---|
892 | <p><i>© Copyright John Maddock 1998- |
---|
893 | <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2004<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p> |
---|
894 | <P><I>Use, modification and distribution are subject to the Boost Software License, |
---|
895 | Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A> |
---|
896 | or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P> |
---|
897 | </body> |
---|
898 | </html> |
---|