xoreos  0.0.5
filelist.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos 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 xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef COMMON_FILELIST_H
26 #define COMMON_FILELIST_H
27 
28 #include <list>
29 
30 #include "src/common/ustring.h"
31 
32 namespace Common {
33 
35 class FileList {
36 public:
37  typedef std::list<UString>::const_iterator const_iterator;
38 
39  FileList();
40  FileList(const FileList &list);
42  FileList(const UString &directory, int recurseDepth = 0);
43  ~FileList();
44 
45  FileList &operator=(const FileList &list);
46  FileList &operator+=(const FileList &list);
47 
49  void clear();
50 
52  bool empty() const;
54  size_t size() const;
55 
57  void sort(bool caseInsensitive);
58 
63  void relativize(const Common::UString &basePath);
64 
66  const_iterator begin() const;
68  const_iterator end() const;
69 
78  bool addDirectory(const UString &directory, int recurseDepth = 0);
79 
86  bool addSubDirectories(const UString &directory);
87 
95  bool getSubList(const UString &str, bool caseInsensitive, FileList &subList) const;
96 
104  bool getSubListGlob(const UString &glob, bool caseInsensitive, FileList &subList) const;
105 
112  bool contains(const UString &str, bool caseInsensitive) const;
113 
120  bool containsGlob(const UString &glob, bool caseInsensitive) const;
121 
129  UString findFirst(const UString &str, bool caseInsensitive) const;
130 
138  UString findFirstGlob(const UString &glob, bool caseInsensitive) const;
139 
140 private:
141  typedef std::list<UString> Files;
142 
144 };
145 
146 } // End of namespace Common
147 
148 #endif // COMMON_FILELIST_H
bool addSubDirectories(const UString &directory)
Add subdirectories of a directory to the list.
Definition: filelist.cpp:131
FileList & operator+=(const FileList &list)
Definition: filelist.cpp:56
Definition: 2dafile.h:39
A class holding an UTF-8 string.
Definition: ustring.h:48
std::list< UString >::const_iterator const_iterator
Definition: filelist.h:37
std::list< UString > Files
Definition: filelist.h:141
UString findFirst(const UString &str, bool caseInsensitive) const
Find the first file ending with the given string.
Definition: filelist.cpp:193
FileList & operator=(const FileList &list)
Definition: filelist.cpp:50
size_t size() const
Return the number of files in the list.
Definition: filelist.cpp:70
void relativize(const Common::UString &basePath)
Express all files in this archive as relative to the given base path.
Definition: filelist.cpp:81
Unicode string handling.
bool getSubList(const UString &str, bool caseInsensitive, FileList &subList) const
Add files ending with the given string into another FileList.
Definition: filelist.cpp:149
UString findFirstGlob(const UString &glob, bool caseInsensitive) const
Find the first file matching the given regex.
Definition: filelist.cpp:207
bool empty() const
Is the list empty?
Definition: filelist.cpp:66
A list of files.
Definition: filelist.h:35
const_iterator begin() const
Return a const_iterator pointing to the beginning of the list.
Definition: filelist.cpp:94
bool addDirectory(const UString &directory, int recurseDepth=0)
Add a directory to the list.
Definition: filelist.cpp:102
void clear()
Clear the list.
Definition: filelist.cpp:62
void sort(bool caseInsensitive)
Sort this list alphabetically.
Definition: filelist.cpp:74
bool containsGlob(const UString &glob, bool caseInsensitive) const
Does the list contain at least one file matching the given regex?
Definition: filelist.cpp:189
bool getSubListGlob(const UString &glob, bool caseInsensitive, FileList &subList) const
Add files matching the given regex into another FileList.
Definition: filelist.cpp:167
const_iterator end() const
Return a const_iterator pointing past the end of the list.
Definition: filelist.cpp:98
bool contains(const UString &str, bool caseInsensitive) const
Does the list contain at least one file ending with the given string?
Definition: filelist.cpp:185