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

Unified Diff: compiled/filter/CommentFilter.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/CommentFilter.h
===================================================================
--- a/compiled/filter/CommentFilter.h
+++ b/compiled/filter/CommentFilter.h
@@ -21,8 +21,17 @@
class CommentFilter : public Filter
{
public:
explicit CommentFilter(const String& text);
static Type Parse(const String& text);
static CommentFilter* Create(const String& text);
};
+
+template<>
+inline CommentFilter* Filter::As<CommentFilter>()
+{
+ if ((mType & Type::COMMENT) == Type::COMMENT)
sergei 2017/10/12 12:24:34 Tests would be very helpful, so far it seems it al
Wladimir Palant 2017/10/13 11:43:28 This is C++ internals, so it cannot be tested dire
+ return nullptr;
+
+ return static_cast<CommentFilter*>(this);
+}

Powered by Google App Engine
This is Rietveld