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

Delta Between Two Patch Sets: compiled/filter/Filter.h

Issue 29613616: Issue 6064 - Put C++ code into a configurable namespace (Closed) Base URL: https://github.com/adblockplus/adblockpluscore.git
Left Patch Set: address comments Created Nov. 22, 2017, 9:36 a.m.
Right Patch Set: rebase Created Feb. 6, 2018, 9:54 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
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 20 matching lines...) Expand all
31 { 31 {
32 protected: 32 protected:
33 OwnedString mText; 33 OwnedString mText;
34 34
35 public: 35 public:
36 enum Type 36 enum Type
37 { 37 {
38 UNKNOWN = 0, 38 UNKNOWN = 0,
39 INVALID = 1, 39 INVALID = 1,
40 COMMENT = 2, 40 COMMENT = 2,
41 BLOCKING = 3, 41 ACTIVE = 4,
42 WHITELIST = 4, 42 REGEXP = ACTIVE | 8,
43 ELEMHIDE = 5, 43 BLOCKING = REGEXP | 16,
44 ELEMHIDEEXCEPTION = 6, 44 WHITELIST = REGEXP | 32,
45 ELEMHIDEEMULATION = 7, 45 ELEMHIDEBASE = ACTIVE | 64,
46 VALUE_COUNT = 8 46 ELEMHIDE = ELEMHIDEBASE | 128,
47 ELEMHIDEEXCEPTION = ELEMHIDEBASE | 256,
48 ELEMHIDEEMULATION = ELEMHIDEBASE | 512
47 }; 49 };
48 50
49 explicit Filter(Type type, const String& text); 51 explicit Filter(Type type, const String& text);
50 ~Filter(); 52 ~Filter();
51 53
52 Type mType; 54 Type mType;
53 55
54 const String& BINDINGS_EXPORTED GetText() const 56 const String& BINDINGS_EXPORTED GetText() const
55 { 57 {
56 return mText; 58 return mText;
57 } 59 }
58 60
59 OwnedString BINDINGS_EXPORTED Serialize() const; 61 OwnedString BINDINGS_EXPORTED Serialize() const;
60 62
61 static Filter* BINDINGS_EXPORTED FromText(DependentString& text); 63 static Filter* BINDINGS_EXPORTED FromText(DependentString& text);
64
65 template<typename T>
66 T* As()
67 {
68 if ((mType & T::classType) != T::classType)
69 return nullptr;
70
71 return static_cast<T*>(this);
72 }
73
74 template<typename T>
75 const T* As() const
76 {
77 if ((mType & T::classType) != T::classType)
78 return nullptr;
79
80 return static_cast<const T*>(this);
81 }
62 }; 82 };
63 83
64 typedef intrusive_ptr<Filter> FilterPtr; 84 typedef intrusive_ptr<Filter> FilterPtr;
65 85
66 ABP_NS_END 86 ABP_NS_END
LEFTRIGHT

Powered by Google App Engine
This is Rietveld