Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
Directory.h
1 /*
2  * Directory class interface
3  *
4  * This file is part of OTAWA
5  * Copyright (c) 2005-12, IRIT UPS.
6  *
7  * OTAWA is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * OTAWA is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OTAWA; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 #ifndef ELM_SYS_DIRECTORY_H
22 #define ELM_SYS_DIRECTORY_H
23 
24 #include <elm/PreIterator.h>
25 #include <elm/sys/FileItem.h>
26 
27 namespace elm { namespace sys {
28 
29 // File class
30 class Directory: public FileItem {
31  friend class FileItem;
32  Directory(Path path, ino_t inode);
33 public:
34 
36 
37  // Children iterator
38  class Iter {
39  public:
41 
42  Iter(LockPtr<Directory> directory);
43  ~Iter(void);
44  bool ended(void) const;
45  t item(void) const;
46  void next(void);
47  bool equals(const Iter& i) const;
48 
49  inline operator bool() const { return !ended(); }
50  inline operator t() const { return item(); }
51  inline t operator*() const { return item(); }
52  inline t operator->() const { return item(); }
53  inline Iter& operator++() { next(); return *this; }
54  inline void operator++(int) { next(); }
55  inline bool operator==(const Iter& i) const { return equals(i); }
56  inline bool operator!=(const Iter& i) const { return !equals(i); }
57 
58  private:
59  Path path;
60  void *dir;
61  LockPtr<FileItem> file;
62  void go(void);
63  };
64 
65  LockPtr<Directory> toDirectory(void) override;
66 };
67 
68 } } // elm::system
69 
70 #endif // ELM_SYS_DIRECTORY_H
71 
elm::sys::Directory::Iter
Definition: Directory.h:38
elm::sys::Directory::Iter::operator++
void operator++(int)
Definition: Directory.h:54
elm::sys::Directory::Iter::Iter
Iter(LockPtr< Directory > directory)
Definition: system_Directory.cpp:112
elm::sys::Path
Definition: Path.h:33
elm::sys::Directory::Iter::operator*
t operator*() const
Definition: Directory.h:51
elm::sys::Directory::Iter::item
t item(void) const
Definition: system_Directory.cpp:137
bool
elm::sys::Directory::Iter::operator->
t operator->() const
Definition: Directory.h:52
elm::sys::Directory
Definition: Directory.h:30
elm::sys::FileItem::path
Path & path()
Definition: system_FileItem.cpp:175
elm::sys::Directory::Iter::t
LockPtr< FileItem > t
Definition: Directory.h:40
elm::sys::Directory::make
static LockPtr< Directory > make(Path path)
Definition: system_Directory.cpp:47
elm
Definition: adapter.h:26
elm::sys::Directory::Iter::operator!=
bool operator!=(const Iter &i) const
Definition: Directory.h:56
elm::sys::Directory::Iter::operator++
Iter & operator++()
Definition: Directory.h:53
elm::sys::Directory::Iter::equals
bool equals(const Iter &i) const
Definition: system_Directory.cpp:150
elm::LockPtr
Definition: LockPtr.h:40
elm::sys::Directory::Iter::~Iter
~Iter(void)
Definition: system_Directory.cpp:123
elm::sys::FileItem
Definition: FileItem.h:36
elm::sys::Directory::Iter::next
void next(void)
Definition: system_Directory.cpp:145
elm::sys::Directory::toDirectory
LockPtr< Directory > toDirectory(void) override
Definition: system_Directory.cpp:76
elm::sys::Directory::Iter::ended
bool ended(void) const
Definition: system_Directory.cpp:130
elm::sys::Directory::Iter::operator==
bool operator==(const Iter &i) const
Definition: Directory.h:55