添付ファイルの情報



[添付ファイル一覧] [全ページの添付ファイル一覧]

filefunclistarray_p1.diff
格納ファイル名:attach/446576656C6F702F31_66756E636C69737461727261795F70312E64696666
ページ:Develop/1
格納ファイル名:attach/446576656C6F702F31_66756E636C69737461727261795F70312E64696666
MD5ハッシュ値:908733d6fe5c0400976424dd695cbaf5
サイズ:7.3KB (7426 bytes)
Content-type:application/octet-stream
登録日時:2006/10/28 18:12:03
アクセス数:236
MD5ハッシュ値:908733d6fe5c0400976424dd695cbaf5
filefunclistarray_p1.diff
  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
Index: sakura_core/CDlgJump.cpp
===================================================================
--- sakura_core/CDlgJump.cpp	(revision 1011)
+++ sakura_core/CDlgJump.cpp	(working copy)
@@ -202,7 +202,7 @@
 void CDlgJump::SetData( void )
 {
 	CEditDoc*		pCEditDoc = (CEditDoc*)m_lParam;
-	CFuncInfoArr	cFuncInfoArr;
+	CFuncInfoArr	cFuncInfoArr( pCEditDoc );
 	int				i;
 	HWND			hwndCtrl;
 	char			szText[1024];
Index: sakura_core/CDocLineMgr.cpp
===================================================================
--- sakura_core/CDocLineMgr.cpp	(revision 1011)
+++ sakura_core/CDocLineMgr.cpp	(working copy)
@@ -2505,5 +2505,33 @@
 
 }
 
+//--------------------------------------------------------
+//	Iterator for CDocLine
+//--------------------------------------------------------
+/*!
+	increment position ++ite
+*/
+CDocLineMgr::iterator CDocLineMgr::iterator::operator++()
+{
+	if( m_current == NULL ){
+		return *this;	//	end + 1 = end
+	}
 
+	m_current = m_current->m_pNext;
+	return *this;
+}
+
+/*!
+	increment position ite++
+*/
+CDocLineMgr::iterator CDocLineMgr::iterator::operator++(int)
+{
+	if( m_current == NULL ){
+		return *this;	//	end + 1 = end
+	}
+	iterator t( *this );
+	m_current = m_current->m_pNext;
+	return t;
+}
+
 /*[EOF]*/
Index: sakura_core/CDocLineMgr.h
===================================================================
--- sakura_core/CDocLineMgr.h	(revision 1011)
+++ sakura_core/CDocLineMgr.h	(working copy)
@@ -12,6 +12,7 @@
 	Copyright (C) 2001, hor, genta
 	Copyright (C) 2002, aroka, MIK, hor
 	Copyright (C) 2003, Moca, ryoji
+	Copyright (C) 2006, genta
 
 	This source code is designed for sakura editor.
 	Please contact the copyright holder to use this code for other purpose.
@@ -23,6 +24,7 @@
 #define _CDOCLINEMGR_H_
 
 #include <windows.h>
+#include <iterator>	// 2006.10.28 genta
 #include "global.h" // 2002/2/10 aroka
 #include "CEol.h" // 2002/2/10 aroka
 class CDocLine; // 2002/2/10 aroka
@@ -188,7 +190,7 @@
 	*/
 	CDocLine*	m_pDocLineTop;
 	CDocLine*	m_pDocLineBot;
-	CDocLine*	m_pDocLineCurrent;	/* 順アクセス時の現在位置 */
+	mutable CDocLine*	m_pDocLineCurrent;	/* 順アクセス時の現在位置 */
 	int			m_nLines;		/* 全行数 */
 	int			m_nPrevReferLine;
 	CDocLine*	m_pCodePrevRefer;
@@ -200,8 +202,47 @@
 	*/
 protected:
 
+	//	Oct. 28, 2006 genta : iterator追加
+public:
+	/*!
+		CDocLineMgrの保持するデータをCDocLineMgr::m_pDocLineCurrentに
+		影響を与えることなく効率的にスキャンする.
 
+		主としてアウトライン解析(全てのデータを読む)での利用を想定.
+		そのためunidirectionalとしてある.(戻ることは出来ない)
 
+		@note データが編集されると値は無効となる.
+		無効な値に対する操作結果は保証されない.
+		(不正なアドレスにアクセスする可能性がある)
+		
+		@date 2006.10.28 genta 新規作成
+		@author genta
+	*/
+	class iterator : public std::iterator<std::forward_iterator_tag, CDocLine>{
+	public:
+		//	operator
+		iterator operator++();
+		iterator operator++(int);
+		bool operator==(const iterator& rhs)
+			{ return m_current == rhs.m_current && m_pcDocLineMgr == rhs.m_pcDocLineMgr; }
+		bool operator!=(const iterator& rhs) { return ! ( *this == rhs ); }
+		
+		//	constructor
+		iterator ( CDocLineMgr* m, CDocLine* p ) :
+			m_pcDocLineMgr( m ), m_current( p ){}
+		iterator( const iterator& c )
+			: m_pcDocLineMgr( c.m_pcDocLineMgr ), m_current( c.m_current ){}
+
+	private:
+		CDocLineMgr* m_pcDocLineMgr;
+		CDocLine*	 m_current;
+		
+	};
+
+	friend iterator;
+	iterator begin() { return iterator( this, GetDocLineTop() ); }
+	iterator end(){ return iterator( this, 0 ); }
+	iterator beginat(int l){ return iterator( this, GetLineInfo( l ) ); }
 };
 
 
Index: sakura_core/CEditView_Command.cpp
===================================================================
--- sakura_core/CEditView_Command.cpp	(revision 1011)
+++ sakura_core/CEditView_Command.cpp	(working copy)
@@ -4711,7 +4711,8 @@
 //		return TRUE;
 //	}
 
-	static CFuncInfoArr	cFuncInfoArr;
+	//	Oct. 28, 2006 genta
+	static CFuncInfoArr	cFuncInfoArr( m_pcEditDoc );
 //	int		nLine;
 //	int		nListType;
 
Index: sakura_core/CFuncInfoArr.cpp
===================================================================
--- sakura_core/CFuncInfoArr.cpp	(revision 1011)
+++ sakura_core/CFuncInfoArr.cpp	(working copy)
@@ -16,20 +16,19 @@
 #include <stdlib.h>
 #include <malloc.h>
 #include "CFuncInfoArr.h"
+#include "CEditDoc.h"	//	2006.10.28 genta
 #include "debug.h"// 2002/2/10 aroka
 
 
-/* CFuncInfoArrクラス構築 */
-CFuncInfoArr::CFuncInfoArr()
+/*! CFuncInfoArrクラス構築
+
+	@date 2006.10.18 genta 引数追加 CEditDoc
+*/
+CFuncInfoArr::CFuncInfoArr(CEditDoc* doc)
+	: m_pcEditDoc( doc ), m_nFuncInfoArrNum( 0 ), m_ppcFuncInfoArr( NULL )
 {
-	m_nFuncInfoArrNum = 0;	/* 配列要素数 */
-	m_ppcFuncInfoArr = NULL;	/* 配列 */
-	return;
 }
 
-
-
-
 /* CFuncInfoArrクラス消滅 */
 CFuncInfoArr::~CFuncInfoArr()
 {
@@ -115,5 +114,20 @@
 #endif
 }
 
+//----------------------------------------------------------
+//	Document Iterator class methods
+//----------------------------------------------------------
 
+/*!
+	Get an iterator that points the head of document data
+*/
+CFuncInfoArr::CDocIterator CFuncInfoArr::begin_data()
+{
+	return CFuncInfoArr::CDocIterator( m_pcEditDoc->m_cDocLineMgr.begin(), 1 );
+}
+
+CDocLineMgr::iterator CFuncInfoArr::end_data()
+{
+	return m_pcEditDoc->m_cDocLineMgr.end();
+}
 /*[EOF]*/
Index: sakura_core/CFuncInfoArr.h
===================================================================
--- sakura_core/CFuncInfoArr.h	(revision 1011)
+++ sakura_core/CFuncInfoArr.h	(working copy)
@@ -18,11 +18,14 @@
 #define _CFUNCINFOARR_H_
 
 #include "CFuncInfo.h"
+#include "CDocLineMgr.h"
 
+class CEditDoc;
+
 //! アウトライン解析 データ配列
 class CFuncInfoArr {
 	public:
-		CFuncInfoArr();	/* CFuncInfoArrクラス構築 */
+		CFuncInfoArr(CEditDoc*);	/* CFuncInfoArrクラス構築 */
 		~CFuncInfoArr();	/* CFuncInfoArrクラス消滅 */
 		CFuncInfo* GetAt( int );	/* 0<=の指定番号のデータを返す */
 		void AppendData( CFuncInfo* );	/* 配列の最後にデータを追加する */
@@ -37,6 +40,47 @@
 	private:
 		int			m_nFuncInfoArrNum;	/*!< 配列要素数 */
 		CFuncInfo**	m_ppcFuncInfoArr;	/*!< 配列 */
+		
+		CEditDoc*	m_pcEditDoc;	//!< Oct. 28, 2006 genta
+	
+	public:
+		/*!
+			アウトライン解析に特化したデータ読み出しiterator
+			
+			operator++で行番号のカウントも行う.
+			
+			@date 2006.10.28 genta 新規作成
+			@author genta
+		*/
+		class CDocIterator : public CDocLineMgr::iterator {
+		public:
+			typedef CDocLineMgr::iterator super;
+
+			/*!
+				次の行への移動と行番号のカウントアップ
+				
+				@note iteratorが最後の要素の末尾 end_data() を指しているときに
+				++を行ってはいけない.行うと行番号だけがカウントアップされてしまう.
+			*/
+			CDocIterator operator++() { super::operator++(); ++m_linenum; return *this; } ;
+			CDocIterator operator++(int) { CDocIterator t(*this); this->operator++(); return t; }
+
+			//	constructor
+			CDocIterator( CDocIterator& );
+			
+			CDocIterator( const CDocLineMgr::iterator& it, int num )
+				: CDocLineMgr::iterator( it ), m_linenum( num ){}
+
+			int get_line() const { return m_linenum; }
+			void reset_flag();
+			const char* c_str() { return m_current->m_pLine->;
+		private:
+			int m_linenum;	//!< 現在の行番号(1〜)
+		};
+		
+		CDocIterator begin_data();
+		CDocLineMgr::iterator end_data();
+		void AppendData( CDocLineMgr::iterator&, const char*, int, int nDepth = 0 );
 };
 
 




    


    ホーム 一覧 単語検索 最終更新 バックアップ リンク元   ヘルプ   最終更新のRSS