#ifndef __PROPERTY_ITERATOR_HPP__ #define __PROPERTY_ITERATOR_HPP__ #include #include namespace lisp { struct ListEntry { ListEntry(const boost::shared_ptr lisp) : lisp(lisp), used(false) {} const boost::shared_ptr lisp; bool used; }; typedef std::multimap PropertyMap; template class PropertyIterator { public: PropertyIterator() { end = i; } T* operator ->() const { return ¤tval; } T operator*() const { return currentval; } bool next() { bool res; do { if(i == end) return false; res = property_get(i->second.lisp, currentval); if(res) { i->second.used = true; current_item = i->first; } ++i; if(res) return true; } while(true); } const std::string& item() const { return current_item; } private: friend class Properties; PropertyIterator(PropertyMap::iterator begin, PropertyMap::iterator end) : i(begin), end(end) { } PropertyMap::iterator i; PropertyMap::iterator end; std::string current_item; T currentval; }; } #endif