OSDN Git Service

[ 739529 ] project file & directory filters
[winmerge-jp/winmerge-jp.git] / Src / FileFilterMgr.h
1 /////////////////////////////////////////////////////////////////////////////
2 // FileFilterMgr.h : declaration file
3 //
4 // The FileFilterMgr loads a collection of named file filters from disk,
5 // and provides lookup access by name, or array access by index, to these
6 // named filters. It also provides test functions for actually using the filters.
7 /////////////////////////////////////////////////////////////////////////////
8 //    License (GPLv2+):
9 //    This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
10 //    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
11 //    You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
12 /////////////////////////////////////////////////////////////////////////////
13
14 #ifndef FileFilter_h_included
15 #define FileFilter_h_included
16
17 // Uses MFC C++ template containers
18 #ifndef __AFXTEMPL_H__
19 #include <afxtempl.h>
20 #endif
21
22 struct FileFilter;
23
24 class FileFilterMgr
25 {
26 private:
27
28 public:
29         ~FileFilterMgr();
30         // Reload filter array from specified directory (passed to CFileFind)
31         void LoadFromDirectory(LPCTSTR szPattern);
32
33         // access to array of filters
34         int GetFilterCount() const { return m_filters.GetSize(); }
35         CString GetFilterName(int i);
36         FileFilter * GetFilter(LPCTSTR szFilterName);
37
38         // methods to actually use filter
39         BOOL TestFileNameAgainstFilter(FileFilter * pFilter, LPCTSTR szFileName);
40         BOOL TestDirNameAgainstFilter(FileFilter * pFilter, LPCTSTR szDirName);
41
42
43 // Implementation methods
44 protected:
45         // Clear the list of known filters
46         void DeleteAllFilters();
47         // Load a filter from a file (if syntax is valid)
48         void LoadFilterFile(LPCTSTR szFilepath, LPCTSTR szFilename);
49
50 // Implementation data
51 private:
52         CTypedPtrArray<CPtrArray, FileFilter *> m_filters;
53 };
54
55
56 #endif // FileFilter_h_included
57