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

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

Issue 9987009: Interface for the libadblockplus API (Closed)
Left Patch Set: Some changes to the API, implemented stubs Created March 26, 2013, 3:13 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 <AdblockPlus.h> 1 #include <AdblockPlus.h>
2 #include <fstream> 2 #include <fstream>
3 #include <iostream> 3 #include <iostream>
4 #include <sstream> 4 #include <sstream>
5 5
6 #include "GcCommand.h" 6 #include "GcCommand.h"
7 #include "HelpCommand.h" 7 #include "HelpCommand.h"
8 #include "SubscriptionsCommand.h" 8 #include "SubscriptionsCommand.h"
9 #include "MatchesCommand.h" 9 #include "MatchesCommand.h"
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 53 }
54 } 54 }
55 55
56 int main() 56 int main()
57 { 57 {
58 try 58 try
59 { 59 {
60 LibFileReader fileReader; 60 LibFileReader fileReader;
61 CerrErrorCallback errorCallback; 61 CerrErrorCallback errorCallback;
62 AdblockPlus::JsEngine jsEngine(&fileReader, 0); 62 AdblockPlus::JsEngine jsEngine(&fileReader, 0);
63 jsEngine.Load("adblockplus_compat.js"); 63 AdblockPlus::FilterEngine filterEngine(jsEngine);
64 jsEngine.Load("adblockplus.js");
65 64
66 CommandMap commands; 65 CommandMap commands;
67 Add(commands, new GcCommand(jsEngine)); 66 Add(commands, new GcCommand(jsEngine));
68 Add(commands, new HelpCommand(commands)); 67 Add(commands, new HelpCommand(commands));
69 Add(commands, new SubscriptionsCommand(jsEngine)); 68 Add(commands, new SubscriptionsCommand(filterEngine));
70 Add(commands, new MatchesCommand()); 69 Add(commands, new MatchesCommand(filterEngine));
71 70
72 std::string commandLine; 71 std::string commandLine;
73 while (ReadCommandLine(commandLine)) 72 while (ReadCommandLine(commandLine))
73 {
Felix Dahlke 2013/03/27 08:18:26 This whole block is an unrelated indentation chang
74 std::string commandName;
75 std::string arguments;
76 ParseCommandLine(commandLine, commandName, arguments);
77 const CommandMap::const_iterator it = commands.find(commandName);
78 try
74 { 79 {
75 std::string commandName; 80 if (it != commands.end())
76 std::string arguments; 81 (*it->second)(arguments);
77 ParseCommandLine(commandLine, commandName, arguments); 82 else
78 const CommandMap::const_iterator it = commands.find(commandName); 83 throw NoSuchCommandError(commandName);
79 try
80 {
81 if (it != commands.end())
82 (*it->second)(arguments);
83 else
84 throw NoSuchCommandError(commandName);
85 }
86 catch (NoSuchCommandError error)
87 {
88 std::cout << error.what() << std::endl;
89 }
90 } 84 }
85 catch (NoSuchCommandError error)
86 {
87 std::cout << error.what() << std::endl;
88 }
89 }
91 } 90 }
92 catch (const std::exception& e) 91 catch (const std::exception& e)
93 { 92 {
94 std::cerr << "Exception: " << e.what() << std::endl; 93 std::cerr << "Exception: " << e.what() << std::endl;
95 } 94 }
96 return 0; 95 return 0;
97 } 96 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld