The Pedigree Project  0.1
IteratorAdapter.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef KERNEL_UTILITIES_ITERATORADAPTER_H
21 #define KERNEL_UTILITIES_ITERATORADAPTER_H
22 
31 template <typename T, class Iterator>
33 {
34  public:
37  {
38  }
41  inline IteratorAdapter(const Iterator &x) : m_Iterator(x)
42  {
43  }
46  template <typename T2, class Iterator2>
49  {
50  }
54  {
55  }
58  {
59  }
60 
64  {
66  return *this;
67  }
70  template <typename T2, class Iterator2>
72  {
74  return *this;
75  }
80  inline bool operator==(const IteratorAdapter &x) const
81  {
82  if (m_Iterator != x.m_Iterator)
83  return false;
84  return true;
85  }
89  {
90  ++m_Iterator;
91  return *this;
92  }
96  {
97  --m_Iterator;
98  return *this;
99  }
102  inline T &operator*()
103  {
104  return reinterpret_cast<T &>(*m_Iterator);
105  }
108  {
109  return reinterpret_cast<T &>(*m_Iterator);
110  }
111 
114  inline const Iterator &__getIterator() const
115  {
116  return m_Iterator;
117  }
121  {
122  return m_Iterator;
123  }
124 
125  private:
128 };
129 
132 #endif
IteratorAdapter(const IteratorAdapter< T2, Iterator2 > &x)
IteratorAdapter & operator=(const IteratorAdapter &x)
Iterator & __getIterator()
const Iterator & __getIterator() const
IteratorAdapter(const Iterator &x)
IteratorAdapter & operator=(const IteratorAdapter< T2, Iterator2 > &x)
IteratorAdapter & operator++()
IteratorAdapter & operator--()
An iterator applicable for many data structures.
Definition: Iterator.h:43
IteratorAdapter(const IteratorAdapter &x)
bool operator==(const IteratorAdapter &x) const
IteratorAdapter reinterpret_casts an Iterators element to another type.