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

Unified Diff: compiled/filter/RegExpFilter.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
Index: compiled/filter/RegExpFilter.h
===================================================================
--- a/compiled/filter/RegExpFilter.h
+++ b/compiled/filter/RegExpFilter.h
@@ -106,8 +106,17 @@ public:
explicit RegExpFilter(Type type, const String& text, const RegExpFilterData& data);
~RegExpFilter();
static Type Parse(DependentString& text, DependentString& error,
RegExpFilterData& data);
static void GenerateCustomBindings();
bool BINDINGS_EXPORTED Matches(const String& location, int typeMask,
DependentString& docDomain, bool thirdParty, const String& sitekey) const;
};
+
+template<>
+inline RegExpFilter* Filter::As<RegExpFilter>()
+{
+ if ((mType & Type::REGEXP) == Type::REGEXP)
+ return nullptr;
+
+ return static_cast<RegExpFilter*>(this);
+}

Powered by Google App Engine
This is Rietveld