/Src/Dependencies/Boost/boost/spirit/home/support/iterators/detail/multi_pass.hpp

http://hadesmem.googlecode.com/ · C++ Header · 132 lines · 83 code · 31 blank · 18 comment · 0 complexity · 87857f650459e530b6f06eaf821d32c2 MD5 · raw file

  1. // Copyright (c) 2001 Daniel C. Nuffer
  2. // Copyright (c) 2001-2011 Hartmut Kaiser
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #if !defined(BOOST_SPIRIT_ITERATOR_MULTI_PASS_MAR_16_2007_1122AM)
  7. #define BOOST_SPIRIT_ITERATOR_MULTI_PASS_MAR_16_2007_1122AM
  8. #include <boost/config.hpp>
  9. #include <boost/spirit/home/support/iterators/multi_pass_fwd.hpp>
  10. #include <boost/iterator.hpp>
  11. #include <boost/mpl/bool.hpp>
  12. #include <iterator>
  13. #include <algorithm>
  14. ///////////////////////////////////////////////////////////////////////////////
  15. namespace boost { namespace spirit { namespace detail
  16. {
  17. #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  18. ///////////////////////////////////////////////////////////////////////////
  19. // Meta-function to generate a std::iterator<> base class for multi_pass.
  20. // This is used mainly to improve conformance of compilers not supporting
  21. // PTS and thus relying on inheritance to recognize an iterator.
  22. //
  23. // We are using boost::iterator<> because it offers an automatic
  24. // workaround for broken std::iterator<> implementations.
  25. ///////////////////////////////////////////////////////////////////////////
  26. template <typename T, typename InputPolicy>
  27. struct iterator_base_creator
  28. {
  29. typedef typename InputPolicy::BOOST_NESTED_TEMPLATE unique<T> input_type;
  30. typedef boost::iterator <
  31. std::forward_iterator_tag
  32. , typename input_type::value_type
  33. , typename input_type::difference_type
  34. , typename input_type::pointer
  35. , typename input_type::reference
  36. > type;
  37. };
  38. #endif
  39. ///////////////////////////////////////////////////////////////////////////
  40. // Default implementations of the different policies to be used with a
  41. // multi_pass iterator
  42. ///////////////////////////////////////////////////////////////////////////
  43. struct default_input_policy
  44. {
  45. default_input_policy() {}
  46. template <typename Functor>
  47. default_input_policy(Functor const&) {}
  48. template <typename MultiPass>
  49. static void destroy(MultiPass&) {}
  50. void swap(default_input_policy&) {}
  51. template <typename MultiPass, typename TokenType>
  52. static void advance_input(MultiPass& mp);
  53. template <typename MultiPass>
  54. static typename MultiPass::reference get_input(MultiPass& mp);
  55. template <typename MultiPass>
  56. static bool input_at_eof(MultiPass const& mp);
  57. template <typename MultiPass, typename TokenType>
  58. static bool input_is_valid(MultiPass& mp, TokenType& curtok);
  59. };
  60. struct default_ownership_policy
  61. {
  62. template <typename MultiPass>
  63. static void destroy(MultiPass&) {}
  64. void swap(default_ownership_policy&) {}
  65. template <typename MultiPass>
  66. static void clone(MultiPass&) {}
  67. template <typename MultiPass>
  68. static bool release(MultiPass& mp);
  69. template <typename MultiPass>
  70. static bool is_unique(MultiPass const& mp);
  71. };
  72. struct default_storage_policy
  73. {
  74. template <typename MultiPass>
  75. static void destroy(MultiPass&) {}
  76. void swap(default_storage_policy&) {}
  77. template <typename MultiPass>
  78. static typename MultiPass::reference dereference(MultiPass const& mp);
  79. template <typename MultiPass>
  80. static void increment(MultiPass&) {}
  81. template <typename MultiPass>
  82. static void clear_queue(MultiPass&) {}
  83. template <typename MultiPass>
  84. static bool is_eof(MultiPass const& mp);
  85. template <typename MultiPass>
  86. static bool equal_to(MultiPass const& mp, MultiPass const& x);
  87. template <typename MultiPass>
  88. static bool less_than(MultiPass const& mp, MultiPass const& x);
  89. };
  90. struct default_checking_policy
  91. {
  92. template <typename MultiPass>
  93. static void destroy(MultiPass&) {}
  94. void swap(default_checking_policy&) {}
  95. template <typename MultiPass>
  96. static void docheck(MultiPass const&) {}
  97. template <typename MultiPass>
  98. static void clear_queue(MultiPass&) {}
  99. };
  100. }}}
  101. #endif