concept.hpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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