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

Delta Between Two Patch Sets: compiled/Filter.h

Issue 29333474: Issue 4125 - [emscripten] Convert filter classes to C++ (Closed)
Left Patch Set: Using embind Created Jan. 15, 2016, 8:44 p.m.
Right Patch Set: Addressed comments from Patch Set 28 Created March 21, 2017, 10:04 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « compiled/ElemHideFilter.cpp ('k') | compiled/Filter.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
8 class Filter; 5 #include "String.h"
6 #include "intrusive_ptr.h"
7 #include "debug.h"
9 8
10 typedef std::shared_ptr<Filter> FilterPtr; 9 class Filter : public ref_counted
11
12 class Filter
13 { 10 {
14 private: 11 protected:
15 std::wstring text; 12 OwnedString mText;
16 13
17 public: 14 public:
18 explicit Filter(const std::wstring& text); 15 enum Type
16 {
17 UNKNOWN = 0,
18 INVALID = 1,
19 COMMENT = 2,
20 BLOCKING = 3,
21 WHITELIST = 4,
22 ELEMHIDE = 5,
23 ELEMHIDEEXCEPTION = 6,
24 CSSPROPERTY = 7,
25 };
26
27 explicit Filter(Type type, const String& text);
28 ~Filter();
29
30 Type mType;
19 31
20 /* TODO 32 /* TODO
21 std::vector<Subscription> subscriptions; 33 std::vector<Subscription> mSubscriptions;
22 */ 34 */
23 35
24 const std::wstring GetText() const 36 EMSCRIPTEN_KEEPALIVE const String& GetText() const
25 { 37 {
26 return text; 38 return mText;
27 } 39 }
28 40
29 enum Type 41 EMSCRIPTEN_KEEPALIVE OwnedString Serialize() const;
30 {
31 UNKNOWN,
32 INVALID,
33 COMMENT,
34 BLOCKING,
35 WHITELIST,
36 ELEMHIDE,
37 ELEMHIDEEXCEPTION,
38 CSSPROPERTY,
39 };
40 42
41 virtual Type GetType() const = 0; 43 static EMSCRIPTEN_KEEPALIVE Filter* FromText(DependentString& text);
42
43 virtual const std::wstring Serialize();
44
45 static FilterPtr FromText(const std::wstring& text);
46 static const std::wstring Normalize(const std::wstring& text);
47 }; 44 };
48 45
49 #endif 46 typedef intrusive_ptr<Filter> FilterPtr;
LEFTRIGHT

Powered by Google App Engine
This is Rietveld