fix cparser warnings
[libfirm] / include / libfirm / adt / iterator.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief   Iterators for the several collection types used in firm.
23  *          Useful for formatted and unified dumping of collections of objects.
24  * @author  Sebastian Hack
25  * @date    29.11.2004
26  * @version $Id$
27  */
28 #ifndef FIRM_ADT_ITERATOR_H
29 #define FIRM_ADT_ITERATOR_H
30
31 #include "fourcc.h"
32
33 #include "../begin.h"
34
35 /**
36  * The iterator magic word.
37  */
38 #define ITERATOR_MAGIC FOURCC('I', 'T', 'E', 'R')
39
40 /**
41  * Check, if some memory object appears to be an iterator.
42  * @param ptr Some memory.
43  * @return 1, if that memory area appears to be an iterator, 0 if not.
44  */
45 #define is_iterator(ptr) (((const iterator_t *) (ptr))->magic == ITERATOR_MAGIC)
46
47 typedef struct iterator_t {
48         unsigned magic;
49         void *(*start)(void *collection);
50         void *(*next)(void *collection, void *curr);
51         void (*finish)(void *collection, void *curr);
52 } iterator_t;
53
54 /**
55  * An iterator implementation for linked lists.
56  */
57 extern const iterator_t *list_iterator;
58
59 /**
60  * An iterator implementation for psets.
61  */
62 extern const iterator_t *pset_iterator;
63
64 #include "../end.h"
65
66 #endif