WIL説明書(C++)  3.0.0
FvIterator.h
[詳解]
1 // $Revision: 1.1 $
2 /*
3  @file FvIterator.h
4  @brief CFvIterator template class
5  @author FAST Corporation
6 */
7 
8 #ifndef _FVITERATOR_H_INCLUDED_
9 #define _FVITERATOR_H_INCLUDED_
10 
11 #include "FvMacros.h"
12 #include "FvDefs.h"
13 #include "FvDebug.h"
14 #include "FvErrors.h"
15 #include "FvObject.h"
16 #include "FvException.h"
17 
18 #include "FvAllocator.h"
19 
20 #include <xutility>
21 
22 #pragma pack(push,_FVCL_PACKING)
23 
24 namespace FVCL
25 {
26 
27 // /////////////////////////////////////////////////////////////////
28 // DEFINE
29 //
30 
31 // /////////////////////////////////////////////////////////////////
32 // TYPEDEF
33 //
34 
35 // /////////////////////////////////////////////////////////////////
36 // CLASS
37 //
38 template<class TYPE> class CFvIterator : public CFvObject
39 {
40 public:
42  typedef TYPE value_type;
44  typedef UINT size_type;
45  typedef TYPE* pointer;
46  typedef const TYPE* const_pointer;
47  typedef TYPE& reference;
48  typedef const TYPE& const_reference;
49 
50 protected:
52  size_type m_uiIndex;
53 
54 public:
55  // ===================================================================
56  CFvIterator( size_type uiIndex=0, CFvAllocator<TYPE>* pAllocator=NULL )
57  {
58  this->m_alloc = pAllocator;
59  this->m_uiIndex = uiIndex;
60  }
61 
62  // ===================================================================
63  CFvIterator( const CFvIterator<TYPE>& object )
64  {
65  operator = (object);
66  }
67 
68  // ===================================================================
69  virtual ~CFvIterator()
70  {
71  }
72 
73 public:
74  //
75  // METHOD
76  //
77 
78  // ===================================================================
80  {
81  return this->m_alloc;
82  }
83 
84  // ===================================================================
85  size_type GetIndex() const
86  {
87  return this->m_uiIndex;
88  }
89 
90 public:
91  // ===================================================================
93  {
94  this->m_alloc = ope.m_alloc;
95  this->m_uiIndex = ope.m_uiIndex;
96  return *this;
97  }
98 
99  // ===================================================================
100  bool operator == ( const CFvIterator<TYPE>& ope ) const
101  {
102  if( this->m_alloc != ope.m_alloc ) return false;
103  if( this->m_uiIndex != ope.m_uiIndex ) return false;
104  return true;
105  }
106 
107  // ===================================================================
108  bool operator != ( const CFvIterator<TYPE>& ope ) const
109  {
110  return (operator == (ope)) ? false : true;
111  }
112 
113  // ===================================================================
114  CFvIterator<TYPE> operator + ( difference_type iCount ) const
115  {
116  if( this->m_alloc == NULL )
118  UINT index = this->m_uiIndex + iCount;
119  if( !(index<=this->m_alloc->GetCount()) )
121  return CFvIterator<TYPE>( (UINT)index, this->m_alloc );
122  }
123 
124  // ===================================================================
125  CFvIterator<TYPE> operator + ( size_type iCount ) const
126  {
127  if( this->m_alloc == NULL )
129  UINT index = this->m_uiIndex + iCount;
130  if( !(index<=this->m_alloc->GetCount()) )
132  return CFvIterator<TYPE>( index, this->m_alloc );
133  }
134 
135  // ===================================================================
136  CFvIterator<TYPE> operator - ( difference_type iCount ) const
137  {
138  if( this->m_alloc == NULL )
140  UINT index = this->m_uiIndex - iCount;
141  if( !(index<=this->m_alloc->GetCount()) )
143  return CFvIterator<TYPE>( index, this->m_alloc );
144  }
145 
146  // ===================================================================
147  CFvIterator<TYPE> operator - ( size_type iCount ) const
148  {
149  if( this->m_alloc == NULL )
151  UINT index = this->m_uiIndex - iCount;
152  if( !(index<=this->m_alloc->GetCount()) )
154  return CFvIterator<TYPE>( index, this->m_alloc );
155  }
156 
157  // ===================================================================
159  {
160  if( this->m_alloc == NULL )
162  if( !(this->m_uiIndex < this->m_alloc->GetCount()) )
164  this->m_uiIndex++;
165  return *this;
166  }
167 
168  // ===================================================================
170  {
171  if( this->m_alloc == NULL )
173  if( !(this->m_uiIndex < this->m_alloc->GetCount()) )
175  CFvIterator<TYPE> iter( this->m_uiIndex, this->m_alloc );
176  this->m_uiIndex++;
177  return iter;
178  }
179 
180  // ===================================================================
182  {
183  if( this->m_alloc == NULL )
185  if( this->m_alloc->GetCount() == 0 )
187  if( this->m_uiIndex == 0 )
189  this->m_uiIndex--;
190  return *this;
191  }
192 
193  // ===================================================================
195  {
196  if( this->m_alloc == NULL )
198  if( this->m_alloc->GetCount() == 0 )
200  if( this->m_uiIndex == 0 )
202  CFvIterator<TYPE> iter( this->m_uiIndex, this->m_alloc );
203  this->m_uiIndex--;
204  return iter;
205  }
206 
207  // ===================================================================
208  CFvIterator<TYPE>& operator += ( difference_type iSize )
209  {
210  if( this->m_alloc == NULL )
212 
213  UINT iPos = this->m_uiIndex + iSize;
214  if( !(iPos<=this->m_alloc->GetCount()) )
216 
217  this->m_uiIndex = iPos;
218  return *this;
219  }
220 
221  // ===================================================================
222  CFvIterator<TYPE>& operator -= ( difference_type iSize )
223  {
224  if( this->m_alloc == NULL )
226 
227  UINT iPos = this->m_uiIndex - iSize;
228  if( !(iPos<=this->m_alloc->GetCount()) )
230 
231  this->m_uiIndex = iPos;
232  return *this;
233  }
234 
235  // ===================================================================
236  reference operator []( difference_type index ) const
237  {
238  if( this->m_alloc == NULL )
240  if( index < 0 )
242  return this->m_alloc->GetItem( index );
243  }
244  // ===================================================================
245  reference operator *() const
246  {
247  if( this->m_alloc == NULL )
249  return this->m_alloc->GetItem( this->m_uiIndex );
250  }
251  // ===================================================================
252  pointer operator ->() const
253  {
254  if( this->m_alloc == NULL )
256  return this->m_alloc->GetBuffer( this->m_uiIndex );
257  }
258 
259  // ===================================================================
260  operator TYPE*() const
261  {
262  if( this->m_alloc == NULL )
264  return this->m_alloc->GetBuffer( this->m_uiIndex );
265  }
266 };
267 
268 } // FVCL
269 
270 #pragma pack(pop)
271 
272 #endif // _FVITERATOR_H_INCLUDED_
INT difference_type
イテレータの差を表す型
Definition: FvIterator.h:43
TYPE & reference
要素の参照型
Definition: FvIterator.h:47
TYPE * pointer
要素のポインタ型
Definition: FvIterator.h:45
配列確保テンプレートクラスの基本クラス
Definition: FvAllocator.h:34
virtual ~CFvIterator()
デストラクタ
Definition: FvIterator.h:69
FVCLのネームスペース
Definition: EVCbasicDeclare.txt:9
CFvIterator< TYPE > & operator--()
前置形式の単項デクリメントオペレータ (-X)
Definition: FvIterator.h:181
FVCLの基底クラス
Definition: FvObject.h:23
CFvIterator(const CFvIterator< TYPE > &object)
コピーコンストラクタ
Definition: FvIterator.h:63
virtual reference GetItem(size_type uiIndex) const =0
配列の要素の取得
CFvIterator< TYPE > & operator++()
前置形式の単項インクリメントオペレータ (++X)
Definition: FvIterator.h:158
pointer operator->() const
要素へのポインタ
Definition: FvIterator.h:252
const TYPE * const_pointer
要素のポインタ型(const付き)
Definition: FvIterator.h:46
ランダムアクセスイテレータ
Definition: _STLDeclare.h:81
const INT INVALID_PARAMETER
パラメータが無効です。
Definition: FvErrors.h:24
int INT
整数型(32ビット)
Definition: FvDefs.h:36
配列走査テンプレートクラス
Definition: FvIterator.h:38
reference operator[](difference_type index) const
要素への参照
Definition: FvIterator.h:236
マクロ定義
CFvIterator< TYPE > operator-(difference_type iCount) const
減算オペレータ (-)
Definition: FvIterator.h:136
パラメータ不正例外クラス
Definition: FveBadParamException.h:18
bool operator!=(const CFvIterator< TYPE > &ope) const
比較オペレータ (!=)
Definition: FvIterator.h:108
UINT size_type
サイズ型
Definition: FvIterator.h:44
CFvAllocator< TYPE > * m_alloc
アロケータクラスのオブジェクトへのポインタ
Definition: FvIterator.h:51
TYPE value_type
要素の型
Definition: FvIterator.h:42
CFvIterator< TYPE > & operator-=(difference_type iSize)
減算代入オペレータ (-=)
Definition: FvIterator.h:222
アクセス違反例外クラス
Definition: FveBadAccessException.h:18
エラーコード定義
virtual pointer GetBuffer(size_type uiIndex=0) const =0
配列の要素へのアドレス取得
std::random_access_iterator_tag iterator_category
イテレータカテゴリ
Definition: FvIterator.h:41
const TYPE & const_reference
要素の参照型(const付き)
Definition: FvIterator.h:48
CFvIterator< TYPE > & operator=(const CFvIterator< TYPE > &ope)
代入オペレータ (=)
Definition: FvIterator.h:92
CFvAllocator< TYPE > * GetAllocator() const
配列確保クラスの取得
Definition: FvIterator.h:79
virtual size_type GetCount() const
配列の要素数の取得
Definition: FvAllocator.h:69
unsigned int UINT
整数型(32ビット)[符号なし]
Definition: FvDefs.h:37
size_type m_uiIndex
配列指標
Definition: FvIterator.h:52
size_type GetIndex() const
配列指標の取得
Definition: FvIterator.h:85
CFvObject クラスのインターフェース
CFvIterator(size_type uiIndex=0, CFvAllocator< TYPE > *pAllocator=NULL)
コンストラクタ
Definition: FvIterator.h:56
CFvIterator< TYPE > & operator+=(difference_type iSize)
加算代入オペレータ (+=)
Definition: FvIterator.h:208
const INT NOT_ALLOCATED
領域が確保されていません。
Definition: FvErrors.h:37
bool operator==(const CFvIterator< TYPE > &ope) const
比較オペレータ (==)
Definition: FvIterator.h:100
配列確保テンプレートクラスの基本クラス
reference operator*() const
要素への参照
Definition: FvIterator.h:245
変数型と定数の定義
デバッグ用関数のインターフェース
例外発行関数のインターフェース
CFvIterator< TYPE > operator+(difference_type iCount) const
加算オペレータ (+)
Definition: FvIterator.h:114

Documentation copyright © 2007 FAST Corporation. [B-001864]
Generated on 2023年11月02日(木) 10時12分53秒 for WIL説明書(C++) by doxygen 1.8.11