Crazy Eddie's GUI System  ${CEGUI_VERSION}
iterator_traits.hpp
1 // This file has been generated by Py++.
2 
3 // -*- mode:c++ -*-
4 //
5 // Header file iterator_traits.hpp
6 //
7 // Traits information about iterators for use in determining what
8 // Python methods to support for a container.
9 //
10 // Copyright (c) 2003 Raoul M. Gough
11 //
12 // Use, modification and distribution is subject to the Boost Software
13 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
14 // at http://www.boost.org/LICENSE_1_0.txt)
15 //
16 // History
17 // =======
18 // 2003/ 8/23 rmg File creation as iterator_suite.hpp
19 // 2003/ 9/12 rmg Renamed iterator_traits.hpp
20 // 2008/12/08 Roman Change indexing suite layout
21 //
22 // $Id: iterator_traits.hpp,v 1.1.2.14 2004/02/08 18:57:42 raoulgough Exp $
23 //
24 
25 #ifndef BOOST_PYTHON_INDEXING_ITERATOR_TRAITS_HPP
26 #define BOOST_PYTHON_INDEXING_ITERATOR_TRAITS_HPP
27 
28 #include <indexing_suite/suite_utils.hpp>
29 #include <indexing_suite/methods.hpp>
30 //#include <indexing_suite/workaround.hpp>
31 
32 //#include <boost/call_traits.hpp>
33 //#include <boost/type_traits.hpp>
34 #include <boost/iterator/iterator_traits.hpp>
35 #include <boost/iterator/iterator_categories.hpp>
36 
37 namespace boost { namespace python { namespace indexing {
39  // Indexing traits common base class
41 
42  template<typename Iterator>
44  {
45  private:
46  typedef ::boost::detail::iterator_traits<Iterator> std_traits;
47  typedef typename std_traits::reference reference;
48 
49  public:
50  // typedef Iterator iterator;
51  // typedef typename std_traits::value_type value_type;
52  // typedef typename std_traits::difference_type difference_type;
53 
54  BOOST_STATIC_CONSTANT(
55  bool, has_mutable_ref = is_mutable_ref<reference>::value);
56  };
57 
59  // Indexing traits for input iterators
61 
62  template<typename Iterator>
64  {
65  BOOST_STATIC_CONSTANT(
66  method_set_type,
67  supported_methods = (
68  method_iter
69  ));
70  };
71 
73  // Indexing traits for forward iterators
75 
76  template<typename Iterator>
78  : public base_iterator_traits<Iterator>
79  {
80  BOOST_STATIC_CONSTANT(
81  method_set_type,
82  supported_methods = (
83  method_len
84  | method_iter
85  ));
86  };
87 
89  // Indexing traits for bidirectional iterators
91 
92  template<typename Iterator>
94  : public forward_iterator_traits<Iterator>
95  {
97 
98  BOOST_STATIC_CONSTANT(
99  method_set_type,
100  supported_methods = (
101  base_class::supported_methods
102 
104  base_class::has_mutable_ref,
105  method_reverse
106  >::value
107  ));
108  };
109 
111  // Indexing traits for random access iterators
113 
114  template<typename Iterator>
116  : public bidirectional_iterator_traits<Iterator>
117  {
119 
120  BOOST_STATIC_CONSTANT(
121  method_set_type,
122  supported_methods = (
123  (base_class::supported_methods & ~method_iter)
124 
125  | method_getitem
126  | method_getitem_slice
127 
129  base_class::has_mutable_ref,
130  method_setitem
131  | method_setitem_slice
132  >::value
133 
134  | method_index // Assumes value is equality_comparable
135  | method_contains // Assumes value is equality_comparable
136  | method_count // Assumes value is equality_comparable
137 
139  base_class::has_mutable_ref,
140  method_sort
141  >::value // Assumes value is less_than_comparable
142 
143  ));
144  };
145 
146  namespace iterator_detail {
147  // Some meta-progamming machinery to select the right
148  // indexing::iterator_traits template on the basis of
149  // BOOST_ITERATOR_CATEGORY
150 
151  typedef char basic_iter_sizer[1];
152  typedef char forward_iter_sizer[2];
153  typedef char bidirectional_iter_sizer[3];
154  typedef char random_access_iter_sizer[4];
155 
156  basic_iter_sizer &sizer (void *);
157  forward_iter_sizer &sizer (std::forward_iterator_tag *);
158  bidirectional_iter_sizer &sizer (std::bidirectional_iterator_tag *);
159  random_access_iter_sizer &sizer (std::random_access_iterator_tag *);
160 
161  template<size_t Size> struct traits_by_size {
162  // Default implementation gives only the most basic support
163  template<typename Iterator>
164  struct traits {
166  };
167  };
168 
169  template<>
170  struct traits_by_size<sizeof(forward_iter_sizer)> {
171  template<typename Iterator>
172  struct traits {
174  };
175  };
176 
177  template<>
178  struct traits_by_size<sizeof(bidirectional_iter_sizer)> {
179  template<typename Iterator>
180  struct traits {
182  };
183  };
184 
185  template<>
186  struct traits_by_size<sizeof(random_access_iter_sizer)> {
187  template<typename Iterator>
188  struct traits {
190  };
191  };
192 
193  template<typename Iterator>
195  typedef typename ::boost::BOOST_ITERATOR_CATEGORY<Iterator>::type
196  category;
197 
198  BOOST_STATIC_CONSTANT(
199  size_t, sizer_result = sizeof (sizer (new category)));
200 
201  public:
202  typedef typename traits_by_size<sizer_result>
203  ::BOOST_NESTED_TEMPLATE traits<Iterator>::type type;
204  };
205  }
206 
207  template<typename Iterator>
209  : public iterator_detail::deduced_traits<Iterator>::type
210  {
211  };
212 } } }
213 
214 #endif // BOOST_PYTHON_INDEXING_ITERATOR_TRAITS_HPP
215 
216 
217 
Definition: iterator_traits.hpp:43
Definition: python_CEGUI.h:9
Definition: suite_utils.hpp:46
Definition: iterator_traits.hpp:63
Definition: iterator_traits.hpp:208
Definition: iterator_traits.hpp:77