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

Delta Between Two Patch Sets: compiled/subscription/UserDefinedSubscription.h

Issue 29548581: Issue 4128, 5138 - Add Parser and Serializer implemented in C++ Base URL: https://github.com/adblockplus/adblockpluscore.git
Left Patch Set: Created Sept. 18, 2017, 5:23 p.m.
Right Patch Set: rebase Created March 7, 2018, 12:01 p.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 | « compiled/subscription/Subscription.cpp ('k') | compiled/subscription/UserDefinedSubscription.cpp » ('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 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #pragma once 18 #pragma once
19 19
20 #include "../base.h"
20 #include "Subscription.h" 21 #include "Subscription.h"
21 #include "../filter/Filter.h" 22 #include "../filter/Filter.h"
22 #include "../bindings/runtime.h" 23 #include "../bindings/runtime.h"
24
25 ABP_NS_BEGIN
23 26
24 class UserDefinedSubscription : public Subscription 27 class UserDefinedSubscription : public Subscription
25 { 28 {
26 private: 29 private:
27 int mDefaults; 30 int mDefaults;
28 31
29 public: 32 public:
33 static constexpr Type classType = Type::USERDEFINED;
30 explicit UserDefinedSubscription(const String& id, const KeyValues& properties ); 34 explicit UserDefinedSubscription(const String& id, const KeyValues& properties );
31 bool BINDINGS_EXPORTED IsDefaultFor(const Filter& filter) const; 35 bool BINDINGS_EXPORTED IsDefaultFor(const Filter& filter) const;
32 void BINDINGS_EXPORTED MakeDefaultFor(const Filter& filter); 36 void BINDINGS_EXPORTED MakeDefaultFor(const Filter& filter);
33 bool BINDINGS_EXPORTED IsGeneric() const 37 bool BINDINGS_EXPORTED IsGeneric() const
34 { 38 {
35 return mDefaults == 0; 39 return mDefaults == 0;
36 } 40 }
37 void BINDINGS_EXPORTED InsertFilterAt(Filter& filter, unsigned pos); 41 void BINDINGS_EXPORTED InsertFilterAt(Filter& filter, unsigned pos);
38 bool BINDINGS_EXPORTED RemoveFilterAt(unsigned pos); 42 bool BINDINGS_EXPORTED RemoveFilterAt(unsigned pos);
39 OwnedString SerializeProperties() const; 43 OwnedString SerializeProperties() const;
40 private: 44 private:
41 static void parseDefaultsProperty(const KeyValues& properties, int& member); 45 static void parseDefaultsProperty(const KeyValues& properties, int& member);
42 }; 46 };
43 47
44 template<> 48 typedef intrusive_ptr<UserDefinedSubscription> UserDefinedSubscriptionPtr;
45 inline UserDefinedSubscription* Subscription::As<UserDefinedSubscription>()
46 {
47 if (mType != Type::USERDEFINED)
48 return nullptr;
49 49
50 return static_cast<UserDefinedSubscription*>(this); 50 ABP_NS_END
51 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld