concept.hpp 2.3 KB

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