1
// TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2018-2019 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 class CGitLogListBase
;
26 std::vector
<std::wregex
> m_patterns
;
28 /// sub-string matching info
38 /// sub-strings to find; normalized to lower case
39 std::wstring subString
;
41 /// depending on the presense of a prefix, indicate
42 /// how the sub-string match / mismatch gets combined
43 /// with the current match result
46 /// index within @ref subStringConditions of the
47 /// next condition with prefix==or. 0, if no such
48 /// condition follows.
52 /// list of sub-strings to find; normalized to lower case
53 std::vector
<SCondition
> subStringConditions
;
55 // construction utility
56 void AddSubString(CString token
, Prefix prefix
);
58 /// if false, normalize all strings to lower case before comparing them
59 bool m_bCaseSensitive
;
61 /// attribute selector
62 /// (i.e. what members of GitRevLoglist shall be used for comparison)
63 DWORD m_dwAttributeSelector
;
65 /// negate pattern matching result
69 /// temp / scratch objects to minimize the number memory
70 /// allocation operations
71 mutable std::wstring scratch
;
73 /// filter utiltiy method
74 bool Match(std::wstring
& text
) const;
76 inline bool CalculateFinalResult(bool result
) const { return result
^ m_bNegate
; }
81 CFilterHelper(const CFilterHelper
& rhs
);
82 CFilterHelper(const CString
& filter
, bool filterWithRegex
, DWORD selectedFilter
, bool caseSensitive
);
83 virtual ~CFilterHelper();
85 /// returns a vector with all the ranges where a match was found.
86 void GetMatchRanges(std::vector
<CHARRANGE
>& ranges
, CString text
, int offset
) const;
88 /// assignment operator
89 CFilterHelper
& operator=(const CFilterHelper
& rhs
);
91 /// compare filter specs
92 bool operator==(const CFilterHelper
& rhs
) const;
93 bool operator!=(const CFilterHelper
& rhs
) const;
95 /// returns true if there's something to filter for
96 inline bool IsFilterActive() const { return !(m_patterns
.empty() && subStringConditions
.empty()); }
98 /// called to parse a (potentially incorrect) regex spec
99 bool ValidateRegexp(const CString
& regexp_str
, std::vector
<std::wregex
>& patterns
);
101 inline DWORD
GetSelectedFilters() const { return m_dwAttributeSelector
; }