Chris@16
|
1 // Boost string_algo library concept.hpp header file ---------------------------//
|
Chris@16
|
2
|
Chris@16
|
3 // Copyright Pavol Droba 2002-2003.
|
Chris@16
|
4 //
|
Chris@16
|
5 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
6 // (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
7 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8
|
Chris@16
|
9 // See http://www.boost.org/ for updates, documentation, and revision history.
|
Chris@16
|
10
|
Chris@16
|
11 #ifndef BOOST_STRING_CONCEPT_HPP
|
Chris@16
|
12 #define BOOST_STRING_CONCEPT_HPP
|
Chris@16
|
13
|
Chris@16
|
14 #include <boost/concept_check.hpp>
|
Chris@16
|
15 #include <boost/range/iterator_range_core.hpp>
|
Chris@16
|
16 #include <boost/range/begin.hpp>
|
Chris@16
|
17 #include <boost/range/end.hpp>
|
Chris@16
|
18
|
Chris@16
|
19 /*! \file
|
Chris@16
|
20 Defines concepts used in string_algo library
|
Chris@16
|
21 */
|
Chris@16
|
22
|
Chris@16
|
23 namespace boost {
|
Chris@16
|
24 namespace algorithm {
|
Chris@16
|
25
|
Chris@16
|
26 //! Finder concept
|
Chris@16
|
27 /*!
|
Chris@16
|
28 Defines the Finder concept. Finder is a functor which selects
|
Chris@16
|
29 an arbitrary part of a string. Search is performed on
|
Chris@16
|
30 the range specified by starting and ending iterators.
|
Chris@16
|
31
|
Chris@16
|
32 Result of the find operation must be convertible to iterator_range.
|
Chris@16
|
33 */
|
Chris@16
|
34 template<typename FinderT, typename IteratorT>
|
Chris@16
|
35 struct FinderConcept
|
Chris@16
|
36 {
|
Chris@16
|
37 private:
|
Chris@16
|
38 typedef iterator_range<IteratorT> range;
|
Chris@16
|
39 public:
|
Chris@16
|
40 void constraints()
|
Chris@16
|
41 {
|
Chris@16
|
42 // Operation
|
Chris@16
|
43 r=(*pF)(i,i);
|
Chris@16
|
44 }
|
Chris@16
|
45 private:
|
Chris@16
|
46 range r;
|
Chris@16
|
47 IteratorT i;
|
Chris@16
|
48 FinderT* pF;
|
Chris@16
|
49 }; // Finder_concept
|
Chris@16
|
50
|
Chris@16
|
51
|
Chris@16
|
52 //! Formatter concept
|
Chris@16
|
53 /*!
|
Chris@16
|
54 Defines the Formatter concept. Formatter is a functor, which
|
Chris@16
|
55 takes a result from a finder operation and transforms it
|
Chris@16
|
56 in a specific way.
|
Chris@16
|
57
|
Chris@16
|
58 Result must be a container supported by container_traits,
|
Chris@16
|
59 or a reference to it.
|
Chris@16
|
60 */
|
Chris@16
|
61 template<typename FormatterT, typename FinderT, typename IteratorT>
|
Chris@16
|
62 struct FormatterConcept
|
Chris@16
|
63 {
|
Chris@16
|
64 public:
|
Chris@16
|
65 void constraints()
|
Chris@16
|
66 {
|
Chris@16
|
67 // Operation
|
Chris@16
|
68 ::boost::begin((*pFo)( (*pF)(i,i) ));
|
Chris@16
|
69 ::boost::end((*pFo)( (*pF)(i,i) ));
|
Chris@16
|
70 }
|
Chris@16
|
71 private:
|
Chris@16
|
72 IteratorT i;
|
Chris@16
|
73 FinderT* pF;
|
Chris@16
|
74 FormatterT *pFo;
|
Chris@16
|
75 }; // FormatterConcept;
|
Chris@16
|
76
|
Chris@16
|
77 } // namespace algorithm
|
Chris@16
|
78 } // namespace boost
|
Chris@16
|
79
|
Chris@16
|
80
|
Chris@16
|
81
|
Chris@16
|
82
|
Chris@16
|
83 #endif // BOOST_STRING_CONCEPT_HPP
|