Debian Codegraph @

source/code/Libs/include/cereal/external/rapidxml/rapidxml_iterators.hpp

raw symbols SCIP
1 #ifndef CEREAL_RAPIDXML_ITERATORS_HPP_INCLUDED
2 #define CEREAL_RAPIDXML_ITERATORS_HPP_INCLUDED
3
4 // Copyright (C) 2006, 2009 Marcin Kalicinski
5 // Version 1.13
6 // Revision $DateTime: 2009/05/13 01:46:17 $
7
8 #include "rapidxml.hpp"
9
10 namespace cereal {
11 namespace rapidxml
12 {
13
14 //! Iterator of child nodes of xml_node
15 template<class Ch>
16 class node_iterator
17 {
18
19 public:
20
21 typedef typename xml_node<Ch> value_type;
22 typedef typename xml_node<Ch> &reference;
23 typedef typename xml_node<Ch> *pointer;
24 typedef std::ptrdiff_t difference_type;
25 typedef std::bidirectional_iterator_tag iterator_category;
26
27 node_iterator()
28 : m_node(0)
29 {
30 }
31
32 node_iterator(xml_node<Ch> *node)
33 : m_node(node->first_node())
34 {
35 }
36
37 reference operator *() const
38 {
39 assert(m_node);
40 return *m_node;
41 }
42
43 pointer operator->() const
44 {
45 assert(m_node);
46 return m_node;
47 }
48
49 node_iterator& operator++()
50 {
51 assert(m_node);
52 m_node = m_node->next_sibling();
53 return *this;
54 }
55
56 node_iterator operator++(int)
57 {
58 node_iterator tmp = *this;
59 ++this;
60 return tmp;
61 }
62
63 node_iterator& operator--()
64 {
65 assert(m_node && m_node->previous_sibling());
66 m_node = m_node->previous_sibling();
67 return *this;
68 }
69
70 node_iterator operator--(int)
71 {
72 node_iterator tmp = *this;
73 ++this;
74 return tmp;
75 }
76
77 bool operator ==(const node_iterator<Ch> &rhs)
78 {
79 return m_node == rhs.m_node;
80 }
81
82 bool operator !=(const node_iterator<Ch> &rhs)
83 {
84 return m_node != rhs.m_node;
85 }
86
87 private:
88
89 xml_node<Ch> *m_node;
90
91 };
92
93 //! Iterator of child attributes of xml_node
94 template<class Ch>
95 class attribute_iterator
96 {
97
98 public:
99
100 typedef typename xml_attribute<Ch> value_type;
101 typedef typename xml_attribute<Ch> &reference;
102 typedef typename xml_attribute<Ch> *pointer;
103 typedef std::ptrdiff_t difference_type;
104 typedef std::bidirectional_iterator_tag iterator_category;
105
106 attribute_iterator()
107 : m_attribute(0)
108 {
109 }
110
111 attribute_iterator(xml_node<Ch> *node)
112 : m_attribute(node->first_attribute())
113 {
114 }
115
116 reference operator *() const
117 {
118 assert(m_attribute);
119 return *m_attribute;
120 }
121
122 pointer operator->() const
123 {
124 assert(m_attribute);
125 return m_attribute;
126 }
127
128 attribute_iterator& operator++()
129 {
130 assert(m_attribute);
131 m_attribute = m_attribute->next_attribute();
132 return *this;
133 }
134
135 attribute_iterator operator++(int)
136 {
137 attribute_iterator tmp = *this;
138 ++this;
139 return tmp;
140 }
141
142 attribute_iterator& operator--()
143 {
144 assert(m_attribute && m_attribute->previous_attribute());
145 m_attribute = m_attribute->previous_attribute();
146 return *this;
147 }
148
149 attribute_iterator operator--(int)
150 {
151 attribute_iterator tmp = *this;
152 ++this;
153 return tmp;
154 }
155
156 bool operator ==(const attribute_iterator<Ch> &rhs)
157 {
158 return m_attribute == rhs.m_attribute;
159 }
160
161 bool operator !=(const attribute_iterator<Ch> &rhs)
162 {
163 return m_attribute != rhs.m_attribute;
164 }
165
166 private:
167
168 xml_attribute<Ch> *m_attribute;
169
170 };
171
172 }
173 } // namespace cereal
174
175 #endif