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

Delta Between Two Patch Sets: shell/src/MatchesCommand.cpp

Issue 9987009: Interface for the libadblockplus API (Closed)
Left Patch Set: Rename to FilterEngine, add a dummy implementation Created March 26, 2013, 1:50 p.m.
Right Patch Set: Reduce redundant redundancy Created March 27, 2013, 6:45 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
LEFTRIGHT
(no file at all)
1 #include <iostream>
2 #include <sstream>
3
1 #include "MatchesCommand.h" 4 #include "MatchesCommand.h"
2 5
3 MatchesCommand::MatchesCommand() : Command("matches") 6 MatchesCommand::MatchesCommand(AdblockPlus::FilterEngine& filterEngine)
7 : Command("matches"), filterEngine(filterEngine)
4 { 8 {
5 } 9 }
6 10
7 void MatchesCommand::operator()(const std::string& arguments) 11 void MatchesCommand::operator()(const std::string& arguments)
8 { 12 {
13 std::istringstream argumentStream(arguments);
14 std::string url;
15 argumentStream >> url;
16 std::string contentType;
17 argumentStream >> contentType;
18 if (!url.size() || !contentType.size())
19 {
20 ShowUsage();
21 return;
22 }
23
24 if (filterEngine.Matches(url, contentType))
25 std::cout << "Match" << std::endl;
26 else
27 std::cout << "No match" << std::endl;
9 } 28 }
10 29
11 std::string MatchesCommand::GetDescription() const 30 std::string MatchesCommand::GetDescription() const
12 { 31 {
13 return "Returns the first filter that matches the supplied URL"; 32 return "Returns the first filter that matches the supplied URL";
14 } 33 }
15 34
16 std::string MatchesCommand::GetUsage() const 35 std::string MatchesCommand::GetUsage() const
17 { 36 {
18 return name + " URL"; 37 return name + " URL CONTENT_TYPE";
19 } 38 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld