~thomir-deactivatedaccount/cegui/fix-build

« back to all changes in this revision

Viewing changes to cegui/src/ScriptingModules/PythonScriptModule/bindings/output/CEGUI/indexing_suite/proxy_iterator.hpp

  • Committer: Thomi Richards
  • Date: 2013-02-06 22:13:36 UTC
  • Revision ID: thomi.richards@canonical.com-20130206221336-rsmud4k50g6nzv50
InitialĀ codeĀ import.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// This file has been generated by Py++.
 
2
 
 
3
 
 
4
// Header file proxy_iterator.hpp
 
5
//
 
6
// Copyright (c) 2003 Raoul M. Gough
 
7
//
 
8
// Use, modification and distribution is subject to the Boost Software
 
9
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
 
10
// at http://www.boost.org/LICENSE_1_0.txt)
 
11
//
 
12
// History
 
13
// =======
 
14
// 2003/10/ 8   rmg     File creation
 
15
// 2008/12/08   Roman   Change indexing suite layout
 
16
//
 
17
// $Id: proxy_iterator.hpp,v 1.1.2.8 2003/12/05 17:36:14 raoulgough Exp $
 
18
//
 
19
 
 
20
#ifndef BOOST_PYTHON_INDEXING_PROXY_ITERATOR_HPP
 
21
#define BOOST_PYTHON_INDEXING_PROXY_ITERATOR_HPP
 
22
 
 
23
#include <iterator>
 
24
#include <boost/config.hpp>
 
25
#include <boost/iterator.hpp>
 
26
#include <boost/detail/workaround.hpp>
 
27
 
 
28
namespace boost { namespace python { namespace indexing {
 
29
 
 
30
  template <class ContainerProxy, typename ElementProxy, typename Traits,
 
31
      typename Size, typename Iter>
 
32
  class proxy_iterator
 
33
    : public boost::iterator<
 
34
          std::random_access_iterator_tag,
 
35
          ElementProxy,
 
36
          typename Traits::difference_type,
 
37
          ElementProxy *,
 
38
          ElementProxy // Already has reference semantics
 
39
      >
 
40
  {
 
41
#if !defined (BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
 
42
    template<class C, class H, class G> friend class container_proxy;
 
43
#endif
 
44
 
 
45
    typedef boost::iterator<
 
46
        std::random_access_iterator_tag,
 
47
        ElementProxy,
 
48
        typename Traits::difference_type,
 
49
        ElementProxy *,
 
50
        ElementProxy
 
51
    > base_type;
 
52
 
 
53
  public:
 
54
    typedef ContainerProxy container_proxy_type;
 
55
 
 
56
    typedef Iter raw_iterator;
 
57
    typedef Traits raw_iterator_traits;
 
58
    typedef Size size_type;
 
59
    typedef typename base_type::value_type value_type;
 
60
    typedef typename base_type::difference_type difference_type;
 
61
 
 
62
    typedef value_type *pointer;
 
63
    typedef value_type reference; // Already has reference semantics
 
64
 
 
65
    proxy_iterator (container_proxy_type *p, size_type i)
 
66
      : ptr (p), index (i)
 
67
    {
 
68
    }
 
69
 
 
70
    proxy_iterator (container_proxy_type *p, raw_iterator iter)
 
71
      : ptr (p), index (iter - p->raw_container().begin())
 
72
    {
 
73
    }
 
74
 
 
75
    reference operator*() const { return ptr->at(index); }
 
76
    pointer operator->() const { return &ptr->at(index); }
 
77
    reference operator[](size_type s) { return ptr->at (index + s); }
 
78
 
 
79
    proxy_iterator &operator++ () { ++index; return *this; }
 
80
    proxy_iterator &operator+= (size_type s) { index += s; return *this; }
 
81
 
 
82
    proxy_iterator &operator-- () { --index; return *this; }
 
83
 
 
84
    proxy_iterator operator++ (int) {
 
85
      proxy_iterator temp(*this);
 
86
      ++index;
 
87
      return temp;
 
88
    }
 
89
 
 
90
    proxy_iterator operator-- (int) {
 
91
      proxy_iterator temp(*this);
 
92
      --index;
 
93
      return temp;
 
94
    }
 
95
 
 
96
    proxy_iterator &operator-= (size_type s) { index -= s; return *this; }
 
97
 
 
98
    proxy_iterator operator+ (size_type s) const {
 
99
      return proxy_iterator(*this) += s;
 
100
    }
 
101
 
 
102
    proxy_iterator operator- (size_type s) const {
 
103
      return proxy_iterator(*this) -= s;
 
104
    }
 
105
 
 
106
    difference_type operator- (proxy_iterator i) const {
 
107
      return index - i.index;
 
108
    }
 
109
 
 
110
    bool operator== (proxy_iterator const &other) const {
 
111
      return (ptr == other.ptr) && (index == other.index);
 
112
    }
 
113
 
 
114
    bool operator!= (proxy_iterator const &other) const {
 
115
      return !(*this == other);
 
116
    }
 
117
 
 
118
    bool operator< (proxy_iterator const &other) const {
 
119
      return index < other.index;
 
120
    }
 
121
 
 
122
    bool operator<= (proxy_iterator const &other) const {
 
123
      return index <= other.index;
 
124
    }
 
125
 
 
126
    bool operator> (proxy_iterator const &other) const {
 
127
      return index > other.index;
 
128
    }
 
129
 
 
130
    bool operator>= (proxy_iterator const &other) const {
 
131
      return index >= other.index;
 
132
    }
 
133
 
 
134
    void iter_swap (proxy_iterator const &other) const {
 
135
      ptr->swap_elements (index, other.index);
 
136
    }
 
137
 
 
138
    //  public:
 
139
    // Extensions to the normal iterator interface
 
140
    //    void replace (value_type const &copy) { ptr->replace (index, copy); }
 
141
 
 
142
#if defined (BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
 
143
    // Can't declare container_proxy as friend, so make data public
 
144
  public:
 
145
#else
 
146
  private:
 
147
#endif
 
148
    container_proxy_type *ptr;
 
149
    size_type index;
 
150
  };
 
151
} } }
 
152
 
 
153
#if !BOOST_WORKAROUND (BOOST_MSVC, == 1300)
 
154
// MSVC7.0 can't decide between this and the unspecialized version
 
155
namespace std {
 
156
  template <class C, typename E, typename T, typename S, typename I>
 
157
  void iter_swap(
 
158
      boost::python::indexing::proxy_iterator<C, E, T, S, I> const &first,
 
159
      boost::python::indexing::proxy_iterator<C, E, T, S, I> const &second)
 
160
  {
 
161
    first.iter_swap (second);
 
162
  }
 
163
}
 
164
#endif
 
165
 
 
166
#endif // BOOST_PYTHON_INDEXING_PROXY_ITERATOR_HPP
 
167
 
 
168
 
 
169