LEFT | RIGHT |
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 } |
LEFT | RIGHT |