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.
15 * VERSION see <boost/version.hpp>
16 * DESCRIPTION: Declares regular expression concepts.
19 #ifndef BOOST_REGEX_CONCEPTS_HPP_INCLUDED
20 #define BOOST_REGEX_CONCEPTS_HPP_INCLUDED
22 #include <boost/concept_archetype.hpp>
23 #include <boost/concept_check.hpp>
24 #include <boost/type_traits/is_enum.hpp>
25 #include <boost/type_traits/is_base_and_derived.hpp>
26 #include <boost/static_assert.hpp>
27 #ifndef BOOST_TEST_TR1_REGEX
28 #include <boost/regex.hpp>
38 // this can be either an integer type, an enum, or a std::bitset,
39 // we use the latter as the architype as it offers the "strictest"
40 // of the possible interfaces:
42 typedef std::bitset<512> bitmask_archetype;
45 // A strict model for the character type interface.
49 // default constructable:
51 // copy constructable / assignable:
52 char_architype(const char_architype&);
53 char_architype& operator=(const char_architype&);
54 // constructable from an integral value:
55 char_architype(unsigned long val);
57 bool operator==(const char_architype&)const;
58 bool operator!=(const char_architype&)const;
59 bool operator<(const char_architype&)const;
60 bool operator<=(const char_architype&)const;
61 bool operator>=(const char_architype&)const;
62 bool operator>(const char_architype&)const;
63 // conversion to integral type:
67 // char_architype can not be used with basic_string:
71 template<> struct char_traits<boost::char_architype>
73 // The intent is that this template is not instantiated,
74 // but this typedef gives us a chance of compilation in
76 typedef boost::char_architype char_type;
80 // Allocator architype:
83 class allocator_architype
87 typedef const T* const_pointer;
89 typedef const T& const_reference;
91 typedef unsigned size_type;
92 typedef int difference_type;
97 typedef allocator_architype<U> other;
100 pointer address(reference r);
101 const_pointer address(const_reference r);
102 pointer allocate(size_type);
103 pointer allocate(size_type, pointer);
104 void deallocate(pointer, size_type);
105 size_type max_size()const;
107 allocator_architype();
108 allocator_architype(const allocator_architype&);
110 template <class Other>
111 allocator_architype(const allocator_architype<Other>&);
113 void construct(pointer, const_reference);
114 void destroy(pointer);
118 bool operator == (const allocator_architype<T>&, const allocator_architype<T>&);
120 bool operator != (const allocator_architype<T>&, const allocator_architype<T>&);
124 // regex_traits_architype:
125 // A strict interpretation of the regular expression traits class requirements.
127 template <class charT>
128 struct regex_traits_architype
131 regex_traits_architype();
132 typedef charT char_type;
133 // typedef std::size_t size_type;
134 typedef std::vector<char_type> string_type;
135 typedef copy_constructible_archetype<assignable_archetype<> > locale_type;
136 typedef bitmask_archetype char_class_type;
138 static std::size_t length(const char_type* ) { return 0; }
140 charT translate(charT ) const { return charT(); }
141 charT translate_nocase(charT ) const { return static_object<charT>::get(); }
143 template <class ForwardIterator>
144 string_type transform(ForwardIterator , ForwardIterator ) const
145 { return static_object<string_type>::get(); }
146 template <class ForwardIterator>
147 string_type transform_primary(ForwardIterator , ForwardIterator ) const
148 { return static_object<string_type>::get(); }
150 template <class ForwardIterator>
151 char_class_type lookup_classname(ForwardIterator , ForwardIterator ) const
152 { return static_object<char_class_type>::get(); }
153 template <class ForwardIterator>
154 string_type lookup_collatename(ForwardIterator , ForwardIterator ) const
155 { return static_object<string_type>::get(); }
157 bool isctype(charT, char_class_type) const
159 int value(charT, int) const
162 locale_type imbue(locale_type l)
164 locale_type getloc()const
165 { return static_object<locale_type>::get(); }
168 // this type is not copyable:
169 regex_traits_architype(const regex_traits_architype&);
170 regex_traits_architype& operator=(const regex_traits_architype&);
174 // alter this to std::tr1, to test a std implementation:
176 #ifndef BOOST_TEST_TR1_REGEX
177 namespace global_regex_namespace = ::boost;
179 namespace global_regex_namespace = ::std::tr1;
182 template <class Bitmask>
183 struct BitmaskConcept
187 function_requires<CopyConstructibleConcept<Bitmask> >();
188 function_requires<AssignableConcept<Bitmask> >();
190 m_mask1 = m_mask2 | m_mask3;
191 m_mask1 = m_mask2 & m_mask3;
192 m_mask1 = m_mask2 ^ m_mask3;
200 Bitmask m_mask1, m_mask2, m_mask3;
203 template <class traits>
204 struct RegexTraitsConcept
206 RegexTraitsConcept();
207 // required typedefs:
208 typedef typename traits::char_type char_type;
209 // typedef typename traits::size_type size_type;
210 typedef typename traits::string_type string_type;
211 typedef typename traits::locale_type locale_type;
212 typedef typename traits::char_class_type char_class_type;
216 //function_requires<UnsignedIntegerConcept<size_type> >();
217 function_requires<RandomAccessContainerConcept<string_type> >();
218 function_requires<DefaultConstructibleConcept<locale_type> >();
219 function_requires<CopyConstructibleConcept<locale_type> >();
220 function_requires<AssignableConcept<locale_type> >();
221 function_requires<BitmaskConcept<char_class_type> >();
223 std::size_t n = traits::length(m_pointer);
224 ignore_unused_variable_warning(n);
226 char_type c = m_ctraits.translate(m_char);
227 ignore_unused_variable_warning(c);
228 c = m_ctraits.translate_nocase(m_char);
230 //string_type::foobar bar;
231 string_type s1 = m_ctraits.transform(m_pointer, m_pointer);
232 ignore_unused_variable_warning(s1);
234 string_type s2 = m_ctraits.transform_primary(m_pointer, m_pointer);
235 ignore_unused_variable_warning(s2);
237 char_class_type cc = m_ctraits.lookup_classname(m_pointer, m_pointer);
238 ignore_unused_variable_warning(cc);
240 string_type s3 = m_ctraits.lookup_collatename(m_pointer, m_pointer);
241 ignore_unused_variable_warning(s3);
243 bool b = m_ctraits.isctype(m_char, cc);
244 ignore_unused_variable_warning(b);
246 int v = m_ctraits.value(m_char, 16);
247 ignore_unused_variable_warning(v);
249 locale_type l(m_ctraits.getloc());
251 ignore_unused_variable_warning(l);
254 const traits m_ctraits;
255 const char_type* m_pointer;
258 RegexTraitsConcept& operator=(RegexTraitsConcept&);
262 // helper class to compute what traits class a regular expression type is using:
264 template <class Regex>
265 struct regex_traits_computer;
267 template <class charT, class traits>
268 struct regex_traits_computer< global_regex_namespace::basic_regex<charT, traits> >
274 // BaseRegexConcept does not test anything dependent on basic_string,
275 // in case our charT does not have an associated char_traits:
277 template <class Regex>
278 struct BaseRegexConcept
280 typedef typename Regex::value_type value_type;
281 //typedef typename Regex::size_type size_type;
282 typedef typename Regex::flag_type flag_type;
283 typedef typename Regex::locale_type locale_type;
284 typedef input_iterator_archetype<value_type> input_iterator_type;
286 // derived test types:
287 typedef const value_type* pointer_type;
288 typedef bidirectional_iterator_archetype<value_type> BidiIterator;
289 typedef global_regex_namespace::sub_match<BidiIterator> sub_match_type;
290 typedef global_regex_namespace::match_results<BidiIterator, allocator_architype<sub_match_type> > match_results_type;
291 typedef global_regex_namespace::match_results<BidiIterator> match_results_default_type;
292 typedef output_iterator_archetype<value_type> OutIterator;
293 typedef typename regex_traits_computer<Regex>::type traits_type;
294 typedef global_regex_namespace::regex_iterator<BidiIterator, value_type, traits_type> regex_iterator_type;
295 typedef global_regex_namespace::regex_token_iterator<BidiIterator, value_type, traits_type> regex_token_iterator_type;
297 void global_constraints()
300 // test non-template components:
302 function_requires<BitmaskConcept<global_regex_namespace::regex_constants::syntax_option_type> >();
303 global_regex_namespace::regex_constants::syntax_option_type opts
304 = global_regex_namespace::regex_constants::icase
305 | global_regex_namespace::regex_constants::nosubs
306 | global_regex_namespace::regex_constants::optimize
307 | global_regex_namespace::regex_constants::collate
308 | global_regex_namespace::regex_constants::ECMAScript
309 | global_regex_namespace::regex_constants::basic
310 | global_regex_namespace::regex_constants::extended
311 | global_regex_namespace::regex_constants::awk
312 | global_regex_namespace::regex_constants::grep
313 | global_regex_namespace::regex_constants::egrep;
314 ignore_unused_variable_warning(opts);
316 function_requires<BitmaskConcept<global_regex_namespace::regex_constants::match_flag_type> >();
317 global_regex_namespace::regex_constants::match_flag_type mopts
318 = global_regex_namespace::regex_constants::match_default
319 | global_regex_namespace::regex_constants::match_not_bol
320 | global_regex_namespace::regex_constants::match_not_eol
321 | global_regex_namespace::regex_constants::match_not_bow
322 | global_regex_namespace::regex_constants::match_not_eow
323 | global_regex_namespace::regex_constants::match_any
324 | global_regex_namespace::regex_constants::match_not_null
325 | global_regex_namespace::regex_constants::match_continuous
326 | global_regex_namespace::regex_constants::match_prev_avail
327 | global_regex_namespace::regex_constants::format_default
328 | global_regex_namespace::regex_constants::format_sed
329 | global_regex_namespace::regex_constants::format_no_copy
330 | global_regex_namespace::regex_constants::format_first_only;
331 ignore_unused_variable_warning(mopts);
333 BOOST_STATIC_ASSERT((::boost::is_enum<global_regex_namespace::regex_constants::error_type>::value));
334 global_regex_namespace::regex_constants::error_type e1 = global_regex_namespace::regex_constants::error_collate;
335 ignore_unused_variable_warning(e1);
336 e1 = global_regex_namespace::regex_constants::error_ctype;
337 ignore_unused_variable_warning(e1);
338 e1 = global_regex_namespace::regex_constants::error_escape;
339 ignore_unused_variable_warning(e1);
340 e1 = global_regex_namespace::regex_constants::error_backref;
341 ignore_unused_variable_warning(e1);
342 e1 = global_regex_namespace::regex_constants::error_brack;
343 ignore_unused_variable_warning(e1);
344 e1 = global_regex_namespace::regex_constants::error_paren;
345 ignore_unused_variable_warning(e1);
346 e1 = global_regex_namespace::regex_constants::error_brace;
347 ignore_unused_variable_warning(e1);
348 e1 = global_regex_namespace::regex_constants::error_badbrace;
349 ignore_unused_variable_warning(e1);
350 e1 = global_regex_namespace::regex_constants::error_range;
351 ignore_unused_variable_warning(e1);
352 e1 = global_regex_namespace::regex_constants::error_space;
353 ignore_unused_variable_warning(e1);
354 e1 = global_regex_namespace::regex_constants::error_badrepeat;
355 ignore_unused_variable_warning(e1);
356 e1 = global_regex_namespace::regex_constants::error_complexity;
357 ignore_unused_variable_warning(e1);
358 e1 = global_regex_namespace::regex_constants::error_stack;
359 ignore_unused_variable_warning(e1);
361 BOOST_STATIC_ASSERT((::boost::is_base_and_derived<std::runtime_error, global_regex_namespace::regex_error>::value ));
362 const global_regex_namespace::regex_error except(e1);
365 typedef typename Regex::value_type regex_value_type;
366 function_requires< RegexTraitsConcept<global_regex_namespace::regex_traits<char> > >();
367 function_requires< BaseRegexConcept<global_regex_namespace::basic_regex<char> > >();
371 global_constraints();
373 BOOST_STATIC_ASSERT((::boost::is_same< flag_type, global_regex_namespace::regex_constants::syntax_option_type>::value));
385 ignore_unused_variable_warning(opts);
387 function_requires<DefaultConstructibleConcept<Regex> >();
388 function_requires<CopyConstructibleConcept<Regex> >();
390 // Regex constructors:
392 ignore_unused_variable_warning(e1);
393 Regex e2(m_pointer, m_flags);
394 ignore_unused_variable_warning(e2);
395 Regex e3(m_pointer, m_size, m_flags);
396 ignore_unused_variable_warning(e3);
398 ignore_unused_variable_warning(e4);
399 Regex e5(in1, in2, m_flags);
400 ignore_unused_variable_warning(e5);
408 e.assign(m_pointer, m_flags);
409 e.assign(m_pointer, m_size, m_flags);
411 e.assign(in1, in2, m_flags);
415 typename Regex::size_type i = ce.mark_count();
416 ignore_unused_variable_warning(i);
417 m_flags = ce.flags();
418 e.imbue(ce.getloc());
421 global_regex_namespace::swap(e, e1);
424 BOOST_STATIC_ASSERT((::boost::is_base_and_derived<std::pair<BidiIterator, BidiIterator>, sub_match_type>::value));
425 typedef typename sub_match_type::value_type sub_value_type;
426 typedef typename sub_match_type::difference_type sub_diff_type;
427 typedef typename sub_match_type::iterator sub_iter_type;
428 BOOST_STATIC_ASSERT((::boost::is_same<sub_value_type, value_type>::value));
429 BOOST_STATIC_ASSERT((::boost::is_same<sub_iter_type, BidiIterator>::value));
430 bool b = m_sub.matched;
431 ignore_unused_variable_warning(b);
432 BidiIterator bi = m_sub.first;
433 ignore_unused_variable_warning(bi);
435 ignore_unused_variable_warning(bi);
436 sub_diff_type diff = m_sub.length();
437 ignore_unused_variable_warning(diff);
438 // match_results tests:
439 typedef typename match_results_type::value_type mr_value_type;
440 typedef typename match_results_type::const_reference mr_const_reference;
441 typedef typename match_results_type::reference mr_reference;
442 typedef typename match_results_type::const_iterator mr_const_iterator;
443 typedef typename match_results_type::iterator mr_iterator;
444 typedef typename match_results_type::difference_type mr_difference_type;
445 typedef typename match_results_type::size_type mr_size_type;
446 typedef typename match_results_type::allocator_type mr_allocator_type;
447 typedef typename match_results_type::char_type mr_char_type;
448 typedef typename match_results_type::string_type mr_string_type;
450 match_results_type m1;
451 mr_allocator_type at;
452 match_results_type m2(at);
453 match_results_type m3(m1);
458 mr_size_type mrs = m_cresults.size();
459 ignore_unused_variable_warning(mrs);
460 mrs = m_cresults.max_size();
461 ignore_unused_variable_warning(mrs);
462 b = m_cresults.empty();
463 ignore_unused_variable_warning(b);
464 mr_difference_type mrd = m_cresults.length();
465 ignore_unused_variable_warning(mrd);
466 mrd = m_cresults.length(ival);
467 ignore_unused_variable_warning(mrd);
468 mrd = m_cresults.position();
469 ignore_unused_variable_warning(mrd);
470 mrd = m_cresults.position(mrs);
471 ignore_unused_variable_warning(mrd);
473 mr_const_reference mrcr = m_cresults[ival];
474 ignore_unused_variable_warning(mrcr);
475 mr_const_reference mrcr2 = m_cresults.prefix();
476 ignore_unused_variable_warning(mrcr2);
477 mr_const_reference mrcr3 = m_cresults.suffix();
478 ignore_unused_variable_warning(mrcr3);
479 mr_const_iterator mrci = m_cresults.begin();
480 ignore_unused_variable_warning(mrci);
481 mrci = m_cresults.end();
482 ignore_unused_variable_warning(mrci);
484 mr_allocator_type at2 = m_cresults.get_allocator();
485 m_results.swap(m_results);
486 global_regex_namespace::swap(m_results, m_results);
489 b = global_regex_namespace::regex_match(m_in, m_in, m_results, e);
490 ignore_unused_variable_warning(b);
491 b = global_regex_namespace::regex_match(m_in, m_in, m_results, e, m_mft);
492 ignore_unused_variable_warning(b);
493 b = global_regex_namespace::regex_match(m_in, m_in, e);
494 ignore_unused_variable_warning(b);
495 b = global_regex_namespace::regex_match(m_in, m_in, e, m_mft);
496 ignore_unused_variable_warning(b);
497 b = global_regex_namespace::regex_match(m_pointer, m_pmatch, e);
498 ignore_unused_variable_warning(b);
499 b = global_regex_namespace::regex_match(m_pointer, m_pmatch, e, m_mft);
500 ignore_unused_variable_warning(b);
501 b = global_regex_namespace::regex_match(m_pointer, e);
502 ignore_unused_variable_warning(b);
503 b = global_regex_namespace::regex_match(m_pointer, e, m_mft);
504 ignore_unused_variable_warning(b);
506 b = global_regex_namespace::regex_search(m_in, m_in, m_results, e);
507 ignore_unused_variable_warning(b);
508 b = global_regex_namespace::regex_search(m_in, m_in, m_results, e, m_mft);
509 ignore_unused_variable_warning(b);
510 b = global_regex_namespace::regex_search(m_in, m_in, e);
511 ignore_unused_variable_warning(b);
512 b = global_regex_namespace::regex_search(m_in, m_in, e, m_mft);
513 ignore_unused_variable_warning(b);
514 b = global_regex_namespace::regex_search(m_pointer, m_pmatch, e);
515 ignore_unused_variable_warning(b);
516 b = global_regex_namespace::regex_search(m_pointer, m_pmatch, e, m_mft);
517 ignore_unused_variable_warning(b);
518 b = global_regex_namespace::regex_search(m_pointer, e);
519 ignore_unused_variable_warning(b);
520 b = global_regex_namespace::regex_search(m_pointer, e, m_mft);
521 ignore_unused_variable_warning(b);
524 typedef typename regex_iterator_type::regex_type rit_regex_type;
525 typedef typename regex_iterator_type::value_type rit_value_type;
526 typedef typename regex_iterator_type::difference_type rit_difference_type;
527 typedef typename regex_iterator_type::pointer rit_pointer;
528 typedef typename regex_iterator_type::reference rit_reference;
529 typedef typename regex_iterator_type::iterator_category rit_iterator_category;
530 BOOST_STATIC_ASSERT((::boost::is_same<rit_regex_type, Regex>::value));
531 BOOST_STATIC_ASSERT((::boost::is_same<rit_value_type, match_results_default_type>::value));
532 BOOST_STATIC_ASSERT((::boost::is_same<rit_difference_type, std::ptrdiff_t>::value));
533 BOOST_STATIC_ASSERT((::boost::is_same<rit_pointer, const match_results_default_type*>::value));
534 BOOST_STATIC_ASSERT((::boost::is_same<rit_reference, const match_results_default_type&>::value));
535 BOOST_STATIC_ASSERT((::boost::is_convertible<rit_iterator_category*, std::forward_iterator_tag*>::value));
536 // this takes care of most of the checks needed:
537 function_requires<ForwardIteratorConcept<regex_iterator_type> >();
538 regex_iterator_type iter1(m_in, m_in, e);
539 ignore_unused_variable_warning(iter1);
540 regex_iterator_type iter2(m_in, m_in, e, m_mft);
541 ignore_unused_variable_warning(iter2);
543 // regex_token_iterator:
544 typedef typename regex_token_iterator_type::regex_type rtit_regex_type;
545 typedef typename regex_token_iterator_type::value_type rtit_value_type;
546 typedef typename regex_token_iterator_type::difference_type rtit_difference_type;
547 typedef typename regex_token_iterator_type::pointer rtit_pointer;
548 typedef typename regex_token_iterator_type::reference rtit_reference;
549 typedef typename regex_token_iterator_type::iterator_category rtit_iterator_category;
550 BOOST_STATIC_ASSERT((::boost::is_same<rtit_regex_type, Regex>::value));
551 BOOST_STATIC_ASSERT((::boost::is_same<rtit_value_type, sub_match_type>::value));
552 BOOST_STATIC_ASSERT((::boost::is_same<rtit_difference_type, std::ptrdiff_t>::value));
553 BOOST_STATIC_ASSERT((::boost::is_same<rtit_pointer, const sub_match_type*>::value));
554 BOOST_STATIC_ASSERT((::boost::is_same<rtit_reference, const sub_match_type&>::value));
555 BOOST_STATIC_ASSERT((::boost::is_convertible<rtit_iterator_category*, std::forward_iterator_tag*>::value));
556 // this takes care of most of the checks needed:
557 function_requires<ForwardIteratorConcept<regex_token_iterator_type> >();
558 regex_token_iterator_type ti1(m_in, m_in, e);
559 ignore_unused_variable_warning(ti1);
560 regex_token_iterator_type ti2(m_in, m_in, e, 0);
561 ignore_unused_variable_warning(ti2);
562 regex_token_iterator_type ti3(m_in, m_in, e, 0, m_mft);
563 ignore_unused_variable_warning(ti3);
564 std::vector<int> subs;
565 regex_token_iterator_type ti4(m_in, m_in, e, subs);
566 ignore_unused_variable_warning(ti4);
567 regex_token_iterator_type ti5(m_in, m_in, e, subs, m_mft);
568 ignore_unused_variable_warning(ti5);
569 static const int i_array[3] = { 1, 2, 3, };
570 regex_token_iterator_type ti6(m_in, m_in, e, i_array);
571 ignore_unused_variable_warning(ti6);
572 regex_token_iterator_type ti7(m_in, m_in, e, i_array, m_mft);
573 ignore_unused_variable_warning(ti7);
576 pointer_type m_pointer;
579 input_iterator_type in1, in2;
580 const sub_match_type m_sub;
581 const value_type m_char;
582 match_results_type m_results;
583 const match_results_type m_cresults;
586 global_regex_namespace::regex_constants::match_flag_type m_mft;
587 global_regex_namespace::match_results<
589 allocator_architype<global_regex_namespace::sub_match<pointer_type> > >
593 BaseRegexConcept(const BaseRegexConcept&);
594 BaseRegexConcept& operator=(const BaseRegexConcept&);
599 // Test every interface in the std:
601 template <class Regex>
604 typedef typename Regex::value_type value_type;
605 //typedef typename Regex::size_type size_type;
606 typedef typename Regex::flag_type flag_type;
607 typedef typename Regex::locale_type locale_type;
609 // derived test types:
610 typedef const value_type* pointer_type;
611 typedef std::basic_string<value_type> string_type;
612 typedef boost::bidirectional_iterator_archetype<value_type> BidiIterator;
613 typedef global_regex_namespace::sub_match<BidiIterator> sub_match_type;
614 typedef global_regex_namespace::match_results<BidiIterator, allocator_architype<sub_match_type> > match_results_type;
615 typedef output_iterator_archetype<value_type> OutIterator;
620 function_requires<BaseRegexConcept<Regex> >();
621 // string based construct:
623 ignore_unused_variable_warning(e1);
624 Regex e2(m_string, m_flags);
625 ignore_unused_variable_warning(e2);
631 e.assign(m_string, m_flags);
634 string_type s(m_sub);
635 ignore_unused_variable_warning(s);
637 ignore_unused_variable_warning(s);
638 int i = m_sub.compare(m_string);
639 ignore_unused_variable_warning(i);
641 int i2 = m_sub.compare(m_sub);
642 ignore_unused_variable_warning(i2);
643 i2 = m_sub.compare(m_pointer);
644 ignore_unused_variable_warning(i2);
646 bool b = m_sub == m_sub;
647 ignore_unused_variable_warning(b);
649 ignore_unused_variable_warning(b);
651 ignore_unused_variable_warning(b);
653 ignore_unused_variable_warning(b);
655 ignore_unused_variable_warning(b);
657 ignore_unused_variable_warning(b);
659 b = m_sub == m_pointer;
660 ignore_unused_variable_warning(b);
661 b = m_sub != m_pointer;
662 ignore_unused_variable_warning(b);
663 b = m_sub <= m_pointer;
664 ignore_unused_variable_warning(b);
665 b = m_sub <= m_pointer;
666 ignore_unused_variable_warning(b);
667 b = m_sub > m_pointer;
668 ignore_unused_variable_warning(b);
669 b = m_sub >= m_pointer;
670 ignore_unused_variable_warning(b);
672 b = m_pointer == m_sub;
673 ignore_unused_variable_warning(b);
674 b = m_pointer != m_sub;
675 ignore_unused_variable_warning(b);
676 b = m_pointer <= m_sub;
677 ignore_unused_variable_warning(b);
678 b = m_pointer <= m_sub;
679 ignore_unused_variable_warning(b);
680 b = m_pointer > m_sub;
681 ignore_unused_variable_warning(b);
682 b = m_pointer >= m_sub;
683 ignore_unused_variable_warning(b);
686 ignore_unused_variable_warning(b);
688 ignore_unused_variable_warning(b);
690 ignore_unused_variable_warning(b);
692 ignore_unused_variable_warning(b);
694 ignore_unused_variable_warning(b);
696 ignore_unused_variable_warning(b);
699 ignore_unused_variable_warning(b);
701 ignore_unused_variable_warning(b);
703 ignore_unused_variable_warning(b);
705 ignore_unused_variable_warning(b);
707 ignore_unused_variable_warning(b);
709 ignore_unused_variable_warning(b);
711 b = m_sub == m_string;
712 ignore_unused_variable_warning(b);
713 b = m_sub != m_string;
714 ignore_unused_variable_warning(b);
715 b = m_sub <= m_string;
716 ignore_unused_variable_warning(b);
717 b = m_sub <= m_string;
718 ignore_unused_variable_warning(b);
719 b = m_sub > m_string;
720 ignore_unused_variable_warning(b);
721 b = m_sub >= m_string;
722 ignore_unused_variable_warning(b);
724 b = m_string == m_sub;
725 ignore_unused_variable_warning(b);
726 b = m_string != m_sub;
727 ignore_unused_variable_warning(b);
728 b = m_string <= m_sub;
729 ignore_unused_variable_warning(b);
730 b = m_string <= m_sub;
731 ignore_unused_variable_warning(b);
732 b = m_string > m_sub;
733 ignore_unused_variable_warning(b);
734 b = m_string >= m_sub;
735 ignore_unused_variable_warning(b);
738 m_string = m_results.str();
739 ignore_unused_variable_warning(m_string);
740 m_string = m_results.str(0);
741 ignore_unused_variable_warning(m_string);
742 m_out = m_cresults.format(m_out, m_string);
743 m_out = m_cresults.format(m_out, m_string, m_mft);
744 m_string = m_cresults.format(m_string);
745 ignore_unused_variable_warning(m_string);
746 m_string = m_cresults.format(m_string, m_mft);
747 ignore_unused_variable_warning(m_string);
750 b = global_regex_namespace::regex_match(m_string, m_smatch, e);
751 ignore_unused_variable_warning(b);
752 b = global_regex_namespace::regex_match(m_string, m_smatch, e, m_mft);
753 ignore_unused_variable_warning(b);
754 b = global_regex_namespace::regex_match(m_string, e);
755 ignore_unused_variable_warning(b);
756 b = global_regex_namespace::regex_match(m_string, e, m_mft);
757 ignore_unused_variable_warning(b);
760 b = global_regex_namespace::regex_search(m_string, m_smatch, e);
761 ignore_unused_variable_warning(b);
762 b = global_regex_namespace::regex_search(m_string, m_smatch, e, m_mft);
763 ignore_unused_variable_warning(b);
764 b = global_regex_namespace::regex_search(m_string, e);
765 ignore_unused_variable_warning(b);
766 b = global_regex_namespace::regex_search(m_string, e, m_mft);
767 ignore_unused_variable_warning(b);
770 m_out = global_regex_namespace::regex_replace(m_out, m_in, m_in, e, m_string, m_mft);
771 m_out = global_regex_namespace::regex_replace(m_out, m_in, m_in, e, m_string);
772 m_string = global_regex_namespace::regex_replace(m_string, e, m_string, m_mft);
773 ignore_unused_variable_warning(m_string);
774 m_string = global_regex_namespace::regex_replace(m_string, e, m_string);
775 ignore_unused_variable_warning(m_string);
780 string_type m_string;
781 const sub_match_type m_sub;
782 match_results_type m_results;
783 pointer_type m_pointer;
785 const match_results_type m_cresults;
788 global_regex_namespace::regex_constants::match_flag_type m_mft;
789 global_regex_namespace::match_results<typename string_type::const_iterator, allocator_architype<global_regex_namespace::sub_match<typename string_type::const_iterator> > > m_smatch;
792 RegexConcept(const RegexConcept&);
793 RegexConcept& operator=(const RegexConcept&);
796 #ifndef BOOST_REGEX_TEST_STD
801 typedef typename M::char_type char_type;
802 const char_type* operator()(const M&)const
804 static const char_type c = static_cast<char_type>(0);
811 typedef typename M::char_type char_type;
812 std::vector<char_type> operator()(const M&)const
814 static const std::vector<char_type> c;
822 O operator()(const M& /*m*/, O i)const
831 O operator()(const M& /*m*/, O i, regex_constants::match_flag_type)const
838 // BoostRegexConcept:
839 // Test every interface in the Boost implementation:
841 template <class Regex>
842 struct BoostRegexConcept
844 typedef typename Regex::value_type value_type;
845 typedef typename Regex::size_type size_type;
846 typedef typename Regex::flag_type flag_type;
847 typedef typename Regex::locale_type locale_type;
849 // derived test types:
850 typedef const value_type* pointer_type;
851 typedef std::basic_string<value_type> string_type;
852 typedef typename Regex::const_iterator const_iterator;
853 typedef bidirectional_iterator_archetype<value_type> BidiIterator;
854 typedef output_iterator_archetype<value_type> OutputIterator;
855 typedef global_regex_namespace::sub_match<BidiIterator> sub_match_type;
856 typedef global_regex_namespace::match_results<BidiIterator, allocator_architype<sub_match_type> > match_results_type;
857 typedef global_regex_namespace::match_results<BidiIterator> match_results_default_type;
861 global_regex_namespace::regex_constants::match_flag_type mopts
862 = global_regex_namespace::regex_constants::match_default
863 | global_regex_namespace::regex_constants::match_not_bol
864 | global_regex_namespace::regex_constants::match_not_eol
865 | global_regex_namespace::regex_constants::match_not_bow
866 | global_regex_namespace::regex_constants::match_not_eow
867 | global_regex_namespace::regex_constants::match_any
868 | global_regex_namespace::regex_constants::match_not_null
869 | global_regex_namespace::regex_constants::match_continuous
870 | global_regex_namespace::regex_constants::match_partial
871 | global_regex_namespace::regex_constants::match_prev_avail
872 | global_regex_namespace::regex_constants::format_default
873 | global_regex_namespace::regex_constants::format_sed
874 | global_regex_namespace::regex_constants::format_perl
875 | global_regex_namespace::regex_constants::format_no_copy
876 | global_regex_namespace::regex_constants::format_first_only;
880 function_requires<RegexConcept<Regex> >();
881 const global_regex_namespace::regex_error except(global_regex_namespace::regex_constants::error_collate);
882 std::ptrdiff_t pt = except.position();
883 ignore_unused_variable_warning(pt);
885 #ifndef BOOST_NO_STD_LOCALE
888 unsigned i = ce.error_code();
889 ignore_unused_variable_warning(i);
890 pointer_type p = ce.expression();
891 ignore_unused_variable_warning(p);
892 int i2 = ce.compare(ce2);
893 ignore_unused_variable_warning(i2);
895 ignore_unused_variable_warning(b);
897 ignore_unused_variable_warning(b);
899 ignore_unused_variable_warning(b);
901 ignore_unused_variable_warning(b);
903 ignore_unused_variable_warning(b);
905 ignore_unused_variable_warning(b);
907 ignore_unused_variable_warning(b);
909 ignore_unused_variable_warning(i);
910 size_type s = ce.max_size();
911 ignore_unused_variable_warning(s);
913 ignore_unused_variable_warning(s);
914 const_iterator pi = ce.begin();
915 ignore_unused_variable_warning(pi);
917 ignore_unused_variable_warning(pi);
918 string_type s2 = ce.str();
919 ignore_unused_variable_warning(s2);
921 m_string = m_sub + m_sub;
922 ignore_unused_variable_warning(m_string);
923 m_string = m_sub + m_pointer;
924 ignore_unused_variable_warning(m_string);
925 m_string = m_pointer + m_sub;
926 ignore_unused_variable_warning(m_string);
927 m_string = m_sub + m_string;
928 ignore_unused_variable_warning(m_string);
929 m_string = m_string + m_sub;
930 ignore_unused_variable_warning(m_string);
931 m_string = m_sub + m_char;
932 ignore_unused_variable_warning(m_string);
933 m_string = m_char + m_sub;
934 ignore_unused_variable_warning(m_string);
936 // Named sub-expressions:
937 m_sub = m_cresults[&m_char];
938 ignore_unused_variable_warning(m_sub);
939 m_sub = m_cresults[m_string];
940 ignore_unused_variable_warning(m_sub);
941 m_sub = m_cresults[""];
942 ignore_unused_variable_warning(m_sub);
943 m_sub = m_cresults[std::string("")];
944 ignore_unused_variable_warning(m_sub);
945 m_string = m_cresults.str(&m_char);
946 ignore_unused_variable_warning(m_string);
947 m_string = m_cresults.str(m_string);
948 ignore_unused_variable_warning(m_string);
949 m_string = m_cresults.str("");
950 ignore_unused_variable_warning(m_string);
951 m_string = m_cresults.str(std::string(""));
952 ignore_unused_variable_warning(m_string);
954 typename match_results_type::difference_type diff;
955 diff = m_cresults.length(&m_char);
956 ignore_unused_variable_warning(diff);
957 diff = m_cresults.length(m_string);
958 ignore_unused_variable_warning(diff);
959 diff = m_cresults.length("");
960 ignore_unused_variable_warning(diff);
961 diff = m_cresults.length(std::string(""));
962 ignore_unused_variable_warning(diff);
963 diff = m_cresults.position(&m_char);
964 ignore_unused_variable_warning(diff);
965 diff = m_cresults.position(m_string);
966 ignore_unused_variable_warning(diff);
967 diff = m_cresults.position("");
968 ignore_unused_variable_warning(diff);
969 diff = m_cresults.position(std::string(""));
970 ignore_unused_variable_warning(diff);
972 #ifndef BOOST_NO_STD_LOCALE
974 m_stream << m_cresults;
977 // Extended formatting with a functor:
979 regex_constants::match_flag_type f = regex_constants::match_default;
980 OutputIterator out = static_object<OutputIterator>::get();
982 functor3<match_results_default_type> func3;
983 functor2<match_results_default_type> func2;
984 functor1<match_results_default_type> func1;
986 functor3<match_results_type> func3b;
987 functor2<match_results_type> func2b;
988 functor1<match_results_type> func1b;
990 out = regex_format(out, m_cresults, func3b, f);
991 out = regex_format(out, m_cresults, func3b);
992 out = regex_format(out, m_cresults, func2b, f);
993 out = regex_format(out, m_cresults, func2b);
994 out = regex_format(out, m_cresults, func1b, f);
995 out = regex_format(out, m_cresults, func1b);
996 out = regex_format(out, m_cresults, boost::ref(func3b), f);
997 out = regex_format(out, m_cresults, boost::ref(func3b));
998 out = regex_format(out, m_cresults, boost::ref(func2b), f);
999 out = regex_format(out, m_cresults, boost::ref(func2b));
1000 out = regex_format(out, m_cresults, boost::ref(func1b), f);
1001 out = regex_format(out, m_cresults, boost::ref(func1b));
1002 out = regex_format(out, m_cresults, boost::cref(func3b), f);
1003 out = regex_format(out, m_cresults, boost::cref(func3b));
1004 out = regex_format(out, m_cresults, boost::cref(func2b), f);
1005 out = regex_format(out, m_cresults, boost::cref(func2b));
1006 out = regex_format(out, m_cresults, boost::cref(func1b), f);
1007 out = regex_format(out, m_cresults, boost::cref(func1b));
1009 m_string += regex_format(m_cresults, func3b, f);
1010 m_string += regex_format(m_cresults, func3b);
1011 m_string += regex_format(m_cresults, func2b, f);
1012 m_string += regex_format(m_cresults, func2b);
1013 m_string += regex_format(m_cresults, func1b, f);
1014 m_string += regex_format(m_cresults, func1b);
1015 m_string += regex_format(m_cresults, boost::ref(func3b), f);
1016 m_string += regex_format(m_cresults, boost::ref(func3b));
1017 m_string += regex_format(m_cresults, boost::ref(func2b), f);
1018 m_string += regex_format(m_cresults, boost::ref(func2b));
1019 m_string += regex_format(m_cresults, boost::ref(func1b), f);
1020 m_string += regex_format(m_cresults, boost::ref(func1b));
1021 m_string += regex_format(m_cresults, boost::cref(func3b), f);
1022 m_string += regex_format(m_cresults, boost::cref(func3b));
1023 m_string += regex_format(m_cresults, boost::cref(func2b), f);
1024 m_string += regex_format(m_cresults, boost::cref(func2b));
1025 m_string += regex_format(m_cresults, boost::cref(func1b), f);
1026 m_string += regex_format(m_cresults, boost::cref(func1b));
1028 out = m_cresults.format(out, func3b, f);
1029 out = m_cresults.format(out, func3b);
1030 out = m_cresults.format(out, func2b, f);
1031 out = m_cresults.format(out, func2b);
1032 out = m_cresults.format(out, func1b, f);
1033 out = m_cresults.format(out, func1b);
1034 out = m_cresults.format(out, boost::ref(func3b), f);
1035 out = m_cresults.format(out, boost::ref(func3b));
1036 out = m_cresults.format(out, boost::ref(func2b), f);
1037 out = m_cresults.format(out, boost::ref(func2b));
1038 out = m_cresults.format(out, boost::ref(func1b), f);
1039 out = m_cresults.format(out, boost::ref(func1b));
1040 out = m_cresults.format(out, boost::cref(func3b), f);
1041 out = m_cresults.format(out, boost::cref(func3b));
1042 out = m_cresults.format(out, boost::cref(func2b), f);
1043 out = m_cresults.format(out, boost::cref(func2b));
1044 out = m_cresults.format(out, boost::cref(func1b), f);
1045 out = m_cresults.format(out, boost::cref(func1b));
1047 m_string += m_cresults.format(func3b, f);
1048 m_string += m_cresults.format(func3b);
1049 m_string += m_cresults.format(func2b, f);
1050 m_string += m_cresults.format(func2b);
1051 m_string += m_cresults.format(func1b, f);
1052 m_string += m_cresults.format(func1b);
1053 m_string += m_cresults.format(boost::ref(func3b), f);
1054 m_string += m_cresults.format(boost::ref(func3b));
1055 m_string += m_cresults.format(boost::ref(func2b), f);
1056 m_string += m_cresults.format(boost::ref(func2b));
1057 m_string += m_cresults.format(boost::ref(func1b), f);
1058 m_string += m_cresults.format(boost::ref(func1b));
1059 m_string += m_cresults.format(boost::cref(func3b), f);
1060 m_string += m_cresults.format(boost::cref(func3b));
1061 m_string += m_cresults.format(boost::cref(func2b), f);
1062 m_string += m_cresults.format(boost::cref(func2b));
1063 m_string += m_cresults.format(boost::cref(func1b), f);
1064 m_string += m_cresults.format(boost::cref(func1b));
1066 out = regex_replace(out, m_in, m_in, ce, func3, f);
1067 out = regex_replace(out, m_in, m_in, ce, func3);
1068 out = regex_replace(out, m_in, m_in, ce, func2, f);
1069 out = regex_replace(out, m_in, m_in, ce, func2);
1070 out = regex_replace(out, m_in, m_in, ce, func1, f);
1071 out = regex_replace(out, m_in, m_in, ce, func1);
1072 out = regex_replace(out, m_in, m_in, ce, boost::ref(func3), f);
1073 out = regex_replace(out, m_in, m_in, ce, boost::ref(func3));
1074 out = regex_replace(out, m_in, m_in, ce, boost::ref(func2), f);
1075 out = regex_replace(out, m_in, m_in, ce, boost::ref(func2));
1076 out = regex_replace(out, m_in, m_in, ce, boost::ref(func1), f);
1077 out = regex_replace(out, m_in, m_in, ce, boost::ref(func1));
1078 out = regex_replace(out, m_in, m_in, ce, boost::cref(func3), f);
1079 out = regex_replace(out, m_in, m_in, ce, boost::cref(func3));
1080 out = regex_replace(out, m_in, m_in, ce, boost::cref(func2), f);
1081 out = regex_replace(out, m_in, m_in, ce, boost::cref(func2));
1082 out = regex_replace(out, m_in, m_in, ce, boost::cref(func1), f);
1083 out = regex_replace(out, m_in, m_in, ce, boost::cref(func1));
1085 functor3<match_results<typename string_type::const_iterator> > func3s;
1086 functor2<match_results<typename string_type::const_iterator> > func2s;
1087 functor1<match_results<typename string_type::const_iterator> > func1s;
1088 m_string += regex_replace(m_string, ce, func3s, f);
1089 m_string += regex_replace(m_string, ce, func3s);
1090 m_string += regex_replace(m_string, ce, func2s, f);
1091 m_string += regex_replace(m_string, ce, func2s);
1092 m_string += regex_replace(m_string, ce, func1s, f);
1093 m_string += regex_replace(m_string, ce, func1s);
1094 m_string += regex_replace(m_string, ce, boost::ref(func3s), f);
1095 m_string += regex_replace(m_string, ce, boost::ref(func3s));
1096 m_string += regex_replace(m_string, ce, boost::ref(func2s), f);
1097 m_string += regex_replace(m_string, ce, boost::ref(func2s));
1098 m_string += regex_replace(m_string, ce, boost::ref(func1s), f);
1099 m_string += regex_replace(m_string, ce, boost::ref(func1s));
1100 m_string += regex_replace(m_string, ce, boost::cref(func3s), f);
1101 m_string += regex_replace(m_string, ce, boost::cref(func3s));
1102 m_string += regex_replace(m_string, ce, boost::cref(func2s), f);
1103 m_string += regex_replace(m_string, ce, boost::cref(func2s));
1104 m_string += regex_replace(m_string, ce, boost::cref(func1s), f);
1105 m_string += regex_replace(m_string, ce, boost::cref(func1s));
1108 std::basic_ostream<value_type> m_stream;
1109 sub_match_type m_sub;
1110 pointer_type m_pointer;
1111 string_type m_string;
1112 const value_type m_char;
1113 match_results_type m_results;
1114 const match_results_type m_cresults;
1117 BoostRegexConcept();
1118 BoostRegexConcept(const BoostRegexConcept&);
1119 BoostRegexConcept& operator=(const BoostRegexConcept&);
1122 #endif // BOOST_REGEX_TEST_STD