source: NonGTP/Boost/boost/regex/concepts.hpp @ 857

Revision 857, 33.0 KB checked in by igarcia, 19 years ago (diff)
RevLine 
[857]1/*
2 *
3 * Copyright (c) 2004
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         concepts.hpp
15  *   VERSION      see <boost/version.hpp>
16  *   DESCRIPTION: Declares regular expression concepts.
17  */
18
19#ifndef BOOST_REGEX_CONCEPTS_HPP_INCLUDED
20#define BOOST_REGEX_CONCEPTS_HPP_INCLUDED
21
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>
29#endif
30#include <bitset>
31#include <vector>
32#include <iostream>
33
34namespace boost{
35
36//
37// bitmask_archetype:
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:
41//
42typedef std::bitset<512> bitmask_archetype;
43//
44// char_architype:
45// A strict model for the character type interface.
46//
47struct char_architype
48{
49   // default constructable:
50   char_architype();
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);
56   // comparable:
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:
64   operator long()const;
65};
66//
67// char_architype can not be used with basic_string:
68//
69} // namespace boost
70namespace std{
71   template<> struct char_traits<boost::char_architype>{};
72}
73namespace boost{
74//
75// regex_traits_architype:
76// A strict interpretation of the regular expression traits class requirements.
77//
78template <class charT>
79struct regex_traits_architype
80{
81public:
82   regex_traits_architype();
83   typedef charT char_type;
84   typedef std::size_t size_type;
85   typedef std::vector<char_type> string_type;
86   typedef copy_constructible_archetype<assignable_archetype<> > locale_type;
87   typedef bitmask_archetype char_class_type;
88
89   static size_type length(const char_type* ) { return 0; }
90
91   charT translate(charT ) const { return charT(); }
92   charT translate_nocase(charT ) const { return static_object<charT>::get(); }
93
94   template <class ForwardIterator>
95   string_type transform(ForwardIterator , ForwardIterator ) const
96   { return static_object<string_type>::get(); }
97   template <class ForwardIterator>
98   string_type transform_primary(ForwardIterator , ForwardIterator ) const
99   { return static_object<string_type>::get(); }
100
101   template <class ForwardIterator>
102   char_class_type lookup_classname(ForwardIterator , ForwardIterator ) const
103   { return static_object<char_class_type>::get(); }
104   template <class ForwardIterator>
105   string_type lookup_collatename(ForwardIterator , ForwardIterator ) const
106   { return static_object<string_type>::get(); }
107
108   bool isctype(charT, char_class_type) const
109   { return false; }
110   int value(charT, int) const
111   { return 0; }
112
113   locale_type imbue(locale_type l)
114   { return l; }
115   locale_type getloc()const
116   { return static_object<locale_type>::get(); }
117
118private:
119   // this type is not copyable:
120   regex_traits_architype(const regex_traits_architype&);
121   regex_traits_architype& operator=(const regex_traits_architype&);
122};
123
124//
125// alter this to std::tr1, to test a std implementation:
126//
127#ifndef BOOST_TEST_TR1_REGEX
128namespace global_regex_namespace = ::boost;
129#else
130namespace global_regex_namespace = ::std::tr1;
131#endif
132
133template <class Bitmask>
134struct BitmaskConcept
135{
136   void constraints()
137   {
138      function_requires<CopyConstructibleConcept<Bitmask> >();
139      function_requires<AssignableConcept<Bitmask> >();
140
141      m_mask1 = m_mask2 | m_mask3;
142      m_mask1 = m_mask2 & m_mask3;
143      m_mask1 = m_mask2 ^ m_mask3;
144
145      m_mask1 = ~m_mask2;
146
147      m_mask1 |= m_mask2;
148      m_mask1 &= m_mask2;
149      m_mask1 ^= m_mask2;
150   }
151   Bitmask m_mask1, m_mask2, m_mask3;
152};
153
154template <class traits>
155struct RegexTraitsConcept
156{
157   RegexTraitsConcept();
158   // required typedefs:
159   typedef typename traits::char_type char_type;
160   typedef typename traits::size_type size_type;
161   typedef typename traits::string_type string_type;
162   typedef typename traits::locale_type locale_type;
163   typedef typename traits::char_class_type char_class_type;
164
165   void constraints()
166   {
167      function_requires<UnsignedIntegerConcept<size_type> >();
168      function_requires<RandomAccessContainerConcept<string_type> >();
169      function_requires<DefaultConstructibleConcept<locale_type> >();
170      function_requires<CopyConstructibleConcept<locale_type> >();
171      function_requires<AssignableConcept<locale_type> >();
172      function_requires<BitmaskConcept<char_class_type> >();
173
174      size_type n = traits::length(m_pointer);
175      ignore_unused_variable_warning(n);
176
177      char_type c = m_ctraits.translate(m_char);
178      ignore_unused_variable_warning(c);
179      c = m_ctraits.translate_nocase(m_char);
180     
181      //string_type::foobar bar;
182      string_type s1 = m_ctraits.transform(m_pointer, m_pointer);
183      ignore_unused_variable_warning(s1);
184
185      string_type s2 = m_ctraits.transform_primary(m_pointer, m_pointer);
186      ignore_unused_variable_warning(s2);
187
188      char_class_type cc = m_ctraits.lookup_classname(m_pointer, m_pointer);
189      ignore_unused_variable_warning(cc);
190
191      string_type s3 = m_ctraits.lookup_collatename(m_pointer, m_pointer);
192      ignore_unused_variable_warning(s3);
193
194      bool b = m_ctraits.isctype(m_char, cc);
195      ignore_unused_variable_warning(b);
196
197      int v = m_ctraits.value(m_char, 16);
198      ignore_unused_variable_warning(v);
199
200      locale_type l(m_ctraits.getloc());
201      m_traits.imbue(l);
202      ignore_unused_variable_warning(l);
203   }
204   traits m_traits;
205   const traits m_ctraits;
206   const char_type* m_pointer;
207   char_type m_char;
208};
209
210//
211// helper class to compute what traits class a regular expression type is using:
212//
213template <class Regex>
214struct regex_traits_computer;
215
216template <class charT, class traits>
217struct regex_traits_computer< global_regex_namespace::basic_regex<charT, traits> >
218{
219   typedef traits type;
220};
221
222//
223// BaseRegexConcept does not test anything dependent on basic_string,
224// in case our charT does not have an associated char_traits:
225//
226template <class Regex>
227struct BaseRegexConcept
228{
229   typedef typename Regex::value_type value_type;
230   typedef typename Regex::size_type size_type;
231   typedef typename Regex::flag_type flag_type;
232   typedef typename Regex::locale_type locale_type;
233   typedef input_iterator_archetype<value_type> input_iterator_type;
234
235   // derived test types:
236   typedef const value_type* pointer_type;
237   typedef bidirectional_iterator_archetype<value_type> BidiIterator;
238   typedef global_regex_namespace::sub_match<BidiIterator> sub_match_type;
239   typedef global_regex_namespace::match_results<BidiIterator> match_results_type;
240   typedef output_iterator_archetype<value_type> OutIterator;
241   typedef typename regex_traits_computer<Regex>::type traits_type;
242   typedef global_regex_namespace::regex_iterator<BidiIterator, value_type, traits_type> regex_iterator_type;
243   typedef global_regex_namespace::regex_token_iterator<BidiIterator, value_type, traits_type> regex_token_iterator_type;
244
245   void global_constraints()
246   {
247      //
248      // test non-template components:
249      //
250      function_requires<BitmaskConcept<global_regex_namespace::regex_constants::syntax_option_type> >();
251      global_regex_namespace::regex_constants::syntax_option_type opts
252         = global_regex_namespace::regex_constants::icase
253         | global_regex_namespace::regex_constants::nosubs
254         | global_regex_namespace::regex_constants::optimize
255         | global_regex_namespace::regex_constants::collate
256         | global_regex_namespace::regex_constants::ECMAScript
257         | global_regex_namespace::regex_constants::basic
258         | global_regex_namespace::regex_constants::extended
259         | global_regex_namespace::regex_constants::awk
260         | global_regex_namespace::regex_constants::grep
261         | global_regex_namespace::regex_constants::egrep;
262      ignore_unused_variable_warning(opts);
263
264      function_requires<BitmaskConcept<global_regex_namespace::regex_constants::match_flag_type> >();
265      global_regex_namespace::regex_constants::match_flag_type mopts
266         = global_regex_namespace::regex_constants::match_default
267         | global_regex_namespace::regex_constants::match_not_bol
268         | global_regex_namespace::regex_constants::match_not_eol
269         | global_regex_namespace::regex_constants::match_not_bow
270         | global_regex_namespace::regex_constants::match_not_eow
271         | global_regex_namespace::regex_constants::match_any
272         | global_regex_namespace::regex_constants::match_not_null
273         | global_regex_namespace::regex_constants::match_continuous
274         | global_regex_namespace::regex_constants::match_prev_avail
275         | global_regex_namespace::regex_constants::format_default
276         | global_regex_namespace::regex_constants::format_sed
277         | global_regex_namespace::regex_constants::format_no_copy
278         | global_regex_namespace::regex_constants::format_first_only;
279      ignore_unused_variable_warning(mopts);
280
281      BOOST_STATIC_ASSERT((::boost::is_enum<global_regex_namespace::regex_constants::error_type>::value));
282      global_regex_namespace::regex_constants::error_type e1 = global_regex_namespace::regex_constants::error_collate;
283      ignore_unused_variable_warning(e1);
284      e1 = global_regex_namespace::regex_constants::error_ctype;
285      ignore_unused_variable_warning(e1);
286      e1 = global_regex_namespace::regex_constants::error_escape;
287      ignore_unused_variable_warning(e1);
288      e1 = global_regex_namespace::regex_constants::error_backref;
289      ignore_unused_variable_warning(e1);
290      e1 = global_regex_namespace::regex_constants::error_brack;
291      ignore_unused_variable_warning(e1);
292      e1 = global_regex_namespace::regex_constants::error_paren;
293      ignore_unused_variable_warning(e1);
294      e1 = global_regex_namespace::regex_constants::error_brace;
295      ignore_unused_variable_warning(e1);
296      e1 = global_regex_namespace::regex_constants::error_badbrace;
297      ignore_unused_variable_warning(e1);
298      e1 = global_regex_namespace::regex_constants::error_range;
299      ignore_unused_variable_warning(e1);
300      e1 = global_regex_namespace::regex_constants::error_space;
301      ignore_unused_variable_warning(e1);
302      e1 = global_regex_namespace::regex_constants::error_badrepeat;
303      ignore_unused_variable_warning(e1);
304      e1 = global_regex_namespace::regex_constants::error_complexity;
305      ignore_unused_variable_warning(e1);
306      e1 = global_regex_namespace::regex_constants::error_stack;
307      ignore_unused_variable_warning(e1);
308
309      BOOST_STATIC_ASSERT((::boost::is_base_and_derived<std::runtime_error, global_regex_namespace::regex_error>::value  ));
310      const global_regex_namespace::regex_error except(e1);
311      e1 = except.code();
312
313      typedef typename Regex::value_type value_type;
314      function_requires< RegexTraitsConcept<global_regex_namespace::regex_traits<char> > >();
315      function_requires< BaseRegexConcept<global_regex_namespace::basic_regex<char> > >();
316   }
317   void constraints()
318   {
319      global_constraints();
320
321      BOOST_STATIC_ASSERT((::boost::is_same< flag_type, global_regex_namespace::regex_constants::syntax_option_type>::value));
322      flag_type opts
323         = Regex::icase
324         | Regex::nosubs
325         | Regex::optimize
326         | Regex::collate
327         | Regex::ECMAScript
328         | Regex::basic
329         | Regex::extended
330         | Regex::awk
331         | Regex::grep
332         | Regex::egrep;
333      ignore_unused_variable_warning(opts);
334
335      function_requires<DefaultConstructibleConcept<Regex> >();
336      function_requires<CopyConstructibleConcept<Regex> >();
337
338      // Regex constructors:
339      Regex e1(m_pointer);
340      ignore_unused_variable_warning(e1);
341      Regex e2(m_pointer, m_flags);
342      ignore_unused_variable_warning(e2);
343      Regex e3(m_pointer, m_size, m_flags);
344      ignore_unused_variable_warning(e3);
345      Regex e4(in1, in2);
346      ignore_unused_variable_warning(e4);
347      Regex e5(in1, in2, m_flags);
348      ignore_unused_variable_warning(e5);
349
350      // assign etc:
351      Regex e;
352      e = m_pointer;
353      e = e1;
354      e.assign(e1);
355      e.assign(m_pointer);
356      e.assign(m_pointer, m_flags);
357      e.assign(m_pointer, m_size, m_flags);
358      e.assign(in1, in2);
359      e.assign(in1, in2, m_flags);
360
361      // access:
362      const Regex ce;
363      bool b = ce.empty();
364      ignore_unused_variable_warning(b);
365      size_type i = ce.mark_count();
366      ignore_unused_variable_warning(i);
367      m_flags = ce.flags();
368      e.imbue(ce.getloc());
369      e.swap(e1);
370     
371      global_regex_namespace::swap(e, e1);
372
373      // sub_match:
374      BOOST_STATIC_ASSERT((::boost::is_base_and_derived<std::pair<BidiIterator, BidiIterator>, sub_match_type>::value));
375      typedef typename sub_match_type::value_type sub_value_type;
376      typedef typename sub_match_type::difference_type sub_diff_type;
377      typedef typename sub_match_type::iterator sub_iter_type;
378      BOOST_STATIC_ASSERT((::boost::is_same<sub_value_type, value_type>::value));
379      BOOST_STATIC_ASSERT((::boost::is_same<sub_iter_type, BidiIterator>::value));
380      b = m_sub.matched;
381      ignore_unused_variable_warning(b);
382      BidiIterator bi = m_sub.first;
383      ignore_unused_variable_warning(bi);
384      bi = m_sub.second;
385      ignore_unused_variable_warning(bi);
386      sub_diff_type diff = m_sub.length();
387      ignore_unused_variable_warning(diff);
388      // match_results tests:
389      typedef typename match_results_type::value_type mr_value_type;
390      typedef typename match_results_type::const_reference mr_const_reference;
391      typedef typename match_results_type::reference mr_reference;
392      typedef typename match_results_type::const_iterator mr_const_iterator;
393      typedef typename match_results_type::iterator mr_iterator;
394      typedef typename match_results_type::difference_type mr_difference_type;
395      typedef typename match_results_type::size_type mr_size_type;
396      typedef typename match_results_type::allocator_type mr_allocator_type;
397      typedef typename match_results_type::char_type mr_char_type;
398      typedef typename match_results_type::string_type mr_string_type;
399
400      match_results_type m1;
401      mr_allocator_type at;
402      match_results_type m2(at);
403      match_results_type m3(m1);
404      m1 = m2;
405
406      mr_size_type mrs = m_cresults.size();
407      ignore_unused_variable_warning(mrs);
408      mrs = m_cresults.max_size();
409      ignore_unused_variable_warning(mrs);
410      b = m_cresults.empty();
411      ignore_unused_variable_warning(b);
412      mr_difference_type mrd = m_cresults.length();
413      ignore_unused_variable_warning(mrd);
414      mrd = m_cresults.length(mrs);
415      ignore_unused_variable_warning(mrd);
416      mrd = m_cresults.position();
417      ignore_unused_variable_warning(mrd);
418      mrd = m_cresults.position(mrs);
419      ignore_unused_variable_warning(mrd);
420
421      mr_const_reference mrcr = m_cresults[m_size];
422      ignore_unused_variable_warning(mrcr);
423      mr_const_reference mrcr2 = m_cresults.prefix();
424      ignore_unused_variable_warning(mrcr2);
425      mr_const_reference mrcr3 = m_cresults.suffix();
426      ignore_unused_variable_warning(mrcr3);
427      mr_const_iterator mrci = m_cresults.begin();
428      ignore_unused_variable_warning(mrci);
429      mrci = m_cresults.end();
430      ignore_unused_variable_warning(mrci);
431
432      mr_allocator_type at2 = m_cresults.get_allocator();
433      m_results.swap(m_results);
434      global_regex_namespace::swap(m_results, m_results);
435
436      // regex_match:
437      b = global_regex_namespace::regex_match(m_in, m_in, m_results, e);
438      ignore_unused_variable_warning(b);
439      b = global_regex_namespace::regex_match(m_in, m_in, m_results, e, m_mft);
440      ignore_unused_variable_warning(b);
441      b = global_regex_namespace::regex_match(m_in, m_in, e);
442      ignore_unused_variable_warning(b);
443      b = global_regex_namespace::regex_match(m_in, m_in, e, m_mft);
444      ignore_unused_variable_warning(b);
445      b = global_regex_namespace::regex_match(m_pointer, m_pmatch, e);
446      ignore_unused_variable_warning(b);
447      b = global_regex_namespace::regex_match(m_pointer, m_pmatch, e, m_mft);
448      ignore_unused_variable_warning(b);
449      b = global_regex_namespace::regex_match(m_pointer, e);
450      ignore_unused_variable_warning(b);
451      b = global_regex_namespace::regex_match(m_pointer, e, m_mft);
452      ignore_unused_variable_warning(b);
453      // regex_search:
454      b = global_regex_namespace::regex_search(m_in, m_in, m_results, e);
455      ignore_unused_variable_warning(b);
456      b = global_regex_namespace::regex_search(m_in, m_in, m_results, e, m_mft);
457      ignore_unused_variable_warning(b);
458      b = global_regex_namespace::regex_search(m_in, m_in, e);
459      ignore_unused_variable_warning(b);
460      b = global_regex_namespace::regex_search(m_in, m_in, e, m_mft);
461      ignore_unused_variable_warning(b);
462      b = global_regex_namespace::regex_search(m_pointer, m_pmatch, e);
463      ignore_unused_variable_warning(b);
464      b = global_regex_namespace::regex_search(m_pointer, m_pmatch, e, m_mft);
465      ignore_unused_variable_warning(b);
466      b = global_regex_namespace::regex_search(m_pointer, e);
467      ignore_unused_variable_warning(b);
468      b = global_regex_namespace::regex_search(m_pointer, e, m_mft);
469      ignore_unused_variable_warning(b);
470
471      // regex_iterator:
472      typedef typename regex_iterator_type::regex_type rit_regex_type;
473      typedef typename regex_iterator_type::value_type rit_value_type;
474      typedef typename regex_iterator_type::difference_type rit_difference_type;
475      typedef typename regex_iterator_type::pointer rit_pointer;
476      typedef typename regex_iterator_type::reference rit_reference;
477      typedef typename regex_iterator_type::iterator_category rit_iterator_category;
478      BOOST_STATIC_ASSERT((::boost::is_same<rit_regex_type, Regex>::value));
479      BOOST_STATIC_ASSERT((::boost::is_same<rit_value_type, match_results_type>::value));
480      BOOST_STATIC_ASSERT((::boost::is_same<rit_difference_type, std::ptrdiff_t>::value));
481      BOOST_STATIC_ASSERT((::boost::is_same<rit_pointer, const match_results_type*>::value));
482      BOOST_STATIC_ASSERT((::boost::is_same<rit_reference, const match_results_type&>::value));
483      BOOST_STATIC_ASSERT((::boost::is_convertible<rit_iterator_category*, std::forward_iterator_tag*>::value));
484      // this takes care of most of the checks needed:
485      function_requires<ForwardIteratorConcept<regex_iterator_type> >();
486      regex_iterator_type iter1(m_in, m_in, e);
487      ignore_unused_variable_warning(iter1);
488      regex_iterator_type iter2(m_in, m_in, e, m_mft);
489      ignore_unused_variable_warning(iter2);
490
491      // regex_token_iterator:
492      typedef typename regex_token_iterator_type::regex_type rtit_regex_type;
493      typedef typename regex_token_iterator_type::value_type rtit_value_type;
494      typedef typename regex_token_iterator_type::difference_type rtit_difference_type;
495      typedef typename regex_token_iterator_type::pointer rtit_pointer;
496      typedef typename regex_token_iterator_type::reference rtit_reference;
497      typedef typename regex_token_iterator_type::iterator_category rtit_iterator_category;
498      BOOST_STATIC_ASSERT((::boost::is_same<rtit_regex_type, Regex>::value));
499      BOOST_STATIC_ASSERT((::boost::is_same<rtit_value_type, sub_match_type>::value));
500      BOOST_STATIC_ASSERT((::boost::is_same<rtit_difference_type, std::ptrdiff_t>::value));
501      BOOST_STATIC_ASSERT((::boost::is_same<rtit_pointer, const sub_match_type*>::value));
502      BOOST_STATIC_ASSERT((::boost::is_same<rtit_reference, const sub_match_type&>::value));
503      BOOST_STATIC_ASSERT((::boost::is_convertible<rtit_iterator_category*, std::forward_iterator_tag*>::value));
504      // this takes care of most of the checks needed:
505      function_requires<ForwardIteratorConcept<regex_token_iterator_type> >();
506      regex_token_iterator_type ti1(m_in, m_in, e);
507      ignore_unused_variable_warning(ti1);
508      regex_token_iterator_type ti2(m_in, m_in, e, 0);
509      ignore_unused_variable_warning(ti2);
510      regex_token_iterator_type ti3(m_in, m_in, e, 0, m_mft);
511      ignore_unused_variable_warning(ti3);
512      std::vector<int> subs;
513      regex_token_iterator_type ti4(m_in, m_in, e, subs);
514      ignore_unused_variable_warning(ti4);
515      regex_token_iterator_type ti5(m_in, m_in, e, subs, m_mft);
516      ignore_unused_variable_warning(ti5);
517      static const int i_array[3] = { 1, 2, 3, };
518      regex_token_iterator_type ti6(m_in, m_in, e, i_array);
519      ignore_unused_variable_warning(ti6);
520      regex_token_iterator_type ti7(m_in, m_in, e, i_array, m_mft);
521      ignore_unused_variable_warning(ti7);
522   }
523
524   pointer_type m_pointer;
525   flag_type m_flags;
526   size_type m_size;
527   input_iterator_type in1, in2;
528   const sub_match_type m_sub;
529   const value_type m_char;
530   match_results_type m_results;
531   const match_results_type m_cresults;
532   OutIterator m_out;
533   BidiIterator m_in;
534   global_regex_namespace::regex_constants::match_flag_type m_mft;
535   global_regex_namespace::match_results<pointer_type> m_pmatch;
536
537   BaseRegexConcept();
538   BaseRegexConcept(const BaseRegexConcept&);
539   BaseRegexConcept& operator=(const BaseRegexConcept&);
540};
541
542//
543// RegexConcept:
544// Test every interface in the std:
545//
546template <class Regex>
547struct RegexConcept
548{
549   typedef typename Regex::value_type value_type;
550   typedef typename Regex::size_type size_type;
551   typedef typename Regex::flag_type flag_type;
552   typedef typename Regex::locale_type locale_type;
553
554   // derived test types:
555   typedef const value_type* pointer_type;
556   typedef std::basic_string<value_type> string_type;
557   typedef boost::bidirectional_iterator_archetype<value_type> BidiIterator;
558   typedef global_regex_namespace::sub_match<BidiIterator> sub_match_type;
559   typedef global_regex_namespace::match_results<BidiIterator> match_results_type;
560   typedef output_iterator_archetype<value_type> OutIterator;
561
562
563   void constraints()
564   {
565      function_requires<BaseRegexConcept<Regex> >();
566      // string based construct:
567      Regex e1(m_string);
568      ignore_unused_variable_warning(e1);
569      Regex e2(m_string, m_flags);
570      ignore_unused_variable_warning(e2);
571
572      // assign etc:
573      Regex e;
574      e = m_string;
575      e.assign(m_string);
576      e.assign(m_string, m_flags);
577
578      // sub_match:
579      string_type s(m_sub);
580      ignore_unused_variable_warning(s);
581      s = m_sub.str();
582      ignore_unused_variable_warning(s);
583      int i = m_sub.compare(m_string);
584      ignore_unused_variable_warning(i);
585
586      int i2 = m_sub.compare(m_sub);
587      ignore_unused_variable_warning(i2);
588      i2 = m_sub.compare(m_pointer);
589      ignore_unused_variable_warning(i2);
590
591      bool b = m_sub == m_sub;
592      ignore_unused_variable_warning(b);
593      b = m_sub != m_sub;
594      ignore_unused_variable_warning(b);
595      b = m_sub <= m_sub;
596      ignore_unused_variable_warning(b);
597      b = m_sub <= m_sub;
598      ignore_unused_variable_warning(b);
599      b = m_sub > m_sub;
600      ignore_unused_variable_warning(b);
601      b = m_sub >= m_sub;
602      ignore_unused_variable_warning(b);
603
604      b = m_sub == m_pointer;
605      ignore_unused_variable_warning(b);
606      b = m_sub != m_pointer;
607      ignore_unused_variable_warning(b);
608      b = m_sub <= m_pointer;
609      ignore_unused_variable_warning(b);
610      b = m_sub <= m_pointer;
611      ignore_unused_variable_warning(b);
612      b = m_sub > m_pointer;
613      ignore_unused_variable_warning(b);
614      b = m_sub >= m_pointer;
615      ignore_unused_variable_warning(b);
616
617      b = m_pointer == m_sub;
618      ignore_unused_variable_warning(b);
619      b = m_pointer != m_sub;
620      ignore_unused_variable_warning(b);
621      b = m_pointer <= m_sub;
622      ignore_unused_variable_warning(b);
623      b = m_pointer <= m_sub;
624      ignore_unused_variable_warning(b);
625      b = m_pointer > m_sub;
626      ignore_unused_variable_warning(b);
627      b = m_pointer >= m_sub;
628      ignore_unused_variable_warning(b);
629
630      b = m_sub == m_char;
631      ignore_unused_variable_warning(b);
632      b = m_sub != m_char;
633      ignore_unused_variable_warning(b);
634      b = m_sub <= m_char;
635      ignore_unused_variable_warning(b);
636      b = m_sub <= m_char;
637      ignore_unused_variable_warning(b);
638      b = m_sub > m_char;
639      ignore_unused_variable_warning(b);
640      b = m_sub >= m_char;
641      ignore_unused_variable_warning(b);
642
643      b = m_char == m_sub;
644      ignore_unused_variable_warning(b);
645      b = m_char != m_sub;
646      ignore_unused_variable_warning(b);
647      b = m_char <= m_sub;
648      ignore_unused_variable_warning(b);
649      b = m_char <= m_sub;
650      ignore_unused_variable_warning(b);
651      b = m_char > m_sub;
652      ignore_unused_variable_warning(b);
653      b = m_char >= m_sub;
654      ignore_unused_variable_warning(b);
655
656      b = m_sub == m_string;
657      ignore_unused_variable_warning(b);
658      b = m_sub != m_string;
659      ignore_unused_variable_warning(b);
660      b = m_sub <= m_string;
661      ignore_unused_variable_warning(b);
662      b = m_sub <= m_string;
663      ignore_unused_variable_warning(b);
664      b = m_sub > m_string;
665      ignore_unused_variable_warning(b);
666      b = m_sub >= m_string;
667      ignore_unused_variable_warning(b);
668
669      b = m_string == m_sub;
670      ignore_unused_variable_warning(b);
671      b = m_string != m_sub;
672      ignore_unused_variable_warning(b);
673      b = m_string <= m_sub;
674      ignore_unused_variable_warning(b);
675      b = m_string <= m_sub;
676      ignore_unused_variable_warning(b);
677      b = m_string > m_sub;
678      ignore_unused_variable_warning(b);
679      b = m_string >= m_sub;
680      ignore_unused_variable_warning(b);
681
682      // match results:
683      m_string = m_results.str();
684      ignore_unused_variable_warning(m_string);
685      m_string = m_results.str(0);
686      ignore_unused_variable_warning(m_string);
687      m_out = m_cresults.format(m_out, m_string);
688      m_out = m_cresults.format(m_out, m_string, m_mft);
689      m_string = m_cresults.format(m_string);
690      ignore_unused_variable_warning(m_string);
691      m_string = m_cresults.format(m_string, m_mft);
692      ignore_unused_variable_warning(m_string);
693
694      // regex_match:
695      b = global_regex_namespace::regex_match(m_string, m_smatch, e);
696      ignore_unused_variable_warning(b);
697      b = global_regex_namespace::regex_match(m_string, m_smatch, e, m_mft);
698      ignore_unused_variable_warning(b);
699      b = global_regex_namespace::regex_match(m_string, e);
700      ignore_unused_variable_warning(b);
701      b = global_regex_namespace::regex_match(m_string, e, m_mft);
702      ignore_unused_variable_warning(b);
703
704      // regex_search:
705      b = global_regex_namespace::regex_search(m_string, m_smatch, e);
706      ignore_unused_variable_warning(b);
707      b = global_regex_namespace::regex_search(m_string, m_smatch, e, m_mft);
708      ignore_unused_variable_warning(b);
709      b = global_regex_namespace::regex_search(m_string, e);
710      ignore_unused_variable_warning(b);
711      b = global_regex_namespace::regex_search(m_string, e, m_mft);
712      ignore_unused_variable_warning(b);
713
714      // regex_replace:
715      m_out = global_regex_namespace::regex_replace(m_out, m_in, m_in, e, m_string, m_mft);
716      m_out = global_regex_namespace::regex_replace(m_out, m_in, m_in, e, m_string);
717      m_string = global_regex_namespace::regex_replace(m_string, e, m_string, m_mft);
718      ignore_unused_variable_warning(m_string);
719      m_string = global_regex_namespace::regex_replace(m_string, e, m_string);
720      ignore_unused_variable_warning(m_string);
721
722   }
723
724   flag_type m_flags;
725   string_type m_string;
726   const sub_match_type m_sub;
727   match_results_type m_results;
728   pointer_type m_pointer;
729   value_type m_char;
730   const match_results_type m_cresults;
731   OutIterator m_out;
732   BidiIterator m_in;
733   global_regex_namespace::regex_constants::match_flag_type m_mft;
734   global_regex_namespace::match_results<typename string_type::const_iterator> m_smatch;
735
736   RegexConcept();
737   RegexConcept(const RegexConcept&);
738   RegexConcept& operator=(const RegexConcept&);
739};
740
741//
742// BoostRegexConcept:
743// Test every interface in the Boost implementation:
744//
745template <class Regex>
746struct BoostRegexConcept
747{
748   typedef typename Regex::value_type value_type;
749   typedef typename Regex::size_type size_type;
750   typedef typename Regex::flag_type flag_type;
751   typedef typename Regex::locale_type locale_type;
752
753   // derived test types:
754   typedef const value_type* pointer_type;
755   typedef std::basic_string<value_type> string_type;
756   typedef typename Regex::const_iterator const_iterator;
757   typedef bidirectional_iterator_archetype<value_type> BidiIterator;
758   typedef global_regex_namespace::sub_match<BidiIterator> sub_match_type;
759   typedef global_regex_namespace::match_results<BidiIterator> match_results_type;
760
761   void constraints()
762   {
763      global_regex_namespace::regex_constants::match_flag_type mopts
764         = global_regex_namespace::regex_constants::match_default
765         | global_regex_namespace::regex_constants::match_not_bol
766         | global_regex_namespace::regex_constants::match_not_eol
767         | global_regex_namespace::regex_constants::match_not_bow
768         | global_regex_namespace::regex_constants::match_not_eow
769         | global_regex_namespace::regex_constants::match_any
770         | global_regex_namespace::regex_constants::match_not_null
771         | global_regex_namespace::regex_constants::match_continuous
772         | global_regex_namespace::regex_constants::match_partial
773         | global_regex_namespace::regex_constants::match_prev_avail
774         | global_regex_namespace::regex_constants::format_default
775         | global_regex_namespace::regex_constants::format_sed
776         | global_regex_namespace::regex_constants::format_perl
777         | global_regex_namespace::regex_constants::format_no_copy
778         | global_regex_namespace::regex_constants::format_first_only;
779
780      function_requires<RegexConcept<Regex> >();
781      const global_regex_namespace::regex_error except(global_regex_namespace::regex_constants::error_collate);
782      std::ptrdiff_t pt = except.position();
783      ignore_unused_variable_warning(pt);
784      const Regex ce, ce2;
785#ifndef BOOST_NO_STD_LOCALE
786      m_stream << ce;
787#endif
788      unsigned i = ce.error_code();
789      ignore_unused_variable_warning(i);
790      pointer_type p = ce.expression();
791      ignore_unused_variable_warning(p);
792      int i2 = ce.compare(ce2);
793      ignore_unused_variable_warning(i2);
794      bool b = ce == ce2;
795      ignore_unused_variable_warning(b);
796      b = ce != ce2;
797      ignore_unused_variable_warning(b);
798      b = ce < ce2;
799      ignore_unused_variable_warning(b);
800      b = ce > ce2;
801      ignore_unused_variable_warning(b);
802      b = ce <= ce2;
803      ignore_unused_variable_warning(b);
804      b = ce >= ce2;
805      ignore_unused_variable_warning(b);
806      i = ce.status();
807      ignore_unused_variable_warning(i);
808      size_type s = ce.max_size();
809      ignore_unused_variable_warning(s);
810      s = ce.size();
811      ignore_unused_variable_warning(s);
812      const_iterator pi = ce.begin();
813      ignore_unused_variable_warning(pi);
814      pi = ce.end();
815      ignore_unused_variable_warning(pi);
816      string_type s2 = ce.str();
817      ignore_unused_variable_warning(s2);
818
819      m_string = m_sub + m_sub;
820      ignore_unused_variable_warning(m_string);
821      m_string = m_sub + m_pointer;
822      ignore_unused_variable_warning(m_string);
823      m_string = m_pointer + m_sub;
824      ignore_unused_variable_warning(m_string);
825      m_string = m_sub + m_string;
826      ignore_unused_variable_warning(m_string);
827      m_string = m_string + m_sub;
828      ignore_unused_variable_warning(m_string);
829      m_string = m_sub + m_char;
830      ignore_unused_variable_warning(m_string);
831      m_string = m_char + m_sub;
832      ignore_unused_variable_warning(m_string);
833
834#ifndef BOOST_NO_STD_LOCALE
835      m_stream << m_sub;
836      m_stream << m_cresults;
837#endif
838   }
839
840   std::basic_ostream<value_type> m_stream;
841   sub_match_type m_sub;
842   pointer_type m_pointer;
843   string_type m_string;
844   const value_type m_char;
845   match_results_type m_results;
846   const match_results_type m_cresults;
847
848   BoostRegexConcept();
849   BoostRegexConcept(const BoostRegexConcept&);
850   BoostRegexConcept& operator=(const BoostRegexConcept&);
851};
852
853}
854
855#endif
Note: See TracBrowser for help on using the repository browser.