LEFT | RIGHT |
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 #include <string> | |
6 | 4 |
7 #include "ActiveFilter.h" | 5 #include "ActiveFilter.h" |
8 | 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 |
9 class ElemHideBase : public ActiveFilter | 40 class ElemHideBase : public ActiveFilter |
10 { | 41 { |
11 private: | 42 protected: |
12 std::u16string selector; | 43 ElemHideBaseData mData; |
13 public: | 44 public: |
14 ElemHideBase(const std::u16string& text, const std::u16string& domains, | 45 explicit ElemHideBase(Type type, const String& text, const ElemHideBaseData& d
ata); |
15 const std::u16string& selector); | 46 static Type Parse(DependentString& text, ElemHideData& data); |
16 static Type Parse(const std::u16string& text, size_t* domainsEnd, | |
17 size_t* selectorStart); | |
18 static ElemHideBase* Create(const std::u16string& text); | |
19 | 47 |
20 const std::u16string GetSelector() const | 48 EMSCRIPTEN_KEEPALIVE const DependentString GetSelector() const |
21 { | 49 { |
22 return selector; | 50 return mData.GetSelector(mText); |
23 } | 51 } |
24 | 52 |
25 const std::u16string GetSelectorDomain() const; | 53 EMSCRIPTEN_KEEPALIVE OwnedString GetSelectorDomain() const; |
26 }; | 54 }; |
27 | |
28 #endif | |
LEFT | RIGHT |