Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: compiled/filter/Matcher.h

Issue 29556737: Issue 5141 - Convert filter match to C++ (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Cleanup. Fixed the bindings to export what we actually need. Created Sept. 27, 2017, 3:27 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « compiled/filter/Filter.cpp ('k') | compiled/filter/Matcher.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH
4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #pragma once
19
20 #include <vector>
21
22 #include "../debug.h"
23 #include "../bindings/runtime.h"
24 #include "../StringMap.h"
25 #include "Filter.h"
26
27 class MatcherBase : public ref_counted
28 {
29 private:
30 static MatcherBase* mInstance;
31
32 public:
33 virtual ~MatcherBase()
34 {
35 }
36
37 static MatcherBase* BINDINGS_EXPORTED GetDefaultInstance()
38 {
39 return mInstance;
40 }
41 virtual void BINDINGS_EXPORTED Add(const FilterPtr&) = 0;
42 virtual void BINDINGS_EXPORTED Remove(const FilterPtr&) = 0;
43 virtual void BINDINGS_EXPORTED Clear() = 0;
44 virtual bool BINDINGS_EXPORTED HasFilter(const FilterPtr&) const = 0;
45 virtual const String& BINDINGS_EXPORTED GetKeywordForFilter(const FilterPtr& f ilter) = 0;
46 virtual Filter* BINDINGS_EXPORTED MatchesAny(const String& location,
47 int typeMask, DependentString& docDomain, bool thirdParty,
48 const String& sitekey, bool specificOnly) = 0;
49 protected:
50 virtual OwnedString FindKeyword(const FilterPtr&) = 0;
51 };
52
53 typedef intrusive_ptr<MatcherBase> MatcherPtr;
54
55 class Matcher : public MatcherBase
56 {
57 private:
58 friend class CombinedMatcher;
59 StringMap<std::vector<FilterPtr>> mFilterByKeyword;
60 StringMap<OwnedString> mKeywordByFilter;
61 int mFilterReId;
62 int mOptionsReId;
63 int mCandidatesReId;
64 public:
65 Matcher();
66 ~Matcher();
67
68 void BINDINGS_EXPORTED Add(const FilterPtr&) override;
69 void BINDINGS_EXPORTED Remove(const FilterPtr&) override;
70 void BINDINGS_EXPORTED Clear() override ;
71 bool BINDINGS_EXPORTED HasFilter(const FilterPtr&) const override;
72 const String& BINDINGS_EXPORTED GetKeywordForFilter(const FilterPtr& filter) o verride;
73 Filter* BINDINGS_EXPORTED MatchesAny(const String& location,
74 int typeMask, DependentString& docDomain, bool thirdParty,
75 const String& sitekey, bool specificOnly) override;
76 protected:
77 OwnedString FindKeyword(const FilterPtr&) override;
78 private:
79 Filter* CheckEntryMatch(const String& keyword,
80 const String& location,
81 int typeMask, DependentString& docDomain, bool thirdParty,
82 const String& sitekey, bool specificOnly);
83 };
OLDNEW
« no previous file with comments | « compiled/filter/Filter.cpp ('k') | compiled/filter/Matcher.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld