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