Sun, 04 Oct 2015 06:43:02 +0300
Bézier curves are now parsed correctly
#pragma once #include "ldObject.h" #include "ldDocument.h" template<typename T> class LDObjectIterator { public: LDObjectIterator (LDDocument* doc) : m_list (doc->objects()), m_i (-1) { seekTillValid(); } LDObjectIterator (const LDObjectList& objs) : m_list (objs), m_i (-1) { seekTillValid(); } bool outOfBounds() const { return m_i < 0 or m_i >= m_list.size(); } T* get() const { return (T*) m_list[m_i]; } bool isValid() const { return not outOfBounds() and get()->type() == T::SubclassType; } void seek (int i) { m_i = i; } void seekTillValid() { do ++m_i; while (not outOfBounds() and not isValid()); } void rewindTillValid() { do --m_i; while (m_i >= 0 and not isValid()); } int tell() const { return m_i; } T* operator*() const { return get(); } T* operator->() const { return get(); } void operator++() { seekTillValid(); } void operator++ (int) { seekTillValid(); } void operator--() { rewindTillValid(); } void operator-- (int) { rewindTillValid(); } private: const LDObjectList& m_list; int m_i; };