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