From 79e681282e7c5e84d8d6bbd595bce455ebf4e8f1 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 17 Oct 2003 12:04:44 +0000 Subject: needed some more work to get Iterators to work in FSList svn-id: r10857 --- backends/fs/fs.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/backends/fs/fs.h b/backends/fs/fs.h index e849a57f10..e3f0c809de 100644 --- a/backends/fs/fs.h +++ b/backends/fs/fs.h @@ -146,8 +146,19 @@ public: /* * A sorted list of multiple file system nodes. E.g. the contents of a given directory. */ -class FSList : public Common::List { +class FSList : Common::List { public: + class ConstIterator { + friend class FSList; + FilesystemNode **_data; + ConstIterator(FilesystemNode **data) : _data(data) { } + public: + const FilesystemNode &operator *() const { return **_data; } + const FilesystemNode *operator->() const { return *_data; } + bool operator !=(const ConstIterator &iter) const { return _data != iter._data; } + void operator ++() { ++_data; } + }; + ~FSList() { for (int i = 0; i < _size; i++) delete _data[i]; @@ -172,6 +183,15 @@ public: } int size() const { return _size; } + + ConstIterator begin() const { + return ConstIterator(_data); + } + + ConstIterator end() const { + return ConstIterator(_data + _size); + } + }; #endif -- cgit v1.2.3