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

Delta Between Two Patch Sets: compiled/ElemHideBase.h

Issue 29333474: Issue 4125 - [emscripten] Convert filter classes to C++ (Closed)
Left Patch Set: Reworked JS binding generation Created Feb. 1, 2016, 9:14 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/CommentFilter.cpp ('k') | compiled/ElemHideBase.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_ELEM_HIDE_BASE_H 1 #pragma once
2 #define ADBLOCK_PLUS_ELEM_HIDE_BASE_H
3 2
4 #include <cstddef> 3 #include <cstddef>
5 4
6 #include "ActiveFilter.h" 5 #include "ActiveFilter.h"
7 6
7 struct ElemHideBaseData
8 {
9 String::size_type mDomainsEnd;
10 String::size_type mSelectorStart;
11
12 bool HasDomains() const
13 {
14 return mDomainsEnd != 0;
15 }
16
17 DependentString GetDomainsSource(String& text) const
18 {
19 return DependentString(text, 0, mDomainsEnd);
20 }
21
22 const DependentString GetDomainsSource(const String& text) const
23 {
24 return DependentString(text, 0, mDomainsEnd);
25 }
26
27 DependentString GetSelector(String& text) const
28 {
29 return DependentString(text, mSelectorStart);
30 }
31
32 const DependentString GetSelector(const String& text) const
33 {
34 return DependentString(text, mSelectorStart);
35 }
36 };
37
38 struct ElemHideData;
39
8 class ElemHideBase : public ActiveFilter 40 class ElemHideBase : public ActiveFilter
9 { 41 {
10 private: 42 protected:
11 String mSelector; 43 ElemHideBaseData mData;
12 public: 44 public:
13 ElemHideBase(const String& text, String::size_type domainsEnd, 45 explicit ElemHideBase(Type type, const String& text, const ElemHideBaseData& d ata);
14 String::size_type selectorStart); 46 static Type Parse(DependentString& text, ElemHideData& data);
15 static Type Parse(const String& text, String::size_type* domainsEnd,
16 String::size_type* selectorStart,
17 String::size_type* prefixEnd = nullptr,
18 String::size_type* regexpStart = nullptr,
19 String::size_type* regexpEnd = nullptr,
20 String::size_type* suffixStart = nullptr);
21 static Filter* Create(const String& text);
22 47
23 EMSCRIPTEN_KEEPALIVE const String GetSelector() const 48 EMSCRIPTEN_KEEPALIVE const DependentString GetSelector() const
24 { 49 {
25 return mSelector; 50 return mData.GetSelector(mText);
26 } 51 }
27 52
28 EMSCRIPTEN_KEEPALIVE String GetSelectorDomain() const; 53 EMSCRIPTEN_KEEPALIVE OwnedString GetSelectorDomain() const;
29 }; 54 };
30
31 #endif
LEFTRIGHT

Powered by Google App Engine
This is Rietveld