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

Unified Diff: shell/src/MatchesCommand.cpp

Issue 9987009: Interface for the libadblockplus API (Closed)
Patch Set: Use new API in the shell Created March 27, 2013, 4:58 a.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 | « shell/src/MatchesCommand.h ('k') | shell/src/SubscriptionsCommand.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.MatchesFilters(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";
}
« no previous file with comments | « shell/src/MatchesCommand.h ('k') | shell/src/SubscriptionsCommand.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld