LEFT | RIGHT |
1 #ifndef ADBLOCK_PLUS_FILTER_H | 1 #pragma once |
2 #define ADBLOCK_PLUS_FILTER_H | |
3 | 2 |
4 #include <vector> | 3 #include <vector> |
5 | 4 |
6 #include "String.h" | 5 #include "String.h" |
7 #include "intrusive_ptr.h" | 6 #include "intrusive_ptr.h" |
8 #include "debug.h" | 7 #include "debug.h" |
9 | 8 |
10 class Filter : public ref_counted | 9 class Filter : public ref_counted |
11 { | 10 { |
12 protected: | 11 protected: |
13 String mText; | 12 OwnedString mText; |
14 | 13 |
15 public: | 14 public: |
16 explicit Filter(const String& text); | |
17 virtual ~Filter(); | |
18 | |
19 /* TODO | |
20 std::vector<Subscription> subscriptions; | |
21 */ | |
22 | |
23 const String GetText() const | |
24 { | |
25 return mText; | |
26 } | |
27 | |
28 enum Type | 15 enum Type |
29 { | 16 { |
30 UNKNOWN = 0, | 17 UNKNOWN = 0, |
31 INVALID = 1, | 18 INVALID = 1, |
32 COMMENT = 2, | 19 COMMENT = 2, |
33 BLOCKING = 3, | 20 BLOCKING = 3, |
34 WHITELIST = 4, | 21 WHITELIST = 4, |
35 ELEMHIDE = 5, | 22 ELEMHIDE = 5, |
36 ELEMHIDEEXCEPTION = 6, | 23 ELEMHIDEEXCEPTION = 6, |
37 CSSPROPERTY = 7, | 24 CSSPROPERTY = 7, |
38 }; | 25 }; |
39 | 26 |
40 virtual Type GetType() const = 0; | 27 explicit Filter(Type type, const String& text); |
| 28 ~Filter(); |
41 | 29 |
42 virtual String Serialize() const; | 30 Type mType; |
43 | 31 |
44 static Filter* FromText(const String& text); | 32 /* TODO |
45 static String Normalize(String& text); | 33 std::vector<Subscription> mSubscriptions; |
| 34 */ |
| 35 |
| 36 EMSCRIPTEN_KEEPALIVE const String& GetText() const |
| 37 { |
| 38 return mText; |
| 39 } |
| 40 |
| 41 EMSCRIPTEN_KEEPALIVE OwnedString Serialize() const; |
| 42 |
| 43 static EMSCRIPTEN_KEEPALIVE Filter* FromText(DependentString& text); |
46 }; | 44 }; |
47 | 45 |
48 typedef intrusive_ptr<Filter> FilterPtr; | 46 typedef intrusive_ptr<Filter> FilterPtr; |
49 | |
50 #endif | |
LEFT | RIGHT |