| 264 | |
| 265 | public: |
| 266 | class Iterator |
| 267 | { |
| 268 | public: |
| 269 | using iterator_category = std::input_iterator_tag; |
| 270 | using value_type = Name; |
| 271 | using difference_type = std::ptrdiff_t; |
| 272 | using pointer = const Name *; |
| 273 | using reference = const Name &; |
| 274 | |
| 275 | const static uint32_t END_TAG = UINT32_MAX; |
| 276 | |
| 277 | Iterator(Name view, uint32_t tag) : _view(std::move(view)), _tag(tag) {} // Special for the end iterator |
| 278 | Iterator(Name view, uint32_t tag, Header *owner) : _view(std::move(view)), _tag(tag), _owner(owner) {} |
| 279 | |
| 280 | reference |
| 281 | operator*() const |
| 282 | { |
| 283 | return _view; |
| 284 | } |
| 285 | |
| 286 | pointer |
| 287 | operator->() |
| 288 | { |
| 289 | return &_view; |
| 290 | } |
| 291 | |
| 292 | // Prefix increment |
| 293 | Iterator & |
| 294 | operator++() |
| 295 | { |
| 296 | if (_tag != END_TAG) { |
| 297 | CAssert(_tag == _owner->_iterator_tag); |
| 298 | |
| 299 | _view = _owner->iterate(); |
| 300 | if (_view.empty()) { |
| 301 | _tag = END_TAG; |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | return *this; |
| 306 | } |
| 307 | |
| 308 | friend bool |
| 309 | operator==(const Iterator &a, const Iterator &b) |
| 310 | { |
| 311 | return a._tag == b._tag; |
| 312 | }; |
| 313 | |
| 314 | friend bool |
| 315 | operator!=(const Iterator &a, const Iterator &b) |
| 316 | { |
| 317 | return a._tag != b._tag; |
| 318 | }; |
| 319 | |
| 320 | static const Iterator |
| 321 | end() |
| 322 | { |
| 323 | return _end; |
no test coverage detected