OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [include/] [ext/] [pb_assoc/] [detail/] [value_type_adapter/] [iterator.hpp] - Blame information for rev 17

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 17 jlechner
// -*- C++ -*-
2
 
3
// Copyright (C) 2005 Free Software Foundation, Inc.
4
//
5
// This file is part of the GNU ISO C++ Library.  This library is free
6
// software; you can redistribute it and/or modify it under the
7
// terms of the GNU General Public License as published by the
8
// Free Software Foundation; either version 2, or (at your option)
9
// any later version.
10
 
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
// GNU General Public License for more details.
15
 
16
// You should have received a copy of the GNU General Public License along
17
// with this library; see the file COPYING.  If not, write to the Free
18
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19
// USA.
20
 
21
// As a special exception, you may use this file as part of a free software
22
// library without restriction.  Specifically, if other files instantiate
23
// templates or use macros or inline functions from this file, or you compile
24
// this file and link it with other files to produce an executable, this
25
// file does not by itself cause the resulting executable to be covered by
26
// the GNU General Public License.  This exception does not however
27
// invalidate any other reasons why the executable file might be covered by
28
// the GNU General Public License.
29
 
30
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
31
 
32
// Permission to use, copy, modify, sell, and distribute this software
33
// is hereby granted without fee, provided that the above copyright
34
// notice appears in all copies, and that both that copyright notice and
35
// this permission notice appear in supporting documentation. None of
36
// the above authors, nor IBM Haifa Research Laboratories, make any
37
// representation about the suitability of this software for any
38
// purpose. It is provided "as is" without express or implied warranty.
39
 
40
/**
41
 * @file it_.hpp
42
 * Contains an it_ for an adapter of mapping levels.
43
 */
44
 
45
#define PB_ASSOC_IT_C_DEC \
46
        it_< \
47
                It0, \
48
                It1, \
49
                Has_Data, \
50
                Const>
51
 
52
#define PB_ASSOC_OIT_T_DEC \
53
        template<class OIt0, class OIt1, bool OHas_Data, bool OConst>
54
 
55
#define PB_ASSOC_OIT_C_DEC \
56
        it_< \
57
                OIt0, \
58
                OIt1, \
59
                OHas_Data, \
60
                OConst>
61
 
62
template<class It0, class It1, bool Has_Data, bool Const>
63
class it_
64
{
65
public:
66
 
67
  typedef typename it_value_type_traits_t::value_type value_type;
68
 
69
  typedef typename it_value_type_traits_t::reference reference;
70
 
71
  typedef
72
  typename it_value_type_traits_t::const_reference
73
  const_reference;
74
 
75
  typedef typename it_value_type_traits_t::pointer pointer;
76
 
77
  typedef typename it_value_type_traits_t::const_pointer const_pointer;
78
 
79
public:
80
  inline
81
  it_(It0 it0 = It0(),
82
      It0 end_it0 = It0(),
83
      It1 it1 = It1()) : m_it0(it0),
84
                         m_end_it0(end_it0),
85
                         m_it1(it1)
86
  { }
87
 
88
  inline
89
  it_(const PB_ASSOC_IT_C_DEC& r_other) : m_it0(r_other.m_it0),
90
                                          m_end_it0(r_other.m_end_it0),
91
                                          m_it1(r_other.m_it1)
92
  { }
93
 
94
  PB_ASSOC_OIT_T_DEC
95
  inline
96
  it_(const PB_ASSOC_OIT_C_DEC& r_other) : m_it0(r_other.m_it0),
97
                                           m_end_it0(r_other.m_end_it0),
98
                                           m_it1(r_other.m_it1)
99
  { }
100
 
101
  inline bool
102
  operator==(const PB_ASSOC_IT_C_DEC& r_other) const
103
  {
104
    if (m_it0 != r_other.m_it0)
105
      return (false);
106
 
107
    if (m_it0 == m_end_it0)
108
      return (true);
109
 
110
    return (m_it1 == r_other.m_it1);
111
  }
112
 
113
  inline bool
114
  operator!=(const PB_ASSOC_IT_C_DEC& r_other) const
115
  {
116
    return (!operator==(r_other));
117
  }
118
 
119
  inline PB_ASSOC_IT_C_DEC&
120
  operator++()
121
  {
122
    ++m_it1;
123
 
124
    if (m_it1 == m_it0->second.end())
125
      do
126
        {
127
          ++m_it0;
128
        }
129
      while (m_it0 != m_end_it0&&  m_it0->second.empty());
130
 
131
    if (m_it0 != m_end_it0&&  !m_it0->second.empty())
132
      m_it1 = m_it0->second.begin();
133
 
134
    return (*this);
135
  }
136
 
137
  inline PB_ASSOC_IT_C_DEC
138
  operator++(int)
139
  {
140
    PB_ASSOC_IT_C_DEC ret =* this;
141
 
142
    operator++();
143
 
144
    return (ret);
145
  }
146
 
147
  inline const_pointer
148
  operator->() const
149
  {
150
    it_value_type_traits_t::make_valid(m_value_type_holder, m_it0->first, * m_it1);
151
 
152
    return (it_value_type_traits_t::recast(m_value_type_holder));
153
  }
154
 
155
  inline pointer
156
  operator->()
157
  {
158
    // Tmp Ami PB_ASSOC_STATIC_ASSERT(non_const, !Const);
159
 
160
    it_value_type_traits_t::make_valid(m_value_type_holder, m_it0->first, * m_it1);
161
 
162
    return (it_value_type_traits_t::recast(m_value_type_holder));
163
  }
164
 
165
  inline const_reference
166
  operator*() const
167
  {
168
    return (*operator->());
169
  }
170
 
171
  inline reference
172
  operator*()
173
  {
174
    PB_ASSOC_STATIC_ASSERT(non_const, !Const);
175
 
176
    return (*operator->());
177
  }
178
 
179
public:
180
  mutable It0 m_it0;
181
  It0 m_end_it0;
182
 
183
  mutable It1 m_it1;
184
 
185
  int_to_type<Has_Data> m_has_data;
186
 
187
private:
188
  mutable typename it_value_type_traits_t::value_type_holder m_value_type_holder;
189
};
190
 
191
#undef PB_ASSOC_IT_C_DEC
192
 
193
#undef PB_ASSOC_OIT_T_DEC
194
 
195
#undef PB_ASSOC_OIT_C_DEC
196
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.