554 |
554 |
}
|
555 |
555 |
}
|
556 |
556 |
|
|
557 |
/* Wraps a map iterator, returning the value on dereference */
|
|
558 |
template<typename _Container, typename _Iterator, typename _ValueType = typename _Iterator::value_type::second_type>
|
|
559 |
class map_value_iterator
|
|
560 |
: public std::iterator<typename _Iterator::iterator_category, _ValueType, typename _Iterator::difference_type>
|
|
561 |
{
|
|
562 |
private:
|
|
563 |
/*
|
|
564 |
* const_map_value_iterator should look like an iterator of
|
|
565 |
* const _ValueType. Unfortunately, the map const_iterator
|
|
566 |
* is actually just an iterator of const pairs, where
|
|
567 |
* _ValueType is not const, so we need to explicitly add
|
|
568 |
* const to _ValueType.
|
|
569 |
*/
|
|
570 |
typedef map_value_iterator<_Container, typename _Container::const_iterator, const typename _Container::const_iterator::value_type::second_type> const_map_value_iterator;
|
|
571 |
|
|
572 |
public:
|
|
573 |
_Iterator it;
|
|
574 |
|
|
575 |
map_value_iterator() {}
|
|
576 |
map_value_iterator(typename _Container::const_iterator it) : it(it) {}
|
|
577 |
map_value_iterator(typename _Container::iterator it) : it(it) {}
|
|
578 |
|
|
579 |
_ValueType& operator*() const { return it->second; }
|
|
580 |
_ValueType* operator->() const { return &it->second; }
|
|
581 |
map_value_iterator& operator++() { it++; return *this; }
|
|
582 |
map_value_iterator& operator++(int) { it++; return *this; }
|
|
583 |
map_value_iterator& operator--() { it--; return *this; }
|
|
584 |
map_value_iterator& operator--(int) { it--; return *this; }
|
|
585 |
bool operator==(map_value_iterator const & rhs) const { return it == rhs.it; }
|
|
586 |
bool operator!=(map_value_iterator const & rhs) const { return it != rhs.it; }
|
|
587 |
|
|
588 |
/* Support conversion to const_iterator */
|
|
589 |
operator const_map_value_iterator() const
|
|
590 |
{
|
|
591 |
return const_map_value_iterator(it);
|
|
592 |
}
|
|
593 |
};
|
|
594 |
|
557 |
595 |
} // namespace Exiv2
|
558 |
596 |
|
559 |
597 |
#endif // #ifndef TYPES_HPP_
|
560 |
|
-
|