OSDN Git Service

- Use Poco::RegularExpression instead of PCRE library. (Poco::RegularExpression inter...
[winmerge-jp/winmerge-jp.git] / Src / FileFilter.h
1 /////////////////////////////////////////////////////////////////////////////
2 //    License (GPLv2+):
3 //    This program is free software; you can redistribute it and/or modify
4 //    it under the terms of the GNU General Public License as published by
5 //    the Free Software Foundation; either version 2 of the License, or
6 //    (at your option) any later version.
7 //
8 //    This program is distributed in the hope that it will be useful, but
9 //    WITHOUT ANY WARRANTY; without even the implied warranty of
10 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //    General Public License for more details.
12 //
13 //    You should have received a copy of the GNU General Public License
14 //    along with this program; if not, write to the Free Software
15 //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 /////////////////////////////////////////////////////////////////////////////
17 /** 
18  * @file  FileFilter.h
19  *
20  * @brief Declaration file for FileFilter
21  */
22 // ID line follows -- this is updated by SVN
23 // $Id$
24
25 #include <vector>
26 #include <Poco/RegularExpression.h>
27 #include "UnicodeString.h"
28
29 /**
30  * @brief FileFilter rule.
31  *
32  * Contains one filtering element definition (rule). In addition to
33  * regular expression there is boolean value for defining if rule
34  * is inclusive or exclusive. File filters have global inclusive/exclusive
35  * selection but this per-rule setting overwrites it.
36  *
37  * We are using PCRE for regular expressions and pRegExp points to compiled
38  * regular expression. pRegExpExtra contains additional information about
39  * the expression used to optimize matching.
40  */
41 struct FileFilterElement
42 {
43         Poco::RegularExpression regexp; /**< Compiled regular expression */
44         FileFilterElement(const std::string &regex, int reOpts) : regexp(regex, reOpts)
45         {
46         }
47 };
48
49 /**
50  * @brief One actual filter.
51  *
52  * For example, this might be a GNU C filter, excluding *.o files and CVS
53  * directories. That is to say, a filter is a set of file masks and
54  * directory masks. Usually FileFilter contains rules from one filter
55  * definition file. So it can be thought as filter file contents.
56  * @sa FileFilterList
57  */
58 struct FileFilter
59 {
60         bool default_include;   /**< If true, filter rules are inclusive by default */
61         String name;                    /**< Filter name (shown in UI) */
62         String description;     /**< Filter description text */
63         String fullpath;                /**< Full path to filter file */
64         std::vector<FileFilterElement*> filefilters; /**< List of rules for files */
65         std::vector<FileFilterElement*> dirfilters;  /**< List of rules for directories */
66         FileFilter() : default_include(true) { }
67         ~FileFilter();
68         
69         static void EmptyFilterList(std::vector<FileFilterElement*> *filterList);
70 };