00001 #ifndef FAITH__READDIR_H
00002 #define FAITH__READDIR_H
00003
00004 #include <faith/string.h>
00005
00006 namespace Faith
00007 {
00008
00012 class FAITH_TOOLS_EXPORT Dir
00013 {
00014 struct DirPrivate;
00015 DirPrivate *d;
00016
00017 public:
00018
00019 class FAITH_TOOLS_EXPORT Iterator
00020 {
00021 const Faith::Dir *dir;
00022 const Faith::String *it;
00023 friend class Dir;
00024 Iterator(const Faith::Dir *dir, const Faith::String *it);
00025
00026 public:
00027 typedef std::forward_iterator_tag iterator_category;
00028 typedef Faith::String value_type;
00029 typedef ptrdiff_t difference_type;
00030 typedef Faith::String* pointer;
00031 typedef Faith::String& reference;
00032
00033 Iterator(const Iterator &i);
00034 Iterator();
00035 ~Iterator();
00036
00037 Iterator &operator++();
00038 Iterator operator++(int);
00039
00040 bool operator==(const Iterator &i) const;
00041 bool operator!=(const Iterator &i) const { return !operator==(i); }
00042
00043 Iterator &operator=(const Iterator &i);
00044
00049 String name() const;
00050
00051 String operator*() const { return name(); }
00052 };
00053
00054 Dir();
00055 Dir(const String &dir);
00056
00057 ~Dir();
00058
00065 bool open(const String &dir);
00066
00071 void close();
00072
00077 bool isReadable() const;
00078
00079 Dir::Iterator begin() const;
00080 Dir::Iterator end() const;
00081
00082 private:
00083 void getFiles();
00084 };
00085
00086
00087 }
00088
00089 #endif