]> https://gitweb.dealii.org/ - dealii.git/blob
f2e81e85aca60405792d70dd2ed94650e2630676
[dealii.git] /
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
7 #if !defined(BOOST_SPIRIT_ITERATOR_INPUT_ITERATOR_POLICY_MAR_16_2007_1156AM)
8 #define BOOST_SPIRIT_ITERATOR_INPUT_ITERATOR_POLICY_MAR_16_2007_1156AM
9
10 #include <boost/spirit/home/support/iterators/multi_pass_fwd.hpp>
11 #include <boost/spirit/home/support/iterators/detail/multi_pass.hpp>
12 #include <boost/detail/iterator.hpp> // for boost::detail::iterator_traits
13 #include <boost/assert.hpp>
14
15 namespace boost { namespace spirit { namespace iterator_policies
16 {
17     namespace input_iterator_is_valid_test_
18     {
19         ///////////////////////////////////////////////////////////////////////
20         template <typename Token>
21         inline bool token_is_valid(Token const& c)
22         {
23             return c ? true : false;
24         }
25     }
26
27     ///////////////////////////////////////////////////////////////////////////
28     //  class input_iterator
29     //  Implementation of the InputPolicy used by multi_pass
30     // 
31     //  The input_iterator encapsulates an input iterator of type T
32     ///////////////////////////////////////////////////////////////////////////
33     struct input_iterator
34     {
35         ///////////////////////////////////////////////////////////////////////
36         template <typename T>
37         class unique // : public detail::default_input_policy
38         {
39         private:
40             typedef
41                 typename boost::detail::iterator_traits<T>::value_type
42             result_type;
43
44         public:
45             typedef
46                 typename boost::detail::iterator_traits<T>::difference_type
47             difference_type;
48             typedef
49                 typename boost::detail::iterator_traits<T>::difference_type
50             distance_type;
51             typedef
52                 typename boost::detail::iterator_traits<T>::pointer
53             pointer;
54             typedef
55                 typename boost::detail::iterator_traits<T>::reference
56             reference;
57             typedef result_type value_type;
58
59         protected:
60             unique() {}
61             explicit unique(T x) {}
62
63             void swap(unique&) {}
64
65         public:
66             template <typename MultiPass>
67             static void destroy(MultiPass&) {}
68
69             template <typename MultiPass>
70             static typename MultiPass::reference get_input(MultiPass& mp)
71             {
72                 return *mp.shared()->input_;
73             }
74
75             template <typename MultiPass>
76             static void advance_input(MultiPass& mp)
77             {
78                 ++mp.shared()->input_;
79             }
80
81             // test, whether we reached the end of the underlying stream
82             template <typename MultiPass>
83             static bool input_at_eof(MultiPass const& mp) 
84             {
85                 static T const end_iter;
86                 return mp.shared()->input_ == end_iter;
87             }
88
89             template <typename MultiPass>
90             static bool input_is_valid(MultiPass const& mp, value_type const& t) 
91             {
92                 using namespace input_iterator_is_valid_test_;
93                 return token_is_valid(t);
94             }
95
96             // no unique data elements
97         };
98
99         ///////////////////////////////////////////////////////////////////////
100         template <typename T>
101         struct shared
102         {
103             explicit shared(T const& input) : input_(input) {}
104
105             T input_;
106         };
107     };
108
109 }}}
110
111 #endif

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.