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

Unified Diff: compiled/filter/ActiveFilter.h

Issue 29574591: Issue 5258 - Implement Filter::As<>() method to make working with filters easier from C++ code (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Created Oct. 12, 2017, 12:13 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | compiled/filter/BlockingFilter.h » ('j') | compiled/filter/CommentFilter.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiled/filter/ActiveFilter.h
===================================================================
--- a/compiled/filter/ActiveFilter.h
+++ b/compiled/filter/ActiveFilter.h
@@ -63,8 +63,17 @@ public:
FILTER_PROPERTY(unsigned int, mLastHit, FILTER_LASTHIT,
GetLastHit, SetLastHit);
bool BINDINGS_EXPORTED IsActiveOnDomain(DependentString& docDomain,
const String& sitekey) const;
bool BINDINGS_EXPORTED IsActiveOnlyOnDomain(DependentString& docDomain) const;
bool BINDINGS_EXPORTED IsGeneric() const;
OwnedString BINDINGS_EXPORTED Serialize() const;
};
+
+template<>
+inline ActiveFilter* Filter::As<ActiveFilter>()
+{
+ if ((mType & Type::ACTIVE) == Type::ACTIVE)
sergei 2017/10/12 12:24:34 I wonder whether concrete type value can be a clas
hub 2017/10/12 13:51:33 You can have static const, but then for linkage pu
sergei 2017/10/12 13:57:31 A method is also fine for me, can we use constexpr
hub 2017/10/12 14:03:01 Yes you can. I recommend doing so.
Wladimir Palant 2017/10/13 11:43:28 Done.
+ return nullptr;
+
+ return static_cast<ActiveFilter*>(this);
+}
« no previous file with comments | « no previous file | compiled/filter/BlockingFilter.h » ('j') | compiled/filter/CommentFilter.h » ('J')

Powered by Google App Engine
This is Rietveld