Commit | Line | Data |
---|---|---|
e5250216 | 1 | /* Iterator of varobj. |
42a4f53d | 2 | Copyright (C) 2013-2019 Free Software Foundation, Inc. |
e5250216 YQ |
3 | |
4 | This program is free software; you can redistribute it and/or modify | |
5 | it under the terms of the GNU General Public License as published by | |
6 | the Free Software Foundation; either version 3 of the License, or | |
7 | (at your option) any later version. | |
8 | ||
9 | This program is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | GNU General Public License for more details. | |
13 | ||
14 | You should have received a copy of the GNU General Public License | |
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
16 | ||
1a5c2598 TT |
17 | #ifndef VAROBJ_ITER_H |
18 | #define VAROBJ_ITER_H | |
19 | ||
827f100c YQ |
20 | /* A node or item of varobj, composed of the name and the value. */ |
21 | ||
22 | typedef struct varobj_item | |
23 | { | |
24 | /* Name of this item. */ | |
2f408ecb | 25 | std::string name; |
e5250216 | 26 | |
827f100c YQ |
27 | /* Value of this item. */ |
28 | struct value *value; | |
29 | } varobj_item; | |
30 | ||
31 | struct varobj_iter_ops; | |
e5250216 YQ |
32 | |
33 | /* A dynamic varobj iterator "class". */ | |
34 | ||
35 | struct varobj_iter | |
36 | { | |
37 | /* The 'vtable'. */ | |
38 | const struct varobj_iter_ops *ops; | |
39 | ||
40 | /* The varobj this iterator is listing children for. */ | |
41 | struct varobj *var; | |
42 | ||
43 | /* The next raw index we will try to check is available. If it is | |
44 | equal to number_of_children, then we've already iterated the | |
45 | whole set. */ | |
46 | int next_raw_index; | |
47 | }; | |
48 | ||
49 | /* The vtable of the varobj iterator class. */ | |
50 | ||
51 | struct varobj_iter_ops | |
52 | { | |
53 | /* Destructor. Releases everything from SELF (but not SELF | |
54 | itself). */ | |
55 | void (*dtor) (struct varobj_iter *self); | |
56 | ||
57 | /* Returns the next object or NULL if it has reached the end. */ | |
58 | varobj_item *(*next) (struct varobj_iter *self); | |
59 | }; | |
60 | ||
61 | /* Returns the next varobj or NULL if it has reached the end. */ | |
62 | ||
63 | #define varobj_iter_next(ITER) (ITER)->ops->next (ITER) | |
64 | ||
65 | /* Delete a varobj_iter object. */ | |
66 | ||
67 | #define varobj_iter_delete(ITER) \ | |
68 | do \ | |
69 | { \ | |
70 | if ((ITER) != NULL) \ | |
71 | { \ | |
72 | (ITER)->ops->dtor (ITER); \ | |
38768751 | 73 | xfree (ITER); \ |
e5250216 YQ |
74 | } \ |
75 | } while (0) | |
1a5c2598 TT |
76 | |
77 | #endif /* VAROBJ_ITER_H */ |