- class Elf_Sym_Iter {
- public:
- typedef ptrdiff_t difference_type;
- typedef const Elf_Sym value_type;
- typedef std::random_access_iterator_tag iterator_category;
- typedef value_type &reference;
- typedef value_type *pointer;
-
- /// \brief Default construct iterator.
- Elf_Sym_Iter() : EntitySize(0), Current(0, false) {}
- Elf_Sym_Iter(uintX_t EntSize, const char *Start, bool IsDynamic)
- : EntitySize(EntSize), Current(Start, IsDynamic) {}
-
- reference operator*() {
- assert(Current.getPointer() &&
- "Attempted to dereference an invalid iterator!");
- return *reinterpret_cast<pointer>(Current.getPointer());
- }
-
- pointer operator->() {
- assert(Current.getPointer() &&
- "Attempted to dereference an invalid iterator!");
- return reinterpret_cast<pointer>(Current.getPointer());
- }
-
- bool operator==(const Elf_Sym_Iter &Other) {
- return Current == Other.Current;
- }
-
- bool operator!=(const Elf_Sym_Iter &Other) { return !(*this == Other); }
-
- Elf_Sym_Iter &operator++() {
- assert(Current.getPointer() &&
- "Attempted to increment an invalid iterator!");
- Current.setPointer(Current.getPointer() + EntitySize);
- return *this;
- }
-
- Elf_Sym_Iter operator++(int) {
- Elf_Sym_Iter Tmp = *this;
- ++*this;
- return Tmp;
- }
-
- Elf_Sym_Iter operator+(difference_type Dist) {
- assert(Current.getPointer() &&
- "Attempted to increment an invalid iterator!");
- Current.setPointer(Current.getPointer() + EntitySize * Dist);
- return *this;
- }
-
- Elf_Sym_Iter &operator=(const Elf_Sym_Iter &Other) {
- EntitySize = Other.EntitySize;
- Current = Other.Current;
- return *this;
- }
-
- difference_type operator-(const Elf_Sym_Iter &Other) const {
- assert(EntitySize == Other.EntitySize &&
- "Subtracting iterators of different EntitySize!");
- return (Current.getPointer() - Other.Current.getPointer()) / EntitySize;
- }
-
- const char *get() const { return Current.getPointer(); }
-
- bool isDynamic() const { return Current.getInt(); }
-
- uintX_t getEntSize() const { return EntitySize; }
-
- private:
- uintX_t EntitySize;
- PointerIntPair<const char *, 1, bool,
- ArchivePointerTypeTraits<const char> > Current;
- };