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

Side by Side Diff: include/AdblockPlus/FilterEngine.h

Issue 10254076: API cleanup, get rid of JsObject and GetProperty() methods that don`t return JsValue (Closed)
Patch Set: Slightly better Filter/Subscription constructors Created April 26, 2013, 11:51 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | include/AdblockPlus/JsValue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #ifndef ADBLOCKPLUS_FILTER_ENGINE_H 1 #ifndef ADBLOCKPLUS_FILTER_ENGINE_H
2 #define ADBLOCKPLUS_FILTER_ENGINE_H 2 #define ADBLOCKPLUS_FILTER_ENGINE_H
3 3
4 #include <vector> 4 #include <vector>
5 #include <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 #include <AdblockPlus/JsEngine.h> 7 #include <AdblockPlus/JsEngine.h>
8 #include <AdblockPlus/JsValue.h> 8 #include <AdblockPlus/JsValue.h>
9 9
10 #include "tr1_memory.h" 10 #include "tr1_memory.h"
11 11
12 namespace AdblockPlus 12 namespace AdblockPlus
13 { 13 {
14 class FilterEngine; 14 class FilterEngine;
15 15
16 class JsObject : public JsValue 16 class Filter : public JsValue,
17 {
18 public:
19 std::string GetProperty(const std::string& name, const std::string& defaultV alue) const;
20 int64_t GetProperty(const std::string& name, int64_t defaultValue) const;
21 bool GetProperty(const std::string& name, bool defaultValue) const;
22 inline std::string GetProperty(const std::string& name, const char* defaultV alue) const
23 {
24 return GetProperty(name, std::string(defaultValue));
25 }
26 inline int64_t GetProperty(const std::string& name, int defaultValue) const
27 {
28 return GetProperty(name, static_cast<int64_t>(defaultValue));
29 }
30
31 protected:
32 JsObject(JsValuePtr value);
33 };
34
35 class Filter : public JsObject,
36 public std::tr1::enable_shared_from_this<Filter> 17 public std::tr1::enable_shared_from_this<Filter>
37 { 18 {
38 public: 19 public:
39 enum Type {TYPE_BLOCKING, TYPE_EXCEPTION, 20 enum Type {TYPE_BLOCKING, TYPE_EXCEPTION,
40 TYPE_ELEMHIDE, TYPE_ELEMHIDE_EXCEPTION, 21 TYPE_ELEMHIDE, TYPE_ELEMHIDE_EXCEPTION,
41 TYPE_COMMENT, TYPE_INVALID}; 22 TYPE_COMMENT, TYPE_INVALID};
42 23
24 Type GetType();
43 bool IsListed(); 25 bool IsListed();
44 void AddToList(); 26 void AddToList();
45 void RemoveFromList(); 27 void RemoveFromList();
46 bool operator==(const Filter& filter) const; 28 bool operator==(const Filter& filter) const;
47 29
48 Filter(JsValuePtr value); 30 Filter(JsValuePtr value);
49 }; 31 };
50 32
51 class Subscription : public JsObject, 33 class Subscription : public JsValue,
52 public std::tr1::enable_shared_from_this<Subscription> 34 public std::tr1::enable_shared_from_this<Subscription>
53 { 35 {
54 public: 36 public:
55 bool IsListed(); 37 bool IsListed();
56 void AddToList(); 38 void AddToList();
57 void RemoveFromList(); 39 void RemoveFromList();
58 void UpdateFilters(); 40 void UpdateFilters();
59 bool IsUpdating(); 41 bool IsUpdating();
60 bool operator==(const Subscription& subscription) const; 42 bool operator==(const Subscription& subscription) const;
61 43
(...skipping 16 matching lines...) Expand all
78 const std::string& contentType, 60 const std::string& contentType,
79 const std::string& documentUrl); 61 const std::string& documentUrl);
80 std::vector<std::string> GetElementHidingSelectors(const std::string& domain ) const; 62 std::vector<std::string> GetElementHidingSelectors(const std::string& domain ) const;
81 63
82 private: 64 private:
83 JsEnginePtr jsEngine; 65 JsEnginePtr jsEngine;
84 }; 66 };
85 } 67 }
86 68
87 #endif 69 #endif
OLDNEW
« no previous file with comments | « no previous file | include/AdblockPlus/JsValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld