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: Reduce redundant redundancy Created March 27, 2013, 6:45 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
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