Mercurial > projects > ldc
comparison gen/utils.h @ 1228:79758fd2f48a
Added Doxygen file.
Completely seperated type and symbol generation. Should fix a lot of bugs, but is not yet 100% complete.
author | Tomas Lindquist Olsen <tomas.l.olsen gmail.com> |
---|---|
date | Wed, 15 Apr 2009 20:06:25 +0200 |
parents | |
children | ec1d9dc1d32a |
comparison
equal
deleted
inserted
replaced
1215:08f87d8cd101 | 1228:79758fd2f48a |
---|---|
1 #ifndef __LDC_GEN_UTILS_H__ | |
2 #define __LDC_GEN_UTILS_H__ | |
3 | |
4 #include "root.h" | |
5 | |
6 /// Very simple templated iterator for DMD ArrayS. | |
7 template<class C> | |
8 struct ArrayIter | |
9 { | |
10 Array& array; | |
11 size_t index; | |
12 | |
13 ArrayIter(Array& arr, size_t idx = 0) | |
14 : array(arr), index(idx) | |
15 { } | |
16 | |
17 bool done() | |
18 { | |
19 return index >= array.dim; | |
20 } | |
21 bool more() | |
22 { | |
23 return index < array.dim; | |
24 } | |
25 | |
26 C* get() | |
27 { | |
28 return static_cast<C*>(array.data[index]); | |
29 } | |
30 C* operator->() | |
31 { | |
32 return static_cast<C*>(array.data[index]); | |
33 } | |
34 | |
35 void next() | |
36 { | |
37 ++index; | |
38 } | |
39 }; | |
40 | |
41 // some aliases | |
42 typedef ArrayIter<Dsymbol> DsymbolIter; | |
43 typedef ArrayIter<FuncDeclaration> FuncDeclarationIter; | |
44 typedef ArrayIter<VarDeclaration> VarDeclarationIter; | |
45 | |
46 #endif |