1 /*
2  * Copyright (c) 2021-2023, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef VARIABLE_INDEX_ITERATOR_H
9 #define VARIABLE_INDEX_ITERATOR_H
10 
11 #include <stdbool.h>
12 
13 #include "variable_index.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 /**
20  * \brief An iterator for accessing variable_info
21  *
22  * Used for iterating over in-use entries held by the associated
23  * variable_index.
24  */
25 struct variable_index_iterator {
26 	const struct variable_index *variable_index;
27 	size_t current_pos;
28 };
29 
30 /**
31  * @brief      Initializes an iterator to the first position
32  *
33  * @param[in]  iter The iterator
34  * @param[in]  variable_index The associated variable index
35   */
36 void variable_index_iterator_first(struct variable_index_iterator *iter,
37 				   const struct variable_index *variable_index);
38 
39 /**
40  * @brief      Check if iterated beyond last entry
41  *
42  * @param[in]  iter The iterator
43  *
44  * @return     True if iterating is done
45  */
46 bool variable_index_iterator_is_done(const struct variable_index_iterator *iter);
47 
48 /**
49  * @brief      Return variable info for the current position
50  *
51  * @param[in]  iter The iterator
52  *
53  * @return     Pointer to variable_info or NULL
54  */
55 struct variable_info *variable_index_iterator_current(const struct variable_index_iterator *iter);
56 
57 /**
58  * @brief      Iterate to next position
59  *
60  * @param[in]  iter The iterator
61  */
62 void variable_index_iterator_next(struct variable_index_iterator *iter);
63 
64 #ifdef __cplusplus
65 }
66 #endif
67 
68 #endif /* VARIABLE_INDEX_ITERATOR_H */
69