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

Unified Diff: shell/src/MatchesCommand.cpp

Issue 10016005: Add API calls and stubs for filter matching and subscription management (Closed)
Patch Set: Created April 3, 2013, 12:42 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: shell/src/MatchesCommand.cpp
===================================================================
--- a/shell/src/MatchesCommand.cpp
+++ b/shell/src/MatchesCommand.cpp
@@ -1,11 +1,30 @@
+#include <iostream>
+#include <sstream>
+
#include "MatchesCommand.h"
-MatchesCommand::MatchesCommand() : Command("matches")
+MatchesCommand::MatchesCommand(AdblockPlus::FilterEngine& filterEngine)
+ : Command("matches"), filterEngine(filterEngine)
{
}
void MatchesCommand::operator()(const std::string& arguments)
{
+ std::istringstream argumentStream(arguments);
+ std::string url;
+ argumentStream >> url;
+ std::string contentType;
+ argumentStream >> contentType;
+ if (!url.size() || !contentType.size())
+ {
+ ShowUsage();
+ return;
+ }
+
+ if (filterEngine.Matches(url, contentType))
+ std::cout << "Match" << std::endl;
+ else
+ std::cout << "No match" << std::endl;
}
std::string MatchesCommand::GetDescription() const
@@ -15,5 +34,5 @@
std::string MatchesCommand::GetUsage() const
{
- return name + " URL";
+ return name + " URL CONTENT_TYPE";
}

Powered by Google App Engine
This is Rietveld