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: Use new API in the shell Created March 27, 2013, 4:58 a.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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « shell/src/MatchesCommand.h ('k') | shell/src/SubscriptionsCommand.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 #include <iostream> 1 #include <iostream>
2 #include <sstream> 2 #include <sstream>
3 3
4 #include "MatchesCommand.h" 4 #include "MatchesCommand.h"
5 5
6 MatchesCommand::MatchesCommand(AdblockPlus::FilterEngine& filterEngine) 6 MatchesCommand::MatchesCommand(AdblockPlus::FilterEngine& filterEngine)
7 : Command("matches"), filterEngine(filterEngine) 7 : Command("matches"), filterEngine(filterEngine)
8 { 8 {
9 } 9 }
10 10
11 void MatchesCommand::operator()(const std::string& arguments) 11 void MatchesCommand::operator()(const std::string& arguments)
12 { 12 {
13 std::istringstream argumentStream(arguments); 13 std::istringstream argumentStream(arguments);
14 std::string url; 14 std::string url;
15 argumentStream >> url; 15 argumentStream >> url;
16 std::string contentType; 16 std::string contentType;
17 argumentStream >> contentType; 17 argumentStream >> contentType;
18 if (!url.size() || !contentType.size()) 18 if (!url.size() || !contentType.size())
19 { 19 {
20 ShowUsage(); 20 ShowUsage();
21 return; 21 return;
22 } 22 }
23 23
24 if (filterEngine.MatchesFilters(url, contentType)) 24 if (filterEngine.Matches(url, contentType))
25 std::cout << "Match" << std::endl; 25 std::cout << "Match" << std::endl;
26 else 26 else
27 std::cout << "No match" << std::endl; 27 std::cout << "No match" << std::endl;
28 } 28 }
29 29
30 std::string MatchesCommand::GetDescription() const 30 std::string MatchesCommand::GetDescription() const
31 { 31 {
32 return "Returns the first filter that matches the supplied URL"; 32 return "Returns the first filter that matches the supplied URL";
33 } 33 }
34 34
35 std::string MatchesCommand::GetUsage() const 35 std::string MatchesCommand::GetUsage() const
36 { 36 {
37 return name + " URL CONTENT_TYPE"; 37 return name + " URL CONTENT_TYPE";
38 } 38 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld