2 Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 * Neither the name of Intel Corporation nor the names of its
14 contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 \brief Iterator of Variable tables list used by the runtime library
35 #ifndef OFFLOAD_ITERATOR_H_INCLUDED
36 #define OFFLOAD_ITERATOR_H_INCLUDED
39 #include "offload_table.h"
41 // The following class is for iteration over var table.
42 // It was extracted and moved to this offload_iterator.h file from offload_table.h
43 // to solve the problem with compiling with VS 2010. The problem was in incompatibility
44 // of STL objects in VS 2010 with ones in later VS versions.
46 // var table list iterator
47 class Iterator
: public std::iterator
<std::input_iterator_tag
,
50 Iterator() : m_node(0), m_entry(0) {}
52 explicit Iterator(TableList
<VarTable
>::Node
*node
) {
56 Iterator
& operator++() {
59 while (m_entry
->name
== 0) {
62 if (m_entry
->name
== reinterpret_cast<const char*>(-1)) {
63 new_node(m_node
->next
);
69 bool operator==(const Iterator
&other
) const {
70 return m_entry
== other
.m_entry
;
73 bool operator!=(const Iterator
&other
) const {
74 return m_entry
!= other
.m_entry
;
77 const VarTable::Entry
* operator*() const {
82 void new_node(TableList
<VarTable
>::Node
*node
) {
86 m_entry
= m_node
->table
.entries
;
87 while (m_entry
->name
== 0) {
90 if (m_entry
->name
!= reinterpret_cast<const char*>(-1)) {
93 m_node
= m_node
->next
;
99 TableList
<VarTable
>::Node
*m_node
;
100 const VarTable::Entry
*m_entry
;
103 #endif // OFFLOAD_ITERATOR_H_INCLUDED