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