Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 #ifndef ADBLOCKPLUS_ACTIVEFILTER_H | 1 #pragma once |
Felix Dahlke
2016/01/15 17:00:35
Nit: Words in camel cased names should be separate
Wladimir Palant
2016/01/15 20:36:15
Done.
| |
2 #define ADBLOCKPLUS_ACTIVEFILTER_H | |
3 | 2 |
4 #include <string> | 3 #include <emscripten.h> |
5 | 4 |
6 #include "tools.h" | |
7 #include "Filter.h" | 5 #include "Filter.h" |
6 #include "StringMap.h" | |
7 | |
8 #define FILTER_PROPERTY(type, name, getter, setter) \ | |
9 private:\ | |
10 type name;\ | |
11 public:\ | |
12 type EMSCRIPTEN_KEEPALIVE getter() const\ | |
13 {\ | |
14 return name;\ | |
15 }\ | |
16 void EMSCRIPTEN_KEEPALIVE setter(type value)\ | |
17 {\ | |
18 if (name != value)\ | |
19 {\ | |
20 type oldvalue = name;\ | |
21 name = value;\ | |
22 DependentString action(u"filter."_str #name);\ | |
23 EM_ASM_ARGS({\ | |
24 var filter = new (exports[Filter_mapping[$2]])($1);\ | |
25 FilterNotifier.triggerListeners(readString($0), filter, $3, $4);\ | |
26 }, &action, this, mType, value, oldvalue);\ | |
27 }\ | |
28 } | |
8 | 29 |
9 class ActiveFilter : public Filter | 30 class ActiveFilter : public Filter |
10 { | 31 { |
32 protected: | |
33 typedef StringMap<bool> DomainMap; | |
34 typedef StringSet SitekeySet; | |
35 void ParseDomains(const String& domains, String::value_type separator) const; | |
36 void AddSitekey(const String& sitekey) const; | |
37 virtual DomainMap* GetDomains() const; | |
38 virtual SitekeySet* GetSitekeys() const; | |
39 mutable std::unique_ptr<DomainMap> mDomains; | |
40 mutable std::unique_ptr<SitekeySet> mSitekeys; | |
41 private: | |
42 bool mIgnoreTrailingDot; | |
11 public: | 43 public: |
12 ActiveFilter(const std::u16string& text); | 44 explicit ActiveFilter(Type type, const String& text, bool ignoreTrailingDot); |
Felix Dahlke
2016/01/15 17:00:35
Please use the explicit keyword for single paramet
Felix Dahlke
2016/01/15 17:00:35
I'd prefer to go for std::wstring, we also use it
Wladimir Palant
2016/01/15 20:36:15
Done.
Wladimir Palant
2016/01/15 20:36:15
Done though merely as a side-effect of using embin
| |
13 FILTER_PROPERTY(bool, disabled); | 45 FILTER_PROPERTY(bool, mDisabled, GetDisabled, SetDisabled); |
14 FILTER_PROPERTY(unsigned int, hitCount); | 46 FILTER_PROPERTY(unsigned int, mHitCount, GetHitCount, SetHitCount); |
15 FILTER_PROPERTY(unsigned int, lastHit); | 47 FILTER_PROPERTY(unsigned int, mLastHit, GetLastHit, SetLastHit); |
48 bool EMSCRIPTEN_KEEPALIVE IsActiveOnDomain(DependentString& docDomain, | |
49 const String& sitekey) const; | |
50 bool EMSCRIPTEN_KEEPALIVE IsActiveOnlyOnDomain(DependentString& docDomain) con st; | |
51 bool EMSCRIPTEN_KEEPALIVE IsGeneric() const; | |
52 OwnedString EMSCRIPTEN_KEEPALIVE Serialize() const; | |
16 }; | 53 }; |
17 | |
18 #endif | |
LEFT | RIGHT |