30#ifndef __CLAW_ITERATOR_HPP__
31#define __CLAW_ITERATOR_HPP__
41 template <
typename Category,
typename Value,
typename Iterator,
50 template <
typename Value,
typename Iterator,
typename Function>
55 typedef typename std::iterator_traits<Iterator>::difference_type
57 typedef Value value_type;
58 typedef value_type* pointer;
59 typedef value_type& reference;
60 typedef typename std::iterator_traits<Iterator>::iterator_category
70 wrapped_iterator_by_category(
const Iterator& it)
73 wrapped_iterator_by_category(
const Iterator& it,
const Function& f)
77 template <
typename C,
typename V,
typename I,
typename F>
78 wrapped_iterator_by_category(
79 const wrapped_iterator_by_category<C, V, I, F>& that)
80 : m_it(that.get_iterator())
81 , m_fun(that.get_function())
84 const Iterator& get_iterator()
const
88 const Function& get_function()
const
93 self_type& operator++()
99 self_type operator++(
int)
101 self_type tmp(*
this);
106 reference operator*()
const
110 pointer operator->()
const
112 return &m_fun(*m_it);
115 bool operator==(
const self_type& that)
const
117 return m_it == that.m_it;
119 bool operator!=(
const self_type& that)
const
121 return m_it != that.m_it;
123 bool operator==(
const Iterator& it)
const
127 bool operator!=(
const Iterator& it)
const
146 template <
typename Value,
typename Iterator,
typename Function>
151 typedef typename std::iterator_traits<Iterator>::difference_type
153 typedef Value value_type;
154 typedef value_type* pointer;
155 typedef value_type& reference;
156 typedef typename std::iterator_traits<Iterator>::iterator_category
159 typedef wrapped_iterator_by_category<std::bidirectional_iterator_tag,
160 Value, Iterator, Function>
164 wrapped_iterator_by_category()
166 wrapped_iterator_by_category(
const Iterator& it)
169 wrapped_iterator_by_category(
const Iterator& it,
const Function& f)
173 template <
typename C,
typename V,
typename I,
typename F>
174 wrapped_iterator_by_category(
175 const wrapped_iterator_by_category<C, V, I, F>& that)
176 : m_it(that.get_iterator())
177 , m_fun(that.get_function())
180 const Iterator& get_iterator()
const
184 const Function& get_function()
const
189 self_type& operator++()
195 self_type operator++(
int)
197 self_type tmp(*
this);
202 self_type& operator--()
208 self_type operator--(
int)
210 self_type tmp(*
this);
215 reference operator*()
const
219 pointer operator->()
const
221 return &m_fun(*m_it);
224 bool operator==(
const self_type& that)
const
226 return m_it == that.m_it;
228 bool operator!=(
const self_type& that)
const
230 return m_it != that.m_it;
232 bool operator==(
const Iterator& it)
const
236 bool operator!=(
const Iterator& it)
const
254 template <
typename Value,
typename Iterator,
typename Function>
259 typedef typename std::iterator_traits<Iterator>::difference_type
261 typedef Value value_type;
262 typedef value_type* pointer;
263 typedef value_type& reference;
264 typedef typename std::iterator_traits<Iterator>::iterator_category
267 typedef wrapped_iterator_by_category<std::random_access_iterator_tag,
268 Value, Iterator, Function>
272 wrapped_iterator_by_category()
274 wrapped_iterator_by_category(
const Iterator& it)
277 wrapped_iterator_by_category(
const Iterator& it,
const Function& f)
281 template <
typename V,
typename I>
282 wrapped_iterator_by_category(
283 const wrapped_iterator_by_category<std::random_access_iterator_tag, V,
288 template <
typename C,
typename V,
typename I,
typename F>
289 wrapped_iterator_by_category(
290 const wrapped_iterator_by_category<C, V, I, F>& that)
291 : m_it(that.get_iterator())
292 , m_fun(that.get_function())
295 const Iterator& get_iterator()
const
299 const Function& get_function()
const
304 self_type& operator++()
310 self_type operator++(
int)
312 self_type tmp(*
this);
317 self_type& operator--()
323 self_type operator--(
int)
325 self_type tmp(*
this);
330 reference operator*()
const
334 pointer operator->()
const
336 return &m_fun(*m_it);
339 bool operator==(
const self_type& that)
const
341 return m_it == that.m_it;
343 bool operator!=(
const self_type& that)
const
345 return m_it != that.m_it;
347 bool operator==(
const Iterator& it)
const
351 bool operator!=(
const Iterator& it)
const
355 bool operator<(
const self_type& that)
const
357 return m_it < that.m_it;
359 bool operator<=(
const self_type& that)
const
361 return m_it <= that.m_it;
363 bool operator>(
const self_type& that)
const
365 return m_it > that.m_it;
367 bool operator>=(
const self_type& that)
const
369 return m_it >= that.m_it;
372 difference_type operator-(
const self_type& that)
const
374 return m_it - that.m_it;
377 self_type& operator+=(
int n)
383 self_type operator+(
int n)
const
385 self_type result(*
this);
390 self_type& operator-=(
int n)
395 self_type operator-(
int n)
const
397 self_type result(*
this);
402 reference operator[](
int n)
404 return m_fun(m_it[n]);
416 template <
typename Value,
typename Iterator,
typename Function>
421 Value, Iterator, Function>& it)
426 template <
typename Value,
typename Iterator,
typename Function>
431 Value, Iterator, Function>& it)
448 template <
typename Value,
typename Iterator,
typename Function>
454 typename std::iterator_traits<Iterator>::iterator_category, Value,
Base class for wrapped iterators.
This class defines an iterator resulting of the appliance of a function to an effective iterator.
wrapped_iterator_by_category< typename std::iterator_traits< file_content::const_iterator >::iterator_category, constfile_content::key_type, file_content::const_iterator, const_pair_first< file_content::value_type > > iterator_type
This is the main namespace.