forked from WinMerge/winmerge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFileFilter.h
75 lines (69 loc) · 2.77 KB
/
FileFilter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/////////////////////////////////////////////////////////////////////////////
// License (GPLv2+):
// 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.
//
// 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.
//
// 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.
/////////////////////////////////////////////////////////////////////////////
/**
* @file FileFilter.h
*
* @brief Declaration file for FileFilter
*/
#pragma once
#include <vector>
#include <memory>
#define POCO_NO_UNWINDOWS 1
#include <Poco/RegularExpression.h>
#include "UnicodeString.h"
/**
* @brief FileFilter rule.
*
* Contains one filtering element definition (rule). In addition to
* regular expression there is boolean value for defining if rule
* is inclusive or exclusive. File filters have global inclusive/exclusive
* selection but this per-rule setting overwrites it.
*
* We are using PCRE for regular expressions and pRegExp points to compiled
* regular expression. pRegExpExtra contains additional information about
* the expression used to optimize matching.
*/
struct FileFilterElement
{
Poco::RegularExpression regexp; /**< Compiled regular expression */
FileFilterElement(const std::string ®ex, int reOpts) : regexp(regex, reOpts)
{
}
};
typedef std::shared_ptr<FileFilterElement> FileFilterElementPtr;
/**
* @brief One actual filter.
*
* For example, this might be a GNU C filter, excluding *.o files and CVS
* directories. That is to say, a filter is a set of file masks and
* directory masks. Usually FileFilter contains rules from one filter
* definition file. So it can be thought as filter file contents.
* @sa FileFilterList
*/
struct FileFilter
{
bool default_include; /**< If true, filter rules are inclusive by default */
String name; /**< Filter name (shown in UI) */
String description; /**< Filter description text */
String fullpath; /**< Full path to filter file */
std::vector<FileFilterElementPtr> filefilters; /**< List of rules for files */
std::vector<FileFilterElementPtr> dirfilters; /**< List of rules for directories */
FileFilter() : default_include(true) { }
~FileFilter();
static void EmptyFilterList(std::vector<FileFilterElementPtr> *filterList);
};
typedef std::shared_ptr<FileFilter> FileFilterPtr;